Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411512 Posts in 69376 Topics- by 58430 Members - Latest Member: Jesse Webb

April 26, 2024, 07:04:27 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Fake jumping/bouncing in 2d topdown view
Pages: [1]
Print
Author Topic: Fake jumping/bouncing in 2d topdown view  (Read 636 times)
TheArtistJiii
Level 0
***



View Profile
« on: September 12, 2018, 11:31:58 AM »

Hello all. I've been trying to implement something like this



for the past few weeks, but I feel as if I'm heading in the wrong direction.
Anybody have some idea how I can achieve the above affect? much obliged.
Logged

"I'm Jiii" -Jiii
kurtkz
Level 0
***


View Profile
« Reply #1 on: September 12, 2018, 12:24:51 PM »

So, your ball should have an X and Y coordinate. You need to introduce a Z coordinate which reflects the height above the ground. When rendering, render the shadow at (X,Y) and the ball at (X,Y-Z).

Bonus points for introducing juice by deforming the ball when it leaves the ground and when it lands Smiley

EDIT: just realised you probably want some help with the physics too  Waaagh!

You could do this quite simply by introducing the following concepts:

velocity: (X,Y,Z)
gravity: floating point value
friction: floating point value in 0.0-1.0

At every step, you'd do:

velocity.Z += gravity
position = position + velocity

Then check for collision with the ground (Z <= 0) and respond appropriately.

NOTE: don't forget about adjusting the formulae for a fixed timestep...
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic