im working on a pong game, and thus i want to integrate an AI system. after a bit of planning the only way i could think of doing it would be to have one of the platform thingies (the AI one) follow the ball, but that would make impossible to beat it would it not? so is there any other way to do this?
8 replies to this topic
#1
Posted 13 October 2011 - 07:46 AM
|
|
|
#2
Posted 13 October 2011 - 09:52 AM
You could have it follow the ball, but move the platform more slowly than the ball can move.
#3
Posted 13 October 2011 - 09:55 AM
not to stupid :)
but noob question, how can i make it slower than the ball? the only method for slowing things down or speeding them up that i have found as of yet is the FPS regulating.
but noob question, how can i make it slower than the ball? the only method for slowing things down or speeding them up that i have found as of yet is the FPS regulating.
#4
Posted 13 October 2011 - 11:40 AM
I don't know all that much about this kind of thing but here's my suggestion:
Have a variable that will be used to measure the direction of the paddle movement. Any time the ball moves to the other side of the paddle, have the variable switch to another value that will represent movement in that direction. You could have the variable flip between negative and positive values for direction. Then you could implement paddle movement separately from the ball's movement.
Have a variable that will be used to measure the direction of the paddle movement. Any time the ball moves to the other side of the paddle, have the variable switch to another value that will represent movement in that direction. You could have the variable flip between negative and positive values for direction. Then you could implement paddle movement separately from the ball's movement.
Latinamne loqueris?
#5
Posted 13 October 2011 - 01:21 PM
hmm ye that might work. i am too tired to try to implement it today, but i will definetely let you know if it worked once i implement it.
#6
Posted 13 October 2011 - 08:27 PM
Right now you might take 1 of the paddles y variable.
So instead you take say 0.8 making it 0.2 pixels per frame slower than something which has 1 taken off it's x value every frame. Get what I'm going at??
So instead you take say 0.8 making it 0.2 pixels per frame slower than something which has 1 taken off it's x value every frame. Get what I'm going at??
Please, write clearly with proper structure. Double spacing makes the text feel un-jointed, Capitalizing Every Word Means People Stop Before Every Word Sub-Consciously Which Is A Pain In The Backside, and use code tags! (The right most styling box).
#7
Posted 14 October 2011 - 02:13 AM
i did it like this, and it worked pretty good.
i checked if the y value of the paddle was less than the y value of the ball + its height. if this was true then the paddle would start moving up.
then i checked if the y value of the paddle + its height was greater than the y value of the ball. f this was true then the paddle would start moving down.
i hope that makes sense :)
i checked if the y value of the paddle was less than the y value of the ball + its height. if this was true then the paddle would start moving up.
then i checked if the y value of the paddle + its height was greater than the y value of the ball. f this was true then the paddle would start moving down.
i hope that makes sense :)
#8
Posted 15 October 2011 - 10:44 PM
Cool, does the paddle move faster or slower than the ball?
Please, write clearly with proper structure. Double spacing makes the text feel un-jointed, Capitalizing Every Word Means People Stop Before Every Word Sub-Consciously Which Is A Pain In The Backside, and use code tags! (The right most styling box).
#9
Posted 16 October 2011 - 02:56 AM
it moves at the same phase as the ball, howerver it start moving after the ball has past the paddle in a way
i think i am gonna change it in the near future thought (it doesn't add to much of a challange to the game), but for a first AI im fairly happy with it lol.
i think i am gonna change it in the near future thought (it doesn't add to much of a challange to the game), but for a first AI im fairly happy with it lol.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









