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

Post Reply
Marksie
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 3
Joined: Fri Jun 17, 2016 4:25 pm

My Pong Game

Post by Marksie »

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 7293 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 4:25 pm

Re: My Pong Game

Post by Marksie »

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 4:25 pm

Re: My Pong Game

Post by Marksie »

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);
		}
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: My Pong Game

Post by dandymcgee »

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:
Post Reply