Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Snake? Array questions and more... (https://forums.graalonline.com/forums/showthread.php?t=30779)

Gohan43331 06-03-2002 09:42 PM

Snake? Array questions and more...
 
1 Attachment(s)
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)

Gohan43331 06-03-2002 09:44 PM

1 Attachment(s)
The grid (*curses 30 sec timer*)

Gohan43331 06-03-2002 09:46 PM

1 Attachment(s)
And finally, the head (and don't worry about the images...i'll have multi-dir ones soon...These are just temporary)

screen_name 06-03-2002 10:46 PM

=D

lol, i've already got one made, just have to fix it up a bit so i can have fruit and stuff


it was hard to make the bord corners, but i finally got it

screen_name 06-03-2002 10:55 PM

sorry kai for the double post


and from your script, i doubt you'll figure it out =D
lol

BBflat 06-04-2002 11:13 AM

Quote:

Originally posted by screen_name
sorry kai for the double post
Why apologize? Why double post in the first place? This is what the edit button is for.

Spanko 06-04-2002 06:38 PM

You don't really need math to make it, just make one array which stores the position of the current body parts, make it the size of the maximum number of body parts, and then make a variable which keeps track of which part of the array needs to change.

screen_name 06-04-2002 09:11 PM

Quote:

Originally posted by Spanko
You don't really need math to make it, just make one array which stores the position of the current body parts, make it the size of the maximum number of body parts, and then make a variable which keeps track of which part of the array needs to change.


lol, it seems it would be that easy write??

well if you use corners then you have a problem...

=D


All times are GMT +2. The time now is 08:02 AM.

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