Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-03-2002, 09:42 PM
Gohan43331 Gohan43331 is offline
Registered User
Join Date: Jan 2002
Posts: 87
Gohan43331 is on a distinguished road
Send a message via AIM to Gohan43331
Snake? Array questions and more...

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)
Attached Images
 
__________________
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 03:06 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.