ID:266712
 
I'm using Cinnom's Side Scrolling Demo and am wondering how could I make it where if you just fall of an edge lets say, you can jump back up but if your jumping and start falling you cant jump back up untill you hit the ground.This is the code I'm using right now.

client
Northwest() // Don't let them move diagnolly. Funky stuff happens when they can.
return
Northeast()
return
Southwest()
return
Southeast()
return
North()
usr.jump() // Whenever they hit North, make them jump (below).
East()
if(usr.lock == 1) // The reason for the lock var is to prevent what some call "drunk movement" in delayed movement.
return
if(usr.jack==1)
usr.lock = 1
if(usr.icon_state == "jackright") // If they're already faced right, move right.
step(usr,EAST)
usr.icon_state="jackright"
if(usr.icon_state == "jackleft") // If they're not faced right, face right.
usr.icon_state = "jackright"
sleep(1)
usr.lock = 0
return
West()
if(usr.lock == 1)
return
if(usr.jack==1)
usr.lock = 1
if(usr.icon_state == "jackleft") // If they're already faced left, move left.
step(usr,WEST)
if(usr.icon_state == "jackright") // If they're not faced left, face left.
usr.icon_state = "jackleft"
sleep(1)
usr.lock = 0
return







// The way it moves is actually somewhat interesting,
// since you could change it's movement by simply changing its icon_state.

mob
// Make sure you start off with an icon state, or you'll be invisible.
var/jumping = 0 // The jumping var is used solely for disabling gravity while jumping.
var/lock = 0 // lock, used for keeping away "drunk movement" in delayed movement.
var/life = 10
var/delay = 5
var/delay_time
Stat()
stat("Life", src.life) // Show you your current life.
Login()
src.loc = locate(2, 2, 1)
spawn(gravity) src.GravCheck() // Start the gravity.
..()
Logout()
del(src)
..()
Move(A, B)
if(B == WEST)
if (usr.jack==1)
src.icon_state = "jackleft" // Since we're not using movement states,
if(B == EAST)
if (usr.jack==1) // we need to remember to re-set the icon states upon movement.
src.icon_state = "right"
..()
Bump(M)
if((get_dir(src, M) == NORTH)) // This is so you'll fall if you bumped your head.
// If hitting your head is meant to do something, put that here.
src.jumping = 0

proc
jump() // jump, used for projecting yourself into the air, for your own reasons.
if(src.jumping == 1) // You can't jump if you're already jumping.
return
var/turf/aturf = locate(src.x, src.y-1, src.z) // Get the turf directly below you.
var/dense = 0
if(aturf)
for(var/atom/A in aturf)
if(A.density == 1)
dense = 1
break
if(aturf.density == 1)
dense = 1
// Those few lines above are used to make sure you're on something dense. You can't jump if you're falling.
if(!aturf)
dense = 1
if(dense == 1) // If they're on something...
src.jumping = 1
for(var/I = 0, I < (gravity * 1.5), I++) // This is a traditional for loop that loops until I(init 0) is equal to gravity times 1.5.
spawn()
if(src.loc != null)
step(src, NORTH)
sleep(gravity)
if(src.jumping == 0)
break
src.jumping = 0
spawn(gravity) src.GravCheck() // Spawn GravCheck again, since it probably discontinued it's loop while you were airborne.

GravCheck() // Your artificial gravity.
if(src.jumping == 0) // If they're in the process of going up, don't do the gravity thing.
if(fall_type == 1)
var/dense = 0
var/turf/spot = locate(src.x, src.y-1, src.z)
if(spot)
for(var/atom/A in spot)
if(A.density == 1)
dense = 1
if(dense == 0 && spot.density == 0)
src.Move(locate(src.x, src.y-1, src.z))
// The above few lines (again) are for checking if you're on something dense. If you are, there's no need to attempt going down.
// This is merely for the CPU, it'll work without them, since a mere Bump would occur if you went South into a dense object.
else
src.Move(locate(src.x, src.y-1, src.z))
spawn(gravity) src.GravCheck()


If you know how to do this please help thanks.

-Beld
Well most people dont read that much code and they dont want to answer. Try to narrow down where you would add it and how exactly you would do it. I dont know the answer though because i dont know how to do platform games. :P
In response to Mrhat99au
Thats just it I'm not sure were it would go thats why I posted the whole thing.