Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Whack-A-Mole
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mmcdough




PostPosted: Wed Jun 06, 2007 9:39 pm   Post subject: Whack-A-Mole

I am making a Whack-A-Mole game...lol. I made 9 procedures for the heads that pop out of the holes. But now I am stuck because I don't know how to make them randomly pop up.

Thanks.
Sponsor
Sponsor
Sponsor
sponsor
isaiahk9




PostPosted: Wed May 07, 2008 5:41 pm   Post subject: RE:Whack-A-Mole

Why would you make a procedure for each head? I
don't quite get it.
Anyway, why don't you just make a random variable that will call upon a head:
loop
Var whathead r := Rand.Int (1,9)
If whathead = 1 then
headone
elsif whathead = 2 then
headtwo
elsif whathead = 3 then
headthree
elsif whathead = 4 then
headfour
elsif whathead = 5 then
headfive
elsif whathead = 6 then
headsix
elsif whathead = 7 then
headseven
elsif whathead = 8 then
headeight
else
headnight
end if
end loop
S_Grimm




PostPosted: Fri May 09, 2008 11:27 am   Post subject: RE:Whack-A-Mole

I agree with isaiak9. the randint would be the easist way. though you could probably get away with one procedure for each head. use different variables for the x,y coordinates of each head and call the co-ordinates for each..

loop
Var whathead r := Rand.Int (1,9)
If whathead = 1 then
x := 1
y := 1
headone
elsif whathead = 2 then
x:= 2
y:=2
headtwo
etc.
etc.
etc.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: