1
General / Re: Difference of passing a * parameter and a & parameter
« on: June 10, 2017, 03:35:17 pm »
So you mean the function would also work if I changed the * in changeState and pushState parameter to the & symbol?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
class CGameEngine
{
public:
//... some functions
void ChangeState(CGameState* state);
void PushState(CGameState* state);
private:
// the stack of states
vector<CGameState*> states;
//... some variables
};
// ball went through bottom of the window
if(ball.getPosition().top > windowHeight)
{
ball.initPos();
bat1.initPos();
bat2.initPos();
lives1--; // p1's life is negated
// life check, reset values if true
if(lives1 < 1)
{
score2++;
lives1 = 3;
}
}
// ball went through top of the window
if(ball.getPosition().top < 0)
{
ball.initPos();
bat1.initPos();
bat2.initPos();
lives2--; // p2's life is negated
// life check, reset values if true
if(lives2 < 1)
{
score1++;
lives2 = 3;
}
}