Make an object bounce?

Get help using Construct 2

Post » Mon Oct 10, 2011 9:29 pm

Looks good to me ;)
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Tue Sep 25, 2012 3:12 am

"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!

-RE
B
50
S
15
G
11
Posts: 366
Reputation: 12,043

Post » Tue Sep 25, 2012 4:01 am

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. GenkiGenga2012-09-25 04:06:49
ImageImage
B
73
S
16
G
6
Posts: 1,039
Reputation: 10,480

Post » Tue Sep 25, 2012 5:08 am

1) 100 is the speed to move and the angle is the direction.
The formula is a conversion to horizontal and vertical motion.
http://www.teacherschoice.com.au/maths_library/coordinates/polar_-_rectangular_conversion.htm

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:
[code]speed * time = distance[/code]
More info about dt:http://www.scirra.com/tutorials/67/delta-time-and-framerate-independence

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.
B
79
S
24
G
54
Posts: 4,743
Reputation: 40,749

Post » Tue Sep 25, 2012 8:16 am

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!
B
50
S
15
G
11
Posts: 366
Reputation: 12,043

Post » Tue Sep 25, 2012 11:43 am

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'.

ImageImage
B
73
S
16
G
6
Posts: 1,039
Reputation: 10,480

Post » Thu Oct 17, 2013 9:27 pm

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
     objects)

enjoy it.
2D Game GUI Designer
B
12
S
4
G
3
Posts: 130
Reputation: 3,773

Previous

Return to How do I....?

Who is online

Users browsing this forum: heliogame, WhosWho, Yahoo [Bot] and 18 guests