Pong example
swiftskater1
Member Posts: 97
I need to create the computer paddle. I need it to follow the ball vertically (Like the original pong). please help
Comments
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
It's fairly easy, since the only movement the computer can make is up or down.
Create Game Attribute BallY.
In the Ball Actor, Constrain Attribute BallY to be equal to the Ball's Position Y.
In Actor ComputerPaddle:
Make a timer that, for every 1 second,
Rule: if ComputerPaddle.Position.Y > BallY, go down, Otherwise, go up.
You can also add some randomness or increase the counter time to it so create a beginner computer level or that it would appear slower to respond, like a beginner player would.
Hope that helps.
Do you already have all the Actors in place in your Scene? Yours, the ball, and the Computer Paddle? Is the ball moving and bouncing properly?
So, under Game, go to Attributes, and create an Attribute. Make it an integer and call it "BallY."
Then, go back into the Ball Actor and add a Constrain Attribute Action, making Game.BallY to be equal to Ball.Position.Y.
Then, go back into the Computer Paddle Actor and create the Behaviors as listed above.
ComputerPaddle.Position.Y = ComputerPaddle.Position.Y - 5
"Go Up" is ComputerPaddle.Position.Y = ComputerPaddly.Position.Y + 5
Did you happen to look at any of the video tutorials?
Have you downloaded any of the sample projects and other people's games?
Go to one of the games playable on GameSalad.com.
You can right-click on the "Download Project" and save the .game file to your hard drive.
Then, rename it to .zip and you can open it and load the game into GameSalad.
It may be a good opportunity to peek in at other people's work to see how things are done.