Quote:
Originally Posted by callimuc
This is something that could work. Not 100% sure but I can't see something wrong
PHP Code:
//#CLIENTSIDE
const JUMP_HEIGHT = 1; //Player can jump one tile high
function onKeyPressed(code, key) {
//Won't change the player.canJump as you could keep it as a check
//If the player could jump in theory for other scripts
if (key == "s" && player.canJump == true && player.z == 0) {
//Create the shadow image
showImg(20, "shadow.png", player.x+0.5, player.y+1.5);
changeImgVis(20, 1);
findImg(20).layer = 0;
//I rathered to make it into one for() loop and have if statements
//Inside of it instead of creating 2 loops, probably just a personal
//Preference
for (temp.i = 0; temp.i < JUMP_HEIGHT*2; temp.i += 0.05) {
//Since i took the JUMP_HEIGHT times 2, I can create such a check
if (temp.i < JUMP_HEIGHT) {
player.z += 0.05; //Move the player up
}
else {
player.z -= 0.05; //Move the player down
}
}
//failsafe reset the player.z
player.z = 0;
//hide the shadow as you will probably move back to the original one
hideImg(20);
}
}
|
I had just read read this this morning but I figured it out last night! thanks though!
I just simply change the z value of the player and the shadow stays at (player.x), and (player.y-player.z)
Works like a charm. I never knew about the z factor til yesterday so I would like to thank you graal forums for making life a lot easier on me lol