Computer Science Canada

Shootins problems

Author:  upthescale [ Sat May 06, 2006 10:06 pm ]
Post subject:  Shootins problems

Ok i have just recently started a shooting game...about an hour ago hhah and my problem is when i shoot, the deteftion is good (whatdotcolor is the most amazing and most efficient way of detections) but you can hold the mouse down and keep shooting, how can ido it so once you click o nthe mouse, it will only shoot once, adn that's it...the user then has to elt go and click again?


Thanks in advance

robbie

(p.s , when you are talkign about flash, that is action script, or java what is turing called? the language? Dos?)

Author:  TheOneTrueGod [ Sat May 06, 2006 10:22 pm ]
Post subject: 

First of all, whatdotcolour is only one way of detection. There are many more efficient and more amazing ways of detection (if implemented properly) (And i'm sure andy would love to argue that with me Razz)

Anyways, on to your question. You need an "oldbutton" variable. This would keep track of what the buttonclick was last time through the main loop, eg:

code:

var x,y,button,oldbutton : int
button := 0
loop
   oldbutton := button
   mousewhere(x,y,button)
   if button = 1 and oldbutton = 0 then %If they clicked this time through the loop, and not last time, then...
         DO STUFF HERE
   end if
end loop

Author:  upthescale [ Sat May 06, 2006 10:26 pm ]
Post subject: 

man u are a genious hah thanks alot my program shud be good cuz i learned arrays and wdt!!!!

Author:  Delos [ Sat May 06, 2006 10:29 pm ]
Post subject: 

TheOneTrueGod wrote:
(And i'm sure andy would love to argue that with me Razz)


Hardly Wink. In a recent post, the whatdotcolour warrior revealed why it is that he garnered himself that name:

dodge wrote:

...my obsession with whatdotcolour has nothing to do with "taking the easy way" but rather thinking abstractly...


He also had the interesting anecdote of:

Quote:

...collision detection whatdotcolor is for noobs... unless you're talking about masking irregular shapes...


Anyhow. Back on topic. The 'oldmouse' technique works fine. You could, however, look into Mouse.ButtonMoved() and Mouse.ButtonWait(). You'll be surprised how much the Turing Help (F10) can tell you. I'm glad to see you've finally started taking some initiative and learning new things. Keep plugging away.

Author:  upthescale [ Sat May 06, 2006 10:32 pm ]
Post subject: 

sorry but it doesn't work this is what i have inside my loop, inside my for statment:

code:

   oldbutton := b




        if whatdotcolor (x, y) = 90 and b = 1 and oldbutton = 0 then
            randint (people (i).peoplex, 120, 1070)
            randint (people (i).peopley, 670, 670)
            kills += 1
        end if


Author:  TheOneTrueGod [ Sat May 06, 2006 10:53 pm ]
Post subject: 

You have to put the oldbutton := b ***BEFORE*** the Mouse.Where, otherwise theres no point to having it. (Because code goes linearly...) Alternatively, investigate the concepts delos explained.

Author:  upthescale [ Sat May 06, 2006 10:56 pm ]
Post subject: 

then varaible wil haev no value!!!!!

Author:  upthescale [ Sat May 06, 2006 10:58 pm ]
Post subject: 

Truly sorry for spamming, therei sno edit button...but i got it thx man 10 bits (w/e they are) lol


: