Make a paddle follow a ball back and fourth. Question for tshirtbooth

swiftskater1swiftskater1 Member Posts: 97
edited November -1 in Working with GS (Mac)
I have asked this before. But if someone can please give me clearer instructions.. Thank you.

Comments

  • swiftskater1swiftskater1 Member Posts: 97
    Thank you :)
  • swiftskater1swiftskater1 Member Posts: 97
    Okay. Got it working!! now. How would i make it slower and faster? kinda like a random speed!?
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I don't think it is possible using this method because you are constraining the paddle to the ball so it will always follow the ball. Not sure how to make the computer "beatable", but I image you could use accelerate towards instead of constrain. Then if the speed of acceleration is set to a random range you should be able to get the paddle to accelerate fast enough some of the time and not fast enough some of time thus making it beatable.
  • swiftskater1swiftskater1 Member Posts: 97
    Is there a diffrent method i could use?
  • EastboundEastbound Member, BASIC Posts: 1,074
    The one scitunes used sounds pretty easy to implement. Why not fo that route?
  • swiftskater1swiftskater1 Member Posts: 97
    Tried it. It just goes back and fourth at an insane speed.
  • swiftskater1swiftskater1 Member Posts: 97
    Ok. Thanks.
  • BeyondtheTechBeyondtheTech Member Posts: 809
    Oh well, I thought my implementation was good enough in the other thread he started. (http://gamesalad.com/forums/topic.php?id=2636)

    For future reference and probably speaking for the forum mods (if there are any), it probably would be best not to start up new threads regarding the same subject, as it would flood the forums.

    It would make the Computer Paddle move in normal speed and in the direction based on whether or not the Y values were higher or lower. I knew Constraining the Attribute would make the Computer Paddle move unrealistically, and would never miss the ball, so I never gave him that setup.
  • swiftskater1swiftskater1 Member Posts: 97
    beyondtheTech. Your implementation was good! its just im very new. So i need it to be explained.
  • swiftskater1swiftskater1 Member Posts: 97
    When i mean explained i mean like basic.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I would create a game attribute (integer) called ballX. In the ball constrain game.ballX to self.positionX

    In the computer paddle. Use accelerate towards and for the X put in game.ballX. For the speed set it to random(lowest speed, highest speed) then set the Max speed in the attributes pane so that it cannot go insanely fast. you can also use the drag behavior to control how it fast it comes to a stop or starts up. Setting the max speed should do the trick.
  • swiftskater1swiftskater1 Member Posts: 97
    Thanks scitunes! worked like a charm! only one more problem :/ Sometimes the ball will collide with the paddle and sometimes is goes right thru. Any ideas? And this is with the player paddle.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Are you constraining the paddle to touch? I have found that objects that are constrained have less than perfect collision detection. I had been working on a doodle jump style game and gave up for that reason. All of my rules were right but sometimes it would land on a moving platform and just stand there for a while instead of jumping.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I have a game (kidney bounce - I know. horrible name!) that has a paddle style control system and I use the accelerometer and have never had a problem with collision. I was thinking of giving people the choice of using touch, but now 'm thinking it may not work consistently enough.
  • swiftskater1swiftskater1 Member Posts: 97
    Well. I just got all the kinks out. And it's working great! No problems!
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    are you using touch to control the player paddle? Any tips for doing that that I can use on my kidney bounce science game? Did you just constrain the x position to touch?
  • quantumsheepquantumsheep Member Posts: 8,188
    I love how Tshirtbooth is asked for in the thread title. You superstar you! ;)

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • swiftskater1swiftskater1 Member Posts: 97
    Lol. He is like My gamesalad idol :P
  • swiftskater1swiftskater1 Member Posts: 97
    scitunes. I am using touch. But more like a drag. Like the faster your finger drags the faster the paddle moves.
Sign In or Register to comment.