Jump to content
  • Advertisement
Sign in to follow this  
StephanieWhite

AI help for simple pong game.

This topic is 2603 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've just recently become very familiar with SDL basics. I can draw, move and change control over images, etc. I decided pong to be my first ever game. I can get the ball, player's paddle and computer's paddle to move accordingly in any circumstances and I can get the ball to move to(to a point), but I could use some BASIC and MINIMAL help, if you will concur!

I need a way of accurately having a control function represent the movement of the computer's paddle to where the ball is, but not make it 100% perfect. That's the problem. Since I don't do OOP no OOP help would be appreciated, but help in general would. If you also would, I am having small problems with collision detection as well. Thanks!

-Stephanie.

Share this post


Link to post
Share on other sites
Advertisement
Well, the simple approach that Pong usually takes is to have the computer paddle move at a limited speed. Each frame, you compute the placement where the paddle should be (to hit the ball), versus the current position of the paddle. You then take the smaller of the difference or the maximum speed of the paddle, and move the paddle by that amount in that frame.


Hope that gets you started without giving away too much :-) Feel free to ask if you'd like anything in deeper detail.

Share this post


Link to post
Share on other sites

Well, the simple approach that Pong usually takes is to have the computer paddle move at a limited speed. Each frame, you compute the placement where the paddle should be (to hit the ball), versus the current position of the paddle. You then take the smaller of the difference or the maximum speed of the paddle, and move the paddle by that amount in that frame.


Hope that gets you started without giving away too much :-) Feel free to ask if you'd like anything in deeper detail.


i dont define/work with frame speed or calculate frame speed. i find it unceessary like i just want the global idea not the whole scoop on how to manage and write my own code. i do it my own way

Share this post


Link to post
Share on other sites

i dont define/work with frame speed or calculate frame speed. i find it unceessary

Then you're doing it wrong.


like i just want the global idea not the whole scoop on how to manage and write my own code. i do it my own way
[/quote]
Then you will never get help no matter how many questions you ask and how many answers we post.

If you want to "do it your own way" then don't ask questions. If you want to learn something, accept the answers you are given.

Share this post


Link to post
Share on other sites

[quote name='SWQUEENIFY' timestamp='1319763369' post='4877736']
i dont define/work with frame speed or calculate frame speed. i find it unceessary

Then you're doing it wrong.


like i just want the global idea not the whole scoop on how to manage and write my own code. i do it my own way
[/quote]
Then you will never get help no matter how many questions you ask and how many answers we post.

If you want to "do it your own way" then don't ask questions. If you want to learn something, accept the answers you are given.
[/quote]

umad? lol. i told ya all i do it my way. if you wanna help, go ahead, but if you cant it aint my fault. i do it my way because i dont conform to others shit. go with it or fuck off you aint helping me anymore than i can help myself. and if my way is wrong then explain why i got 50% of a pong game accomplished without any help?

yeah thats waht i thaut.

think outside the box or think in it. im thinking out of it. good luck passing around your horse shit to people tho.

PS: Since when it a crime to give a broad idea rather than a complete personal concept? theres a diferrence between helping someone learn how to walk themself their own way and telling them how YOU walk yourself. everyone walks diferrently.

tho i knoe you cant respond 2 this questin because your wrong!

Share this post


Link to post
Share on other sites
Hidden

[quote name='IADaveMark' timestamp='1319765041' post='4877748']
[quote name='SWQUEENIFY' timestamp='1319763369' post='4877736']
i dont define/work with frame speed or calculate frame speed. i find it unceessary

Then you're doing it wrong.


like i just want the global idea not the whole scoop on how to manage and write my own code. i do it my own way
[/quote]
Then you will never get help no matter how many questions you ask and how many answers we post.

If you want to "do it your own way" then don't ask questions. If you want to learn something, accept the answers you are given.
[/quote]

umad? lol. i told ya all i do it my way. if you wanna help, go ahead, but if you cant it aint my fault. i do it my way because i dont conform to others shit. go with it or fuck off you aint helping me anymore than i can help myself. and if my way is wrong then explain why i got 50% of a pong game accomplished without any help?

yeah thats waht i thaut.

think outside the box or think in it. im thinking out of it. good luck passing around your horse shit to people tho.

PS: Since when it a crime to give a broad idea rather than a complete personal concept? theres a diferrence between helping someone learn how to walk themself their own way and telling them how YOU walk yourself. everyone walks diferrently.

tho i knoe you cant respond 2 this questin because your wrong!
[/quote]

I'm a student and hobbyist developer, so take my technical advice with a grain of salt. :P

Frames are a generally used convention in games - including indie/homebrew/casual games - because it simplifies the developer's work enormously. Updating 30 times a second (or 60, or whatever) means that you can perform time-dependent calculations (for example, movement and acceleration) and scale it across all frame rates by simply multiplying by the time since the last frame.

For example, if your paddle moves 1 pixel per millisecond, and it's been 30 milliseconds since the last update, it'll move 10 pixels this frame. If you experience a lag spike for whatever reason and the next frame comes 50 milliseconds later, your paddle will move 50 pixels that frame - and the beauty of it is that the player doesn't know about the lag. It all looks like smooth motion (barring some insane quirk, which should not happen for a Pong clone). By the way, frame time works even if you're not using a fixed frame rate and you're just updating as fast as your computer will let you. If anything, frame time is MORE useful in that situation since moving your paddle at a constant rate every update could look odd if one frame takes 10 milliseconds to occur and the next one takes 50 milliseconds - the paddle will move the same distance in each frame, even though the second frame lasted five times as long as the first (bad for the player's experience). This doesn't sound too terrible for a handful of frames - I mean, it's only 40 pixels - but if you have a sustained period of slow frames that lasts a second, it can really ruin an otherwise good gaming experience.

Thinking outside the box is great, but it can be unproductive or even counterproductive when asking for advice because the vast majority of people who create games follow certain conventions because they are proven to be efficient and/or productive. The conventions may not be the absolute best solutions, but they are good solutions, and more importantly, they are well-known solutions. In this case, frame time improves the player's experience of the game when a lag spike occurs.

Oh, and one little thing: please try to type with proper English - that is, spelling and grammar. It shows that you are willing to spend a few moments of your time to make sure your question/reply is easily understood, and hopefully others will reciprocate and spend some of their time to answer your question(s).

Share this post


Link to post

[quote name='Olof Hedman' timestamp='1319809588' post='4877865']
pretty funny troll :P

Yeah... he was so funny that he got suspended within hours of making his account. dry.gif
[/quote]

I guess my sarcasm didn't show through enough, judging from the -1 I got. (unless it was from the troll)
I mostly meant to point out the obvious to save time for anyone thinking about replying.

Share this post


Link to post
Share on other sites

[quote name='IADaveMark' timestamp='1319828702' post='4877953']
[quote name='Olof Hedman' timestamp='1319809588' post='4877865']
pretty funny troll :P

Yeah... he was so funny that he got suspended within hours of making his account. dry.gif
[/quote]

I guess my sarcasm didn't show through enough, judging from the -1 I got. (unless it was from the troll)
I mostly meant to point out the obvious to save time for anyone thinking about replying.
[/quote]
Yeah... I was a little startled at the people who replied after things became obvious. Oh well.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!