Whack a Mole
Author |
Message |
brazilian_princess
|
Posted: Tue Jun 10, 2003 12:39 pm Post subject: Whack a Mole |
|
|
alritey, for my final project im makin a whack a mole game. the only problem is i suck... so, i dont really kno how to make the moles keep poping out without waitin for the user to click on one before.... i dont kno if i explained that to well, but if i did, can ya help? thanks |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Tue Jun 10, 2003 1:21 pm Post subject: (No subject) |
|
|
if you have no idea how to do something, maybe you should pick another project
though then again... that way you not gonna learn anything
To keep moles popping in/out, you just use a timer. While running the waiting loop, also check for time, and if mole is out for long enough, its time for it to pop back in |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
naoki
|
Posted: Tue Jun 10, 2003 5:20 pm Post subject: (No subject) |
|
|
make the mole popping out a process and if it is out of the hole you set a boolean to false
then use mouse.where and if it clicks in a certain area while the boolean is false then you've scored a hit. end the mole process for that hole.
you'll basically want to loop the mole processes and use mouse.where, and don't forget about tony's timer thing too |
|
|
|
|
|
Andy
|
Posted: Tue Jun 10, 2003 5:35 pm Post subject: (No subject) |
|
|
ya or u can have the mole to be the a couple of coulors then use whatdotcolor |
|
|
|
|
|
AsianSensation
|
Posted: Tue Jun 10, 2003 6:03 pm Post subject: (No subject) |
|
|
don't listen to andy(dodge_tomahawk) he is on crack. if you want a fast efficient program, don't use whatdotcolor. whatdotcolor takes too much memory, and since your checking to see if you've hit the mole, whatdotcolor will just be a waste of memory. Instead, just set restrictions on the x and y value of where your mole is. |
|
|
|
|
|
Andy
|
Posted: Tue Jun 10, 2003 6:17 pm Post subject: (No subject) |
|
|
die meng... whatdotcolor is not slow, not if ur checking only one pixel... and but ur rite about the unefficency tho
just have an array of now many hows there are
code: |
var numholes,x,y,button,circleradius :int
var circlex,circley:array 1..numholes of int
var mole:array 1.. numholes of boolean
for i:1..numholes
mole(i):=false
end for
process switchholes
loop
for i:1..numholes
mole(i):=false
end for
mole(Rand.Int(1,numholes):=true
delay(1000)
end loop
end numholes
end switchholes
loop
mousewhere(x,y,button)
for i:1..numholes
if ((circlex(i)-x)**2) + ((circley(i)-y)**2)<=circleradius**2 and mole(i)then
%do what ever u wanna do here
end if
end for
end loop
|
this is basicly what ur looking for numholes is how many holes u have, circleradius is the radius of the holes if u wanna have a score, just have a new variable and add one to it if a mole is wacked |
|
|
|
|
|
|
|