The Daily Click ::. Forums ::. Klik Coding Help ::. Giving a ball gravity?
 

Post Reply  Post Oekaki 
 

Posted By Message

Gandhi



Registered
  27/07/2003
Points
  117
3rd April, 2004 at 05:42:06 -

Hey, i am wondering on how to give a ball gravity in TGF? ANy help?

 
~GANDHI~

Dr. James MD

Addict

Registered
  08/12/2003
Points
  11941

First GOTW AwardSecond GOTW AwardThird GOTW AwardPicture Me This -Round 26- Winner!
3rd April, 2004 at 07:59:21 -

i posted this on KA;

my way is to use the Direction Calculator object and always have the ball rotate to direction 24. and when ball collides with background, set speed to current speed / 2.

and when ball faces in up directions subtract 1 from speed, when ball is going down add 1 to speed

but there are a million on one ways, this is the most simplistic i can think of

 
Image
http://uk.youtube.com/watch?v=j--8iXVv2_U
On the sixth day God created Manchester
"You gotta get that sand out your vaj!" x13
www.bossbaddie.com

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
3rd April, 2004 at 10:50:04 -

That sounds harder than Dustin's way to me, to be honest!

 
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G

Dr. James MD

Addict

Registered
  08/12/2003
Points
  11941

First GOTW AwardSecond GOTW AwardThird GOTW AwardPicture Me This -Round 26- Winner!
3rd April, 2004 at 13:07:52 -

meh, tis just my way

 
Image
http://uk.youtube.com/watch?v=j--8iXVv2_U
On the sixth day God created Manchester
"You gotta get that sand out your vaj!" x13
www.bossbaddie.com

Dr. James MD

Addict

Registered
  08/12/2003
Points
  11941

First GOTW AwardSecond GOTW AwardThird GOTW AwardPicture Me This -Round 26- Winner!
3rd April, 2004 at 18:34:34 -

get the right formula and its brilliant for gravity. ie dont use Always, just use every X seconds, and some more advanced stuff like using values to control speed for reliability.

its worked 100% fine for me in the past

 
Image
http://uk.youtube.com/watch?v=j--8iXVv2_U
On the sixth day God created Manchester
"You gotta get that sand out your vaj!" x13
www.bossbaddie.com

Gandhi



Registered
  27/07/2003
Points
  117
3rd April, 2004 at 18:52:01 -

i tried your way Dustin G., yet it is not working the way i want. You see when the ball goes up, i want it to go down as well, just like if i threw a ball in the air.

 
~GANDHI~

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
3rd April, 2004 at 19:14:11 -

set the balls its own y value + value of an alterable value or counter
(the ball will move up and down depending on the number of the counter/value)

if the ball is not on a background + 1 to counter/value (move down)
if it is on a background - 1 to counter (move up)

when pressing space (or what ever key you choose) set counter/value - 5
(will throw it up)

thats as basic as I can think of

 
.

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
3rd April, 2004 at 19:25:27 -

I didnt think it was different for every computer.

slower computers will count the in game timer just as quick but may move the character or scroll slower so timer based jumps using every x seconds may not jump high enough.

and not jump the same height each time

if it was set to every 0.10th of a second then the jump could start at the end of the 0.10 or at the start of the 0.10 resulting in a different height.

 
.

Ashman

Possibly Insane

Registered
  12/06/2002
Points
  3974
3rd April, 2004 at 23:09:17 -

OK here's a reasonably easy way I used to use way back. Set the ball to a platform movement and set Speed, Acc, Dec to 0 and set it to No Jump. Then set the gravity you want. Then in the event editor...

Use the balls alterable value A as the trigger for jumping/falling, and Alt B as the strength of jump.

Event 1
Ball Alt Value A = 1
+Ball Alt Value B > 0

THEN

Ball - Movement - Stop
Ball - Position - Y Coordinate - Y( "Ball" ) - Value B( "Ball" )
Ball - Values - Subtract 1 from B

Event 2
Ball Collides with Backdrop

THEN

Ball - Movement - Stop
Ball - Values - Set A to 0


The platform movement will sort out the gravity for itself. It's a very simple way, to make it jump/bounce simply set Alt A to 1, and set Alt B to a variable depending on how high you want it to go.

 
Show me the power child,
I'd like to say,
That I'm down on my knees today,
Gives me the butterflies,
Gives me away,
'Til I'm up on my feet again,
I'm feeling outshined.


"Outshined" - SoundGarden

Teapot

Does he even go here

Registered
  02/10/2003
Points
  2631

VIP Member
3rd April, 2004 at 23:12:37 -

One look? ONE LOOK?

 
n/a

Philipe (Phil-Con Games)



Registered
  27/03/2004
Points
  520
4th April, 2004 at 04:00:37 -

Wow, you people have turned this into some sortof a debate. Poor Ghandi, caught in between fire, attempting to decifer the right path...

 
Games currently in "the works":

Moonrise
My Fantasy (dieing dream)
Shadowed Sunset (this one will be cool)
Dragon Riders (Newer, better animated, cooler, and less gradient version!)
....................
www.phil-con.com baby!

Muggus

Possibly Insane

Registered
  31/07/2002
Points
  2958
4th April, 2004 at 06:44:54 -

Depends on which way this ball is suppose to react.

If it is simply shot by another object, which means it won't be able to bounce or anything, these are the only events you'll need.

- Always
Set Y of Ball to Y("Ball") + Alterable Value A("Ball")

- Every 0"00'05
(this delay can be changed to make ball fall at faster or slow rate)
+ Alterable Value A of Ball < 20
(this value determines terminal velocity of ball)
Add 1 to Alterable Value A of Ball


That's simple enough for a non-reactive projectile. As for something that bounces you may want to add some other events for collisions. I recommend something along the lines of...

- Ball collides with obstacle
Set Alterable Value A to -1
Bounce Ball
Set Speed of Ball to Speed("Ball") / 2

You may want to change the value the ball is decreased by, but this event essentially makes the ball bounce, lose half its speed, and changes the Alterable Value A (which is the vertical velocity causing it to fall) to a negative value thus making it go upwards for just a bit.

Of course these values may need a bit of tweaking depending on your desired effect, and you may find that sometimes there are a few odd bounces that occur. But I recommend you give that a try.

 
MUGGUS
Come and annoy me more at
www.muggus69.tk
STOUT ANGER!!!
   

Post Reply



 



Advertisement

Worth A Click