
-----------------------------------
bozi39
Sun Apr 16, 2006 3:17 pm

How to use mouse commands to perform animations
-----------------------------------
Hey guys. I have been working on a 2-d fps game for my final compsci project and i ran into some problems when it came to doing the animations for the guns. If you download the attatchment you will see that so far i have put in 2 guns and 2 maps. What i want to do next it make the normal gun picture change to the firing gun picture when the use presses the mouse button and then have it change back to the normal picture once the button is released. Can you please tell me which mouse commands to use and if i should use Sprites (which i have heard dont work in turing although they are included in the Turing help)
P.S. If you try to play play only with the Deagle because the ak-47 pic is missing

-----------------------------------
Tony
Sun Apr 16, 2006 3:23 pm


-----------------------------------
[Turing Walkthrough] provides links to such tutorials as [url=http://www.compsci.ca/v2/viewtopic.php?t=6]Mouse.Where

-----------------------------------
[Gandalf]
Sun Apr 16, 2006 4:52 pm


-----------------------------------
You seem to be able to use the mouse commands fairly well...  You'll have to be more specific about your problem to get more specific help.

Also, you probably shouldn't be using Sprites, unless you have Turing 4.1, and even then...

-----------------------------------
bozi39
Sun Apr 16, 2006 5:33 pm


-----------------------------------
thanks for replying guys. Here is the specific problem i am experiencing. As you all know in fps games you move the guy's hand which is hold a wepon in a non-firing position until you click the mouse button. Once you click the mouse button a picture of a weapong while firing replaces the old picture for a spit second and then the non firing picture is displayed again. If you have downloaded my code you have seen that the first part works fairly well- you move the non-firing picture untill you click the mouse button, then a firing picture is displayed for a split second. However after that second is over and if you continue to hold down the mouse button the non - firing picture is not displayed. It only appears after you release the mouse button. So in short: how can i get the non firing picture to be redisplayed right after the mouse button is clicked and not after it is released. in order to see what i am talking about you might have do download my code. Also if you are able to come up with a suggestion could you please post the code to it so that i can understand what you are talking about better since i am relatively new at turing. Thanks a lot guys

-----------------------------------
Tony
Sun Apr 16, 2006 6:03 pm


-----------------------------------
to introduce cool-down, you need a timer

on click (change from up to down) you set your timer to 0, then you register fire for the next whatever amount of time. Once the timer expires, the flag is set back to neutral gun and you don't register hits. The timer will not be reset until the next click (remember, you're looking for change from up to down, not just holding the button down).

-----------------------------------
bozi39
Sun Apr 16, 2006 7:01 pm


-----------------------------------
Thanks Tony. I have seen my friend use a timer in his games in order to time animations but i am not sure what command i should use in order to implement this concept in my game. Can you please show me an example??

-----------------------------------
iker
Sun Apr 16, 2006 7:07 pm


-----------------------------------
just have a simple integer as a counter

if firing = true then
    count += 1
else
    count := 0
end if
if count >= 3 then
    count := 0
end if
if count = 2 or count = 3 then
    %display fireing weapon
else
    %display non-fireing weapon
end if

theres a simple code to help you out

-----------------------------------
Tony
Sun Apr 16, 2006 7:34 pm


-----------------------------------
that's more of a flag approach. Though you could just as well count the main loop's ticks. I suppose this would even be more accurate since you will always be able to fire for a set number of frames, not more on a faster computer :wink: 

I don't recall exact Turing syntax at the moment. Is there a Time. module? I think there was also wallclock or something :think:

To elaborate on iker's example:

loop
% this is your game
Mouse.Where(x,y,button)

if button = 1 then % button down
   counter += 1 % shooting for another frame

   if counter 