Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / My first pong game

Author
Message
aarrowh
17
Years of Service
User Offline
Joined: 19th Oct 2007
Location:
Posted: 6th Nov 2008 19:24
This is my first pong game. It does not have any AI, its 2 player.
up and down control the left paddle, W and S control the right.

C&C welcome



SOMEDAY, I will have coding skillz... :p
Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 6th Nov 2008 22:30
Awesome for your first pong!

Suggestions:

AI - Do not just make the game two player, add some AI for your next challenge.

Ball is a little fast too, and it starts too quick.

Otherwise, very good and way to go!

Vote Norris-Chan 2012!

C0wbox
18
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 6th Nov 2008 23:32
This game isn't bad, you just really need to make the controls the other way round because its very confusing to play quickly. I wanted to move the right hand bat and accidently moved the left hand 1 because I tried using the arrow keys. :S
aarrowh
17
Years of Service
User Offline
Joined: 19th Oct 2007
Location:
Posted: 7th Nov 2008 04:02 Edited at: 7th Nov 2008 04:10
Thanks a lot for the feedback! I've switched the paddle controls, so left paddle is W/S and right paddle is U/D - I have thought about multiple ways of implementing AI, but I can't think of the write way to code it.

I know it should be some type of code that will move the paddle at a specific speed up and down in relevance with the location of the ball. any help appreciated

(off topic)

could anybody provide a link to an image with keystate numbers on it, I've looked everywhere and have not been able to find it. the one in the tut I used was taken down, and I thought it would be a useful thing to have.
thanks,

Aarrowh

*edit*

Forgot the codez...



SOMEDAY, I will have coding skillz... :p
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 7th Nov 2008 10:48
you shoulda searched "scancodes" vs keystates; you woulda found a bunch. here's one:



Virtual Nomad
AMD XP 1800+ (~1.6 Ghz) / 1.5 GB RAM
ATI Radeon 8700LE 128 MB / Windows XP
Joeeigel
18
Years of Service
User Offline
Joined: 6th Jun 2006
Location: A dark room...
Posted: 7th Nov 2008 14:21
Why not make the AI paddle = balls Y possition, but have the paddle move slower so that its slightly behind the ball, giving the player a chance of winning.

aarrowh
17
Years of Service
User Offline
Joined: 19th Oct 2007
Location:
Posted: 7th Nov 2008 17:45 Edited at: 7th Nov 2008 17:53
Alrighty, I've gotten some very basic "AI" it is not beatable yet, I'm still working on that, but I noticed that now my collision does not work. I have no clue why either. anyways, here's the code.

*edit*
I've slowed down the paddle so I think its beatable, but still, seeing as how the collision isn't working. (still can't figure it out) I don't know for sure if its beatable.


SOMEDAY, I will have coding skillz... :p
aarrowh
17
Years of Service
User Offline
Joined: 19th Oct 2007
Location:
Posted: 20th Nov 2008 15:54
bump bump????

still can't get the collision to work...any help??

Code is in above post..

SOMEDAY, I will have coding skillz... :p
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 20th Nov 2008 18:16
Since the paddles are always on their respective side of the plain, you could just check if the sphere's position is within that of the boxes.
Something like

Of course, this will record a hit if the ball is behind the paddle as well, so you might want to add conditional statements to avoid that too.

Hope that helps


-> Oh, come on...
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 20th Nov 2008 18:38 Edited at: 20th Nov 2008 18:40
To give a sense of fallible AI, you could...

1. Limit the number of times the AI's paddle position code is run.

So, for instance allow the human player to update it's position once every game loop. You would then code the AI's position-update-code so it's only able to run say every 8 game loops.

Then to have the game become more difficult, you could decrease the number of game loops the computer AI must wait to say 7,6,5,4... game loops.

You would have to play with the exact number of loops to find a balance.

2. You can limit the speed of the AI paddle, and then to increase difficulty you can gradually allow the AI paddle to increase speed

3. You can also play around with the movement code after the computer AI returns the ball. Does it return to exact center, or can it drift passed the point of impact before it looks to the balls position again. Does it follow the ball position after it hits it, or does it wait for the player's return?

4. Finally you can introduce a chance of error when looking up the balls position, or knowledge that the ball will reflect of a playfield edge.


Just some ideas. Try combining them to create a fun difficulty curve.

"When I look at that square... I wish FPSC noobs would stay on their side of the forums and stop polluting these boards." - Benjamin
king 36
15
Years of Service
User Offline
Joined: 25th Nov 2008
Location:
Posted: 25th Nov 2008 22:36
i like it

jordon

Login to post a reply

Server time is: 2024-11-24 16:21:18
Your offset time is: 2024-11-24 16:21:18