ID:149574
 
Is there a way to know witch way the players character is facing? I am making a jump verb and I want the character to jump the way it is facing soooo. Here is the code I have now.

jump()
src.locked2 = 1
src.density = !density
src.icon_state = "jump"
sleep(2)
src.y += 1
sleep(3)
src.x += 1
sleep(2)
src.x += 1
sleep(2)
src.y -= 1
src.icon_state = "moving"
src.locked2 = 0
src.density = !density

It works but the guy can only jump to the right. I think I need several if cammands to fix this. The only problem is I need some thing for the if command to call to see witch way he is facing. If you know how I can do this please reply. Thanks.
TK6000 wrote:
Is there a way to know witch way the players character is facing? I am making a jump verb and I want the character to jump the way it is facing soooo. Here is the code I have now.

jump()
src.locked2 = 1
src.density = !density
src.icon_state = "jump"
sleep(2)
src.y += 1
sleep(3)
src.x += 1
sleep(2)
src.x += 1
sleep(2)
src.y -= 1
src.icon_state = "moving"
src.locked2 = 0
src.density = !density

It works but the guy can only jump to the right. I think I need several if cammands to fix this. The only problem is I need some thing for the if command to call to see witch way he is facing. If you know how I can do this please reply. Thanks.

What you have to do is put an if() statement in there. Like:
if(src.dir == EAST)
//what to do to jump right
if(src.dir == WEST)
//what to do to jump left


That is probably the best way to do it.

-Rcet
In response to Rcet
Rcet wrote:
if(src.dir == EAST)
//what to do to jump right
if(src.dir == WEST)
//what to do to jump left


That's a good way to do it, but a slightly better way involves the switch proc:
    switch (src.dir)
if (EAST)
// jump right
if (WEST)
// jump left
...
In response to Air Mapster
thanks! So dir is what you call for your direction.