Help with my game? things appearing in wrong place

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
lysear
Posts: 3
Joined: March 31st, 2020, 4:22 pm

Help with my game? things appearing in wrong place

Post by lysear » April 22nd, 2020, 5:30 pm

Hi all,

https://github.com/joeharris200882/Pong2020

the above is a link to my Pong game, nothing fancy, really just using it as a chance to practice logic, classes etc. Can someone help me out, I think I have two main problems (maybe more, who knows)

1. The player 1 and player 2 score meters are appearing in the top left at 0, i want player one in top left, but not that high up, and player two should be over the other side of the screen.

2. I am not sure if the goalScored/gameOver conditions are all correct, It seems to end quicker than I would like (that's what she said)

Any help would be appreciated,

Joe

lysear
Posts: 3
Joined: March 31st, 2020, 4:22 pm

Re: Help with my game? things appearing in wrong place

Post by lysear » April 23rd, 2020, 12:37 am

Hello Joe,

Future Joe here,

Watch the video on constructors, then remember about the initializer list, then you will find the answer. Don't be that guy who asks a basic question without researching the answer yourself first.


Future Joe.

WilsonHuang
Posts: 44
Joined: February 13th, 2019, 3:23 am

Re: Help with my game? things appearing in wrong place

Post by WilsonHuang » April 23rd, 2020, 1:33 am

lysear wrote:
April 22nd, 2020, 5:30 pm
Hi all,

https://github.com/joeharris200882/Pong2020

the above is a link to my Pong game, nothing fancy, really just using it as a chance to practice logic, classes etc. Can someone help me out, I think I have two main problems (maybe more, who knows)

1. The player 1 and player 2 score meters are appearing in the top left at 0, i want player one in top left, but not that high up, and player two should be over the other side of the screen.

2. I am not sure if the goalScored/gameOver conditions are all correct, It seems to end quicker than I would like (that's what she said)

Any help would be appreciated,

Joe
Hi, Joe
1.
If you look at VS Error List, it warns you should initialize variable.
If you don't initialize variable, the compiler will give it a random number. (Assign a random memory to variable), and things will go wrong

Code: Select all

C26495	Variable 'Player::meterHeight' is uninitialized. Always initialize a member variable (type.6).
2.
You assign variables in InitMeter function wrong order.

Code: Select all

void Player::InitMeter(int in_meterx, int in_metery, int in_meterWidth, int in_meterHeight, Color in_c)
{
   in_meterx = meterx; // it should be  meterx = in_meterx;;
    in_metery = metery;
    in_meterWidth = meterWidth;
    in_meterHeight = meterHeight;
    in_c = meterc;
}

Post Reply