The Daily Click ::. Forums ::. Klik Coding Help ::. Platform
 

Post Reply  Post Oekaki 
 

Posted By Message

labyrinthjungle



Registered
  03/03/2007
Points
  13
29th August, 2007 at 16:47:12 -

If you're using a custom platform engine, how do you get an object to "bounce"

 
n/a

Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
29th August, 2007 at 17:11:39 -

Uh, that's a really, really vague question.

Here's an attempt at an answer. Set your gravity to a positive value after the object hits the ground.

 
Craps, I'm an old man!

The Chris Street

Administrator
Unspeakably Lazy Admin

Registered
  14/05/2002
Points
  48488

Game of the Week WinnerClickzine StaffAcoders MemberKlikCast StarVIP MemberPicture Me This Round 35 Winner!Second GOTW AwardYou've Been Circy'd!Picture Me This Round 38 Winner!GOTM December Third Place!!
I am an April FoolKliktober Special Award Tag
30th August, 2007 at 06:25:36 -

ALWAYS:
Set Y Position of OBJECT to (Y Position + (Alterable Value A "OBJECT"/3))

Alterable Value A OBJECT is LOWER than 25
+ (NEGATE) Object is overlapping backdrop:

Add 1 To Value A


OBJECT is overlapping backdrop: Set Value A to -20, Set position Y to Y-1


That's the basics of it.



 
n/a

labyrinthjungle



Registered
  03/03/2007
Points
  13
30th August, 2007 at 08:17:47 -

Thanks! I'm still a little confused, but hopefully I'll be able to figure it out.

 
n/a

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
30th August, 2007 at 08:31:19 -

Yeah, it looks a bit difficult. Just remember that Alterable Value A is the gravity here - you add 1 to it every frame ("always"), then position the object according to the value. So what you get is:

frame 1: Set Y to Y + 1
frame 2: Set Y to Y + 2
frame 3: Set Y to Y + 3
etcetera.

Then, when it finds that it's overlapping a background object (or something else, an active if you want, using object groups for this is REALLY useful), it sets the gravity variable to a NEGATIVE value, meaning that the Y will be set to the Y plus the NEGATIVE value. For example:

Collission: Set Gravity variable to some negative value (-10 in this example)
Frame 1 after collission: Set Y to Y + -10

Y + -10 is equal to Y - 10, which has the effect of the object being positioned more to the top rather than more to the bottom. In the meantime the variable will still always get 1 added to it though, so after a while the value will be positive again. Then it'll be adding an increasing value to the variable again.

The effect: at first the object speeds up while bouncing down, then it overlaps something and bounces back up, until it bounces down after a while again.

You can adjust things a bit by setting the value of bouncing back up (like -20 rather than -10, or whatever you like as long as it's negative), and by dividing the result value of the variable when positioning the object (like: Set Y to (gravity variable / 3)).

If you got the hang of making the ball bounce like this, you can use fastloops to give this stuff extreme precision, too. But don't try this until you really got the hang of it and know how the bouncing works.

 
Old member (~2004-2007).
   

Post Reply



 



Advertisement

Worth A Click