simple linear jumping
NPC Code:
//jump height
this.jumpheight=16;
if (playertouchsme) {
//add weapon
toweapons jump;
say2 jump! hit S to flip;
}
if (weaponfired) {
//disable movement
disabledefmovement;
//set sprite
playersprite=30;
//make jump count
this.jumpcount=this.jumpheight-1;
//show shadow img
showimg 100,charshadow.gif,playerx+.5,playery+1.5;
changeimgvis 100,0;
//start loop
while (this.jumpcount>(this.jumpheight-(this.jumpheight*2))) {
//flip
//check key
if (keydown(5)&&this.jumpcount>0&&this.flip=0) {
//set flip
this.flip=1;
//set flip count
this.flipcount=0;
}
if (this.flip=1&&this.flipcount<4) { playerdir=(playerdir+1)%4; this.flipcount++; }
if (this.flipcount>=4) { this.flip=0; }
//end flip
//check onwall and move player
if (!onwall(playerx+1.5,playery-this.jumpcount/this.jumpheight)) {
playery-=this.jumpcount/this.jumpheight;
}
else {
if (this.jumpcount>=0) {
putleaps 2,playerx+1,playery;
this.jumpcount-=this.jumpcount*2;
}
}
//end checkwall and move
//add to counter
this.jumpcount-=1;
//sleep
sleep .1;
//re run loop
}
//hide
hideimg 100;
//reset variables
this.flip=0;
//reset sprite
playersprite=0;
//re-enable movement
enabledefmovement;
}