Hello all,
I just purchased Game Editor a few days ago, so this is my first post!
My question is this: I have an "enemy" that I need to move randomly. While I think I understand the general syntax required, the enemy does the same thing (i.e., goes the same direction) every time.
I have pasted the code I used below. Basically, what I did was create random variables that are ultimately assigned to xvelocity and yvelocity. Then, I created a second set of random variables. Depending on whether the value returned is 1 or 0, xvelocity and yvelocity will be either positive or negative. Here is the code I used:
int xvel = rand(3);
int yvel = rand(3);
int xposorneg = rand(1);
int yposorneg = rand(1);
if(xposorneg==0)
{
xvelocity = 0-xvel;
}
else
{
xvelocity = xvel;
}
if(yposorneg==0)
{
yvelocity = 0-yvel;
}
else
{
yvelocity = yvel;
}
Every time I run it, the enemy moves to the same place (the upper left-hand corner of the screen). In other words, the movement is not random. I read somewhere in the documentation that "random" is really "pseudo random." Is that what's going on here? Is there no way to get "true" random movement?
I appreciate the help in advance, and I am very excited about working with this wonderful tool!!
Thank you,
Plinydogg