Pong example

swiftskater1swiftskater1 Member Posts: 97
edited November -1 in Working with GS (Mac)
I need to create the computer paddle. I need it to follow the ball vertically (Like the original pong). please help

Comments

  • swiftskater1swiftskater1 Member Posts: 97
    Anyone??
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    take a look at the brick breaker sample code, that would work if you just rotated it.
  • swiftskater1swiftskater1 Member Posts: 97
    I understand that part. I meen. Like have the opponent go up and down randomly.
  • swiftskater1swiftskater1 Member Posts: 97
    I have looked at the wiki and is still don't get it
  • BeyondtheTechBeyondtheTech Member Posts: 809
    If I'm understanding you correctly, you want to want the computer to have some artificial intelligence for his paddle to follow the ball.

    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.
  • swiftskater1swiftskater1 Member Posts: 97
    I still dont get it sorry.
  • BeyondtheTechBeyondtheTech Member Posts: 809
    What part don't you get?

    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?
  • swiftskater1swiftskater1 Member Posts: 97
    Yes, I have all my actors in place. in the Ball Actor, Constrain Attribute BallY to be equal to the Ball's Position Y. I dont really get that.
  • swiftskater1swiftskater1 Member Posts: 97
    Also. ComputerPaddle.Position.Y > BallY, go down, Otherwise, go up. I usually understand all of this.. I don't know what im doing wrong.
  • BeyondtheTechBeyondtheTech Member Posts: 809
    A Game Attribute is basically a global variable. All Actors and all Scenes can get the value of that Attribute.

    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.
  • swiftskater1swiftskater1 Member Posts: 97
    Ok. But The BallY,go down. You cant enter spaces in expression editor. So? do i make a move attribute?
  • BeyondtheTechBeyondtheTech Member Posts: 809
    When using the Expression Editor, you can't type the Attributes in. You need to select it from the drop down (click the white downward facing triangle button) and select it from the list.
  • swiftskater1swiftskater1 Member Posts: 97
    Right, But where is the go down attributes? on the expression editor?
  • BeyondtheTechBeyondtheTech Member Posts: 809
    "Go Down" means move the Actor by adjusting the Y coordinates.
    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.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    You should watch some of TShirtBooth's video tutorials. They will help you get going with the basics. At the top of the website, click Profiles, and click on his profile. He has all sorts of great tutorials, demos, and examples of what can be done with GameSalad.
  • swiftskater1swiftskater1 Member Posts: 97
    yep. I did exactly what you did and now im getting a black screen.. hmm
  • swiftskater1swiftskater1 Member Posts: 97
    Ive used game salad alot.. im not sure why i cant do this one easy task!
  • swiftskater1swiftskater1 Member Posts: 97
    Ok. If someone can give me instructions one more time.. Please..
Sign In or Register to comment.