Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

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.


Messages - enderboy768

Pages: [1]
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?

2
General / Difference of passing a * parameter and a & parameter
« on: June 10, 2017, 03:27:30 pm »
I was reading a tutorial on the internet about game states and then they showed a class of game state with these functions in it:

Code: [Select]
class CGameEngine
{
public:
//... some functions

  void ChangeState(CGameState* state);
  void PushState(CGameState* state);

private:
  // the stack of states
  vector<CGameState*> states;
//... some variables
};


My question is, why is the changeState and pushState need a parameter with *? I thought you would use the & symbol if you want to pass the actual object/variables instead of the copy. Is there any difference? Thank you in advance!  ;D

3
Graphics / How to create a simple pause if win condition is true?
« on: June 08, 2017, 03:18:00 pm »
I wanted to create a simple pause in my pong game so that if any of the player reach a certain score, the game will freeze and a text shows up saying which player has won the game and if a certain key is pressed the game will restart. I tried this: (sorry if it's too simple, I'm a complete newbie  :-[)

Code: [Select]
// 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;
            }
        }

4
Graphics / Re: Rectangle Object collides with Text object
« on: June 08, 2017, 10:46:41 am »
Hehe thanks  ;D

5
Graphics / Re: Rectangle Object collides with Text object
« on: June 06, 2017, 07:49:33 pm »
Oops, my bad! The ball didn't get stuck to the HUD. It actually got stuck to the paddle when it was right behind the HUD (noob error!).

6
Graphics / Rectangle Object collides with Text object
« on: June 06, 2017, 07:23:44 pm »
I have made a little Pong project. I wanted to put a heads up display using sf::Text to it but it turns out the ball (not really, it's a rectangle from sf::RectangleShape) will get stuck when it went through the text. And apparently, the paddle got stuck too! Is there anyway I can make the HUD/the text kind of 'invisible' to the ball and the paddle? Thank you in advance!

7
Graphics / Simple Map Borders
« on: May 14, 2017, 02:00:18 pm »
How do I create like an invisible wall at each side of my window so any moving object can not pass through it? I tried setting the speed to 0 or multiplying it by -1 if the object reach the side, but if I press the arrow keys several times it would still go through it. Sorry if this sounds like a noob question. Thank you in advance!  ;D

8
Graphics / Re: Passing Entity Position to an If Statement
« on: May 14, 2017, 11:16:21 am »
Ah, thank you very much!  :D And yes, by entity I meant object! 

9
Graphics / Passing Entity Position to an If Statement
« on: May 14, 2017, 08:02:42 am »
Is there any simple way to get the entity position to use it in an if statement? I want to use lit like if the moving entity reach a certain point, it will change the direction. And if you want to put any examples / explanation please put it as simple as possible because I'm just starting to learn game programming. Thank you in advance!  :)

Pages: [1]
anything