Alright, I had the sudden urge to go make snake...Don't ask...
Now i feel totally lost...I have a basic script down that changes directions and all that, but I need help with altering the array so that 1 of them is a turning piece...
Ex: you change dir from 3 to 0, the spot that the head is on is now a turning piece and the head is now facing 0. When I tried to alter the array to turn, it moved the whole body up...
I am not a math techie...So this is a bit hard for me :-/
Script:
NPC Code:
if (playerenters) {
toweapons Frogger;
this.active=0;
}
if (weaponfired && this.active==0) {
freezeplayer .6;
playerdir=0;
setani idle,;
this.active=1;
this.dir=3;
this.head={4,9};
this.tail={0,9,1,9,2,9,3,9};
this.dirgo={0,-1,-1,0,0,1,1,0};
timeout = .05;
}
if (timeout && this.active==1) {
freezeplayer .6;
setani idle,;
for (this.i=0;this.i<arraylen(this.tail)/2;this.i++) {
this.tail[this.i*2]+=this.dirgo[this.dir*2];
this.tail[this.i*2+1]+=this.dirgo[this.dir*2+1];
}
this.startx=screenwidth/2-200;
this.starty=screenheight/2-100;
showimg 800,snakegrid.gif,(this.startx),(this.starty);
changeimgvis 800,4;
showimg 801,snakehead.gif,(this.startx+this.head[0]*32),(this.starty+this.head[1]*32);
changeimgvis 801,4;
for (this.i=0;this.i<(arraylen(this.tail)/2);this.i++) {
showimg 802+this.i,snakebody.gif,(this.startx+(this.tail[this.i*2]*32)),(this.starty+(this.tail[this.i*2+1]*32));
changeimgvis 802+this.i,4;
}
if (keydown(0) && this.dir!=2) this.dir=0;
if (keydown(1) && this.dir!=3) this.dir=1;
if (keydown(2) && this.dir!=0) this.dir=2;
if (keydown(3) && this.dir!=1) this.dir=3;
sleep .5;
timeout = .05;
}
I'll post the images in the next 2 posts (and this one)