Make an object bounce?

0 favourites
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • OK, now I see the problem. In the example above I made a wall taller than the layout size so I couldn't recreate the problem. lol This time I just made a small box in the middle. In my first example I set everything so that the ball would bounce as if it were inside a box like in a breakout game.

    Now the problem is figuring out how to accurately make the ball bounce of a box in the center from all angles. I will play around with it and see if I can figure it out. This will require a different technique in other words "I will have to think outside the box." LOL

    Anyway here is the capx. of the problem:

    Bounce Problem

    If anyone has any ideas your help would be appreciated. This one has me stumped.

  • Has me stumped too :)

  • It can be solved by first moving horizontally then vertically, and reversing the horizontal or vertical motion when it overlaps a wall.

  • Thank you very much R0J0hound for your great solution. I was going about it all wrong. It would have taken me forever to get it rite. Thanks again   <img src="smileys/smiley4.gif" border="0" align="middle" />

  • Looks good to me ;)

  • "So now I'm relearning trig so I can figure out this forum answer which three other advanced designers all agree was incredibly useful."

    So saith I to my friend on gchat. I downloaded R0J0hound's capx and I understand the principle of capturing the inverse of the object's effective horizontal and vertical angles on impact, but just in case you guys can explain the math and variables faster than I can figure it out myself:

    1) Why set the instance variables "vx" and "vy" to 100 times the cos(self.Angle)?

    2) Is "dt" an established variable I should know about, and what is it?

    3) How did you create the "move horizontally" and "move vertically" events? I don't see a condition for

         Ball -> Set X to -> self.X + self.vx * dt

    Thanks anyone who can help!


  • Urrgh, lost my post. :/

    Summed up : Rojo is awesome.

    1.) the number is the speed at which the balls move (X and Y movement), if you play around with the numbers you can slow them down or speed them up.

    2.) dt is a reliable way to time something so it will act the same across platforms. (If you add dt to a global variable every tick for instance - it will count up like a stop watch). Not sure what the exact dt to time ratio is though.

    3.) Its done in event 1. The X and Y speed are set to variables, and in the events below the balls are told to stick to the X and Y movements of the variables.

  • 1) 100 is the speed to move and the angle is the direction.

    The formula is a conversion to horizontal and vertical motion.

    2) dt is the amount of time that the current frame is taking. In the example dt is used for time in this simple formula:

    speed * time = distance

    More info about dt:

    3) I'm not quite sure what you're asking, "set x" and "set y" are actions not conditions. The rest of it is just a formula.

  • GenkiGenga and R0J0hound, thanks a ton for the clarification!

    To explain my confusion on item 3, Event 1 has a condition, "System: On Start of Layout" before the associated action, whereas it appears that Event 2 is just the action with no corresponding condition, and is linked to action 3 which *does* have a condition, i.e., "Ball: Is Overlapping Wall."

    If I'm about to figure all that out as I finish reading the Event section of the manual, then I apologize, and I'll work it out. =)

    Thanks for your time!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ahh. Yeah I remember that throwing me in the early days as well! If there is no condition in the event then it reads as 'Every tick'.

  • hello,

    this is the easy to use step to make bouncing ball.

    1. Make objects (sprites) that your ball will bounce when she collide with

    2. Add Bullet behavior to your ball.

    3. In objects properties, change values to:

       - Speed to 400 or any

       - Acceleration & Gravity to 0.

       - Bounce of solids to YES (this make ball bouncing when hit solids


    enjoy it.

    <img src="smileys/smiley17.gif" border="0" align="middle" />

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)