ID:1808513
 
Problem description:
Hey. Im trying to work on a jump system for my game and I want it to be similar to Spirit Age's system, but I dont have a clue on how to go about it.

This is the code I have so far.
Code:
mob/proc
Jump()
if(!CombatCheck())return

if(jumping)return

icon_state = "jump"
jumping = 1

vel_z = jump_height

Increase_Agi_Exp(1)

PhysicsLoop()
spawn()
while(src)
sleep(0.1)

Gravity()

Gravity()
if(dead)
icon_state = "dead"
return

if(guarding)
icon_state = "block"

if(!jumping && !falling && in_combat)
if(!idle)
if(running)
icon_state = "running"
else
icon_state = ""

else if(!attacking)
icon_state = "battle"

if(falling)
step(src, dir, 10)

if(jumping)
if(vel_z == 0)
icon_state = "jump2"

for(var/atom/a in obounds())
if(a.v_height <= src.elevation && a.v_height != 0 && a:density == 1)
vel_z = 0
jumping = 0

elevation = a.v_height

if(running)
icon_state = "running"
else
icon_state = ""

if(vel_z == (jump_height * -1) + 2)
vel_z = 0
pixel_y = 0
elevation = 0
jumping = 0

if(running)
icon_state = "running"
else
icon_state = ""

if(jumping && vel_z >= 0)
icon_state = "jump"

if(jumping && vel_z <= 0)
icon_state = "jump2"

vel_z -= 1

pixel_y += vel_z
elevation += vel_z

else
var/total = 0

for(var/atom/a in obounds())
total += a.v_height

if(total == 0)
pixel_y = 0
vel_z = 0
elevation = 0

layer = MOB_LAYER

obj
step_size = 8
var
mob/owner

Cross(atom/a)
if(istype(a, /mob))
if(src.density)
if(a:elevation >= src.v_height)
if(src.layer > a:layer)
var/old_layer = a:layer
a:layer = src.layer + 0.1

spawn(3)
if(!(a:elevation >= src.v_height))
a:layer = old_layer

return 1

else if(a:falling)
return 1

else
if(istype(src, /obj/Mountain))
return 1

return ..()

area
Platform_Fall
Enter(mob/m)
if(istype(m, /mob/))
//if(m.jumping)
if(m.dir == SOUTH)
m.falling = 1
return 1

return ..()

Exited(mob/m)
if(istype(m, /mob/))
m.icon_state = ""
m.falling = 0


Sorry about the length, Im unsure what you code guys would need to help me with so I put it all.

I want to know whether Im going about this right or if theres a better way of doing it. An explanation would be much appreciated.
One thing's for sure: I think you're better off using step_y than pixel_y for this purpose, if you're going to rely on Move() to handle the collisions for you.