create an actor with moving left or right randomly?

Game Editor comments and discussion.

create an actor with moving left or right randomly?

Postby Game_amateur » Mon Jan 14, 2008 3:49 pm

I am a beginner, i am trying to create an actor, that moves left or right randomly, how can i make it? (a mouse created and move to left or right randomly)
I tried the script editor be4 like below:
x=rand(2);
if (x==1) moveto(-125,0);
else moveto(125,0);

Who can help me the syntax or another way to do that because i havent been succesful yet? THanks alot
Game_amateur
 
Posts: 3
Joined: Mon Jan 14, 2008 3:30 pm
Score: 0 Give a positive score

Re: create an actor with moving left or right randomly?

Postby asmodeus » Mon Jan 14, 2008 4:04 pm

Use this code:
Code: Select all
int randomly = rand(2);
if(randomly==0) xvelocity = -5; // write instead of "5" the speed, that you want.
else xvelocity = 5;
User avatar
asmodeus
 
Posts: 483
Joined: Thu Oct 11, 2007 5:04 pm
Location: Germany
Score: 43 Give a positive score

Re: create an actor with moving left or right randomly?

Postby Fuzzy » Mon Jan 14, 2008 6:54 pm

xvelocity = 5*(rand(3)-1);
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: create an actor with moving left or right randomly?

Postby Game_amateur » Tue Jan 15, 2008 7:56 am

Thanks so much for your helps
Game_amateur
 
Posts: 3
Joined: Mon Jan 14, 2008 3:30 pm
Score: 0 Give a positive score

Re: create an actor with moving left or right randomly?

Postby Game_amateur » Tue Jan 15, 2008 8:03 am

Just one more question:
How can i make a delay function in the script editor.
Like
......
wait(1000);
DestroyActor();
...
Game_amateur
 
Posts: 3
Joined: Mon Jan 14, 2008 3:30 pm
Score: 0 Give a positive score

Re: create an actor with moving left or right randomly?

Postby makslane » Tue Jan 15, 2008 12:20 pm

You need to create a timer and the code will execute when in the timer event.
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Re: create an actor with moving left or right randomly?

Postby tufif » Wed Jan 16, 2008 7:49 pm

And you can make the timer random too
tufif
 
Posts: 22
Joined: Sat Oct 13, 2007 3:00 am
Score: 2 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron