My Ball Stops Bouncing!!!

froamerfroamer Member Posts: 29
edited November -1 in Working with GS (Mac)
.....pause for usual jokes............

..........

OK, my game is at the "proof of concept" stage, but I am pleased with my idea - now if only I could implement it ;-)

I have a ball that constantly bounces vertically. The idea is you guide it through a maze, timing the bounces to survive.

The problem is if my ball hits the walls on the corners it slows down or even stops bouncing altogether.

As you scroll the background, the camera is moved through the scene. To keep the ball in the picture I constrain its X position...

self.Position.X = scene.Camera.Origin.X +100

I think it's this that is making the ball go inside the walls which stops it bouncing; I think.

There are a couple of solutions I can think of..

1) Only adjust the X position if the ball is not colliding - is there a way to do this?

2) Force the ball to keep its speed in some way, so if it slows down it is only while it rectifies itself. Can I do this?

Well as you can tell I am quite new to GS so any help would not only be gratefully received but would bestow masses of positive karma (possibly).

I have uploaded an example - forgive the rubbish graphics as it is a proof of concept:
http://gamesalad.com/game/play/58526

Comments

  • RHRH Member Posts: 1,079
    Are you using collide to make the ball bounce with a restitution of 1? If so maybe removing the collide and creating a rule so that when the ball overlaps with the walls change 'self.motion.linear velocity' to - 'self.motion.linear velocity'.

    I doubt that will change it but it's worth a shot. I'm useless at figuring something out if I can't see the physics.
  • froamerfroamer Member Posts: 29
    Thanks for responding RH. Yes, I am using collide, the ball is set to collide with all actors with the "bouncy" tag. How would I test for the ball overlapping walls? Would I need to test for every wall in the scene? There's loads of them and some will be at angles. Sorry if I am misunderstanding.
  • froamerfroamer Member Posts: 29
    Is what I am trying to do too ambitious for Game Salad? Should I throw my work away and think of a different game idea?

    Any help appreciated very much!
  • UtopianGamesUtopianGames Member Posts: 5,692
    I had a similar problem with the pong/tennis template....if you leave the bats alone the ball will slow down and eventually stop.

    Think you need a way to keep the ball moving at a constant speed....although not sure how.

    Darren.
  • froamerfroamer Member Posts: 29
    Thanks Darren,

    Anyone have any thoughts on how I can keep this darn ball moving?
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    there was a post about this in the past. I think someone made a demo. Try searching the forums (magnifying glass in the top right corner of this site) and try searching the shared projects.
  • ValanValan Member, BASIC Posts: 410
    Nice idea for a game.

    I think you can use the Accelerate behaviour and add Motion/Max Speed and click Apply Max Speed.

    Accelerate will/can cause it to fly off but then the speed is limited by the max speed being applied.
  • froamerfroamer Member Posts: 29
    Many thanks for your comments.

    @scitunes - I searched before posting and after your comment, you wouldn't happen to know the topic you saw or the keywords?

    @Valan -I've tried to interpret your suggestion but I am very new to this. This is what my ball instance looks like now...

    Collide
    Bounce when colliding with: Actor with tag: bouncy

    Constrain Attribute: self.Position.X To: scene.Camera.Origin.X +100

    Rule
    When self.Motion.Max Speed < 200
    Accelerate Direction: 270 Acceleration: 100 Relative to: Actor

    (the last rule is me trying to implement your suggestion). Was this when you meant? It makes no difference, also it seems acceleration has direction when my ball can get stuck on the bottom as well as the top walls.
  • ValanValan Member, BASIC Posts: 410
    You may not need the rule.
    Just have the ball accelerating down all the time.

    Apply a Collision to all the Bouncy actors to collide to the ball.

    Double Click onto the Ball actor.
    Look in the Attributes window on the left.
    Go down and access the Motion Attributes.

    In Max Speed enter 200
    Click on Apply Max Speed.
  • ValanValan Member, BASIC Posts: 410
    Also, just seen it, make the Acceleration Relative to the Scene. Not Actor.
  • froamerfroamer Member Posts: 29
    Many, many thanks for trying to help. I really appreciate it.

    However, I've tried all these suggestions and scanned the forums and I can still get the ball stuck in the wall so it slows down or stops bouncing.

    I was originally impressed with GameSalad, but every game I have tried to build there seems to be some problem that makes it impossible. In this game I can't even get a ball to bounce around a scene without slowing down on the corners of walls!

    I am beginning to wish I hadn't wasted my money on GameSalad. I am a software developer by trade and if I can't get these basic things working, what chance is there of completing a game (even after I find one GameSalad can handle).
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Constraining will override all collisions.
    You can try putting it into the otherwise section of the Rule, like this:

    Rule
    When all conditions are valid:
    Overlaps of collides with Actor of type Wall
    -----
    otherwise
    -----Constrain self.Position.X = scene.Camera.Origin.X +100

    As for the slow down when the ball collides with a wall, you can check out the magnitude demo on my profile. It shows how to keeps a couple of balls bouncing around the screen at a constant velocity. There's some math involved, but without it, the balls would slow down.

    Feel free to dig into that project. Something in there might help you.
  • ValanValan Member, BASIC Posts: 410
    I've only completed one game but I've had lots of problems. These have been resolved in three ways. Get the answer from the forums, leave it till later or hide it.

    Leaving it till later often works well since it buys more time to find or get a working method.

    Hiding it often leads to other creative gameplay that I wouldn't have normally thought of.
  • froamerfroamer Member Posts: 29
    @firemaplegames - many thanks for telling me that key phrase "Constraining will override all collisions."

    This explains the problems I am having in a nutshell! How did you learn this? Am I missing some docs?

    As you suggested I have put the constrain in an otherwise condition so the ball is EITHER colliding OR having its X position constrained - that has really helped.

    I still get the slow down, as you predicted, so I will look through your project example for tips to solve that.

    Many thanks to you and @Valan for taking the time to help and provide hints.
  • froamerfroamer Member Posts: 29
    I've just made the ball's Collision Shape attribute "Rectangle" rather than "Circle" - this combined with your tip @firemaplegames and I think I am back on course. Rather than getting stuck or slowing down on a corner bounce it now judders - a bit ugly but it corrects itself at least.

    Again, many thanks for all your help and suggestions. Perhaps I'll get this game done after all!
Sign In or Register to comment.