PDA

View Full Version : Ok now why wont this work?


Bhala
08-12-2001, 08:14 AM
Why wont this work?

if (playerenters) {
drawunderplayer;
dontblock;
timereverywhere;
timeout = .5;
}
if (timeout){
this.dir = random( 1, 5 );
if (this.dir=1 && !onwall(x+1,y)){y-=1;}
if (this.dir=2 && !onwall(x+.5,y+2)){y+=1;}
if (this.dir=3 && !onwall(x,y)){y-=1;}
if (this.dir=4 && !onwall(x,y)){y-=1;}
timeout = .5;
}

Xaviar
08-12-2001, 08:20 AM
Originally posted by Bhala


this.dir = random( 1, 5 );



should be

this.dir = int(random(1,5));

LiquidIce00
08-12-2001, 08:23 AM
ur onwall is messy tho

Bhala
08-12-2001, 08:28 AM
yea I know about the onwall stuff but I know why that wasnt making it work


thx

Falcor
08-12-2001, 03:24 PM
dir = (dir+int(random(1,4)))%4;

Thats nice a neat =D

Jerom
08-13-2001, 08:35 AM
Originally posted by Bhala
Why wont this work?

if (playerenters) {
drawunderplayer;
dontblock;
timereverywhere;
timeout = .5;
}
if (timeout){
this.dir = random( 1, 5 );
if (this.dir=1 && !onwall(x+1,y)){y-=1;}
if (this.dir=2 && !onwall(x+.5,y+2)){y+=1;}
if (this.dir=3 && !onwall(x,y)){y-=1;}
if (this.dir=4 && !onwall(x,y)){y-=1;}
timeout = .5;
}

When you do random things, doesn't it also do decimals and not just whole numbers?

kyle0654
08-13-2001, 09:32 AM
Originally posted by Jerom

When you do random things, doesn't it also do decimals and not just whole numbers?
yep.

Also, the parts where you check stuff like this.dir=3 should be this.dir==3. Quick guide to where to use == as opposed to =:

if = is found inside:
if ()
while ()
or the second part of for ()
then use ==

otherwise, use =

ownerofbabylon
08-13-2001, 07:04 PM
Originally posted by Kaimetsu


And inefficient...

LOL great to have you back Kai

Jerom
08-14-2001, 03:32 AM
Originally posted by kyle0654

yep.

Also, the parts where you check stuff like this.dir=3 should be this.dir==3. Quick guide to where to use == as opposed to =:

if = is found inside:
if ()
while ()
or the second part of for ()
then use ==

otherwise, use =
But I remember trying to make a baddie, and it would change directions according to what ranges of a number a certain variable was in. I had used the same method before, but it didn't work in my baddie for some reason. I guess I'll have to look over it again.