-
[RESOLVED] trying to figure out this "if"
im trying to figure out why this declaration will not work
it is suppose to move the enemy when its 100px near the player
and stop when its 10 px away from player
please let me know if you know why it does not work
if(xclose<=100 and xclose>=-100 and yclose<=100 and yclose>=-100
and xclose>=10 and xclose<=-10 and yclose>=10 and yclose<=-10)
-
ive figured out if anyone is intersted
if(xclose<=100 and xclose>=-100 and yclose<=100 and yclose>=-100
and xclose>=20 or
xclose<=100 and xclose>=-100 and yclose<=100 and yclose>=-100
and xclose<=-20)
-
this is the final code if you know a simpler way please let me know
if(xclose<=100 and xclose>=-100 and yclose<=100 and yclose>=-100
and xclose>=20 or
xclose<=100 and xclose>=-100 and yclose<=100 and yclose>=-100
and xclose<=-20 or
xclose<=100 and xclose>=-100 and yclose<=100 and yclose>=-100
and yclose>=20 or
xclose<=100 and xclose>=-100 and yclose<=100 and yclose>=-100
and yclose<=-20)
-
.
Hi,
Why not just use two simple if's like so.
PHP Code:
if (xclose <= 100 && xclose >= -100)
{
trace("xclose");
}
if (yclose <= 100 && yclose >= -100)
{
trace("yclose");
}
You don't need the xclose 20 or -20 as it counteracts the 100 -100
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|