This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2008-03-12 12:05:59

Suicune
Scratcher
Registered: 2008-03-11
Posts: 6

Using the randomizer?

Let's say I had a fighting game where 1 guy is controlled by you and the other guy is controlled by the computer.  If the computer-controlled character had more than 2 different attacks, how would I be able to make the attack a random choice out of those attacks?

Offline

 

#2 2008-03-12 12:12:33

EdnaC
Scratcher
Registered: 2007-08-28
Posts: 100+

Re: Using the randomizer?

If (Random from 1 to 10) > 5
Set AttackMode = 1
Else
Set AttackMode = 2

"AttackMode" could be a variable that you set, as shown, or it could be a broadcast.  You could make one attack type more likely by changing the number that you compare the random number to. 

If (Random from 1 to 10) > 8 would not be "true" very often, and attackmode1 would be favored.

Does that help?

-MrEd

Offline

 

#3 2008-03-12 12:18:54

Suicune
Scratcher
Registered: 2008-03-11
Posts: 6

Re: Using the randomizer?

Yeah, I'll see if that works.  Right now I've gotta get off of the computer.

Offline

 

Board footer