Whack a mole
Author |
Message |
Mystique
|
Posted: Sat May 06, 2006 2:59 pm Post subject: Whack a mole |
|
|
Hi!
For my ISU, i want to make a whack a mole program, but the only problem is i don't know how to make the mouse click the mole and store it in the program so that it can keep track of the points . Anyhelp will be appreciated a lot ![Very Happy Very Happy](images/smiles/icon_biggrin.gif) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Sat May 06, 2006 3:18 pm Post subject: (No subject) |
|
|
To work with mouse input, use Mouse.Where.
Apart from that, you'll need to be more specific in your question. |
|
|
|
|
![](images/spacer.gif) |
Mystique
|
Posted: Fri May 12, 2006 5:50 pm Post subject: (No subject) |
|
|
Thanks for the help Cervantes, I did not know about Mouse.Where
But now i have a new problem In my program, I have 6 holes located on the screen, and from this holes I want the moles to come out of them and then disappear back in the hole randomly.
The moles I'm using have been done by using turing. I don't know how to make the moles come in and out without keep on drawing a new picture. How would i do the moles popping in and out, without drawing new images?
I hope this question is a bit more clear. |
|
|
|
|
![](images/spacer.gif) |
HellblazerX
![](http://www.plamania.co.kr/shopimages/plmtest/2910040000213.jpg)
|
Posted: Fri May 12, 2006 6:33 pm Post subject: (No subject) |
|
|
You could use Sprites in your program, and when you want a mole to disappear, use hide, and use show when you want the mole to reappear. |
|
|
|
|
![](images/spacer.gif) |
Mystique
|
Posted: Fri May 12, 2006 6:55 pm Post subject: (No subject) |
|
|
sprites?!?!?!, i never heard of those (there is so much im finding out here than in skl). i looked it up in the turing directory thing, and tried to run it and got an error message. . is there any other method than using sprites? |
|
|
|
|
![](images/spacer.gif) |
Clayton
![](http://compsci.ca/v3/uploads/user_avatars/1718239683472e5c8d7e617.jpg)
|
Posted: Fri May 12, 2006 8:50 pm Post subject: (No subject) |
|
|
unfortunately not really, unless you want to make a procedure to randomly hide a mole, and randomly show a mole, check the Turing Walkthrough if you are having any problems that you dont understand, good luck ![Very Happy Very Happy](http://compsci.ca/v3/images/smiles/icon_biggrin.gif) |
|
|
|
|
![](images/spacer.gif) |
TheOneTrueGod
![](http://www.drmcninja.com/images/mcninjab3.jpg)
|
Posted: Fri May 12, 2006 9:50 pm Post subject: (No subject) |
|
|
yarr... sprites are all but worthless in turing from what I have heard (never bothered to use them, allways create my own )
First of all, consider learning arrays and records, in order to keep your code easy to use and understand. These can be found in the [Turing Walkthrough]. Once you have learnt these, have an activation flag for each mole. That is to say, have a boolean that is true if the mole is active, and false if the mole isn't. If the mole is active, you can either just draw it as out, or you can have it slowly pop out of the hole. I'd suggest you start with it just appearing, and then if you feel like it, work from there. |
|
|
|
|
![](images/spacer.gif) |
Guest
|
Posted: Fri May 12, 2006 10:34 pm Post subject: Possibility |
|
|
What I would do is use a rand.int or something, and make the mole appear and use counters to move it up then back down, then clear him or something. Then a combo with Mouse.Where and Whatdotcolour you can tell if you click a mole. I bet someone is going to bash my reply because I'm new to these forums and someone will say "DO NOT USE WHATDOTCOLOUR ITS COLLISION DETECTION SUCKS!" |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
TheOneTrueGod
![](http://www.drmcninja.com/images/mcninjab3.jpg)
|
Posted: Sat May 13, 2006 9:16 am Post subject: (No subject) |
|
|
Erm, generally anyone who replies in all caps like that is a troll/idiot and should be ignored, but eh. Whatdotcolour collision doesn't suck. It has its uses, but for this case, I would have to disagree that whatdotcolour is a good thing. To be able to use it effectively, he would have to colour each mole a different colour (In order to determine which mole was whacked when), and how many brightpurple moles do you see running around
For this project, It would probably be better to use a square based collision detection, depending on how they are shaped, and depending on if the game is top-down view, or facing from the front. The other option is circular detection.
square based detection is simply:
code: | if mx >= leftside and mx <= rightside and my >= bottom and my <= top then
HitDatMole
end if
|
Where the left, right, bottom, and top are referring to the sides of the mole
Circular collision just uses the distance formula:
code: | if (mx-molex)**2 + (my-moley)**2 <= moleradius**2 then
HitDatMole
end if |
|
|
|
|
|
![](images/spacer.gif) |
Mystique
|
Posted: Wed May 17, 2006 7:30 pm Post subject: (No subject) |
|
|
I have been looking around the forums and have gotten an understanding that Sprite has been deactivated in Turing 4.0.1 (correct me if im wrong). If that is the case, then that explains why whenever I use Sprites, it doesn't work (or im just using it wrong ). So, does that mean the only way of making the moles disappear or reappear is using Rand.Int or something along that line? |
|
|
|
|
![](images/spacer.gif) |
TheOneTrueGod
![](http://www.drmcninja.com/images/mcninjab3.jpg)
|
Posted: Wed May 17, 2006 7:47 pm Post subject: (No subject) |
|
|
There are as many ways of making the moles appear and dissapear as you can think of / implement.
The question you should be asking is: "What is the best one for this situation?"
and, as a further question, "What does best mean?"
Use whatever method you are most comfortable with, be that legions of variables, parallel arrays, records, or even OOP. If you think you fall somewhere on that list, try the next step up, and learn something new . |
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Wed May 17, 2006 7:51 pm Post subject: (No subject) |
|
|
Wouldn't you have to use Rand.Int anyways? How would sprites tell you which mole is going to appear/disappear? |
|
|
|
|
![](images/spacer.gif) |
|
|