My Pong Game

Anything related in any way to game development as a whole is welcome here. Tell us about your game, grace us with your project, show us your new YouTube video, etc.

Moderator: PC Supremacists

My Pong Game

Postby Marksie on Fri Jun 17, 2016 5:44 pm

Hi all,

I have just set up SFML on Visual Studio and I am attempting my first ever graphical game.
I have decided to jump in right at the deep end and go for Pong.
Please see below for my progress so far.

Pong1.PNG
Pong1.PNG (40.16 KiB) Viewed 508 times


So far I can move the left hand paddle up and down. No collision detection so it just goes off the screen.

More to follow.
Marksie
Chaos Rift Newbie
Chaos Rift Newbie
 
Posts: 3
Joined: Fri Jun 17, 2016 5:25 pm

Re: My Pong Game

Postby Marksie on Sat Jun 18, 2016 5:05 am

OK I have gotten up early this morning and decided to crack on with this modern day masterpiece.

I have gotten the ball moving, so far it heads towards the left hand side of the screen.
I have added some basic collision detection as per below, this means that if the ball hits my paddle it changes the speed so it goes in the opposite direction.

Code: Select all
// Check Poistion of ball for Paddle collisions

      boundingBoxBall = Ball.getGlobalBounds();
      RectangleBox = rectangle.getGlobalBounds();
      PCRectangleBox = PCrectangle.getGlobalBounds();
      
      if (boundingBoxBall.intersects(RectangleBox))
      {
         BallX = 3;
      }

      if (boundingBoxBall.intersects(PCRectangleBox))
      {
         BallX = -3;
      }


      Ball.move(BallX, BallY);


My next steps are as follows:

Get the Computer controlled paddle moving.
Get collision detection set up, so that paddles cannot go off the screen.
Marksie
Chaos Rift Newbie
Chaos Rift Newbie
 
Posts: 3
Joined: Fri Jun 17, 2016 5:25 pm

Re: My Pong Game

Postby Marksie on Sat Jun 18, 2016 5:39 am

I have implemented some basic code to get the computer paddle moving:

Code: Select all
//Move the computer controlled paddle

      //Move the paddle up
      if (BallPos.y < PaddlePos.y)
      {
         PCrectangle.move(0, -1);
      }

      //Move the paddle down
      if (BallPos.y > PaddlePos.y)
      {
         PCrectangle.move(0, 1);
      }
Marksie
Chaos Rift Newbie
Chaos Rift Newbie
 
Posts: 3
Joined: Fri Jun 17, 2016 5:25 pm

Re: My Pong Game

Postby dandymcgee on Sat Jun 18, 2016 3:37 pm

Cool! Thanks for sharing your progress. It looks like you're getting through this pretty quick, nice work!
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
 
Posts: 4911
Joined: Tue Apr 29, 2008 4:24 pm
Location: New Hampshire


Return to Game Development

Who is online

Users browsing this forum: No registered users and 4 guests

cron