Keeping a shadow under you're player without moving? in Developer Help
|
|
Alright so I have just finished adding jumping onto my project and I remember making a shadow that stays in one spot under you're player and doesn't move last year. I just recently got back to programming so im trying to get the hang of everything again. This is what I have so far:
Jump() var/D=20 var/D2=1 var/D3=1 var/D4=6 if(src.Jumping==0) src.Jumping=1 src.icon_state="Jump" if(src.CS>=2) D=20 D2=4 D3=3 D4=20 src.Height=D3 spawn(D4) src.Height=0 src.pixel_y+=D sleep(D2) src.pixel_y+=D sleep(D2) src.underlays+=new/obj/Shadow src.pixel_y+=D spawn(D2) src.pixel_y+=D sleep(D2) src.pixel_y+=D sleep(D2) src.pixel_y-=D sleep(D2) src.pixel_y-=D sleep(D2) src.pixel_y-=D sleep(D2) src.pixel_y-=D sleep(D2) src.pixel_y-=D src.underlays-=/obj/Shadow src.pixel_y=0 src.Jumping=0 src.icon_state="" else usr<<"You are already jumping" return
|
The problem is that the shadow moves down as the player is landing. Is there a way that I can make it so the shadow stays locked under the player so the player has a nice idea where he's going to land?
|
below:
Jump()var/D=20//How high you will appear to jump
var/D2=1//How long you will appear to jump
var/mob/S = new/obj/shadow
var/D3=1//How high you will become in the air
var/D4=6//How long you will be airborne
//var/D3=10//H
if(src.Jumping==0)
src.Jumping=1
src.icon_state="Jump"
if(src.CS>=2)
D=20
D2=4
D3=3
D4=20
src.Height=D3
spawn(D4)
src.Height=0
src.pixel_y+=D
sleep(D2)
src.pixel_y+=D
sleep(D2)
S.loc = locate(src.x,src.y,src.z)
src.pixel_y+=D
spawn(D2)
S.loc = locate(src.x,src.y,src.z)
src.pixel_y+=D
sleep(D2)
S.loc = locate(src.x,src.y,src.z)
src.pixel_y+=D
sleep(D2)
S.loc = locate(src.x,src.y,src.z)
src.pixel_y-=D
sleep(D2)
S.loc = locate(src.x,src.y,src.z)
src.pixel_y-=D
sleep(D2)
S.loc = locate(src.x,src.y,src.z)
src.pixel_y-=D
sleep(D2)
S.loc = locate(src.x,src.y,src.z)
src.pixel_y-=D
sleep(D2)
S.loc = locate(src.x,src.y,src.z)
src.pixel_y-=D
src.pixel_y=0
del(S)
src.Jumping=0
src.icon_state=""
else
usr<<"You are already jumping"
return
You might be able to reduce the number of checks with the same result you will just have to test it and see what happens ;)