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

Username:   Password: 
 RegisterRegister   
 How to use mouse commands to perform animations
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
bozi39




PostPosted: Sun Apr 16, 2006 3:17 pm   Post subject: 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
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sun Apr 16, 2006 3:23 pm   Post subject: (No subject)

[Turing Walkthrough] provides links to such tutorials as Mouse.Where
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
[Gandalf]




PostPosted: Sun Apr 16, 2006 4:52 pm   Post subject: (No subject)

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




PostPosted: Sun Apr 16, 2006 5:33 pm   Post subject: (No subject)

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




PostPosted: Sun Apr 16, 2006 6:03 pm   Post subject: (No subject)

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).
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
bozi39




PostPosted: Sun Apr 16, 2006 7:01 pm   Post subject: (No subject)

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




PostPosted: Sun Apr 16, 2006 7:07 pm   Post subject: (No subject)

just have a simple integer as a counter
code:

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




PostPosted: Sun Apr 16, 2006 7:34 pm   Post subject: (No subject)

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 Thinking

To elaborate on iker's example:
code:

loop
% this is your game
Mouse.Where(x,y,button)

if button = 1 then % button down
   counter += 1 % shooting for another frame

   if counter <= cool_down_cap then
      % still shooting
   else
      % reached cool_down_cap, stop
   end if

else % button is up
   counter := 0  %reset cooldown
end if
...
end loop
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Sun Apr 16, 2006 9:46 pm   Post subject: (No subject)

Yep, there is a Time module. The function you're looking for is Time.Elapsed.

You can also achieve the same effect with the older functions clock() (which works the same as Time.Elapsed) and wallclock() (which returns the amount of milliseconds since some date in 1970).
bozi39




PostPosted: Mon Apr 17, 2006 9:09 pm   Post subject: (No subject)

Thanks guys. I thaught of using the Time.Elapsed command but that caused my entire program to stop for the input time and i could not even move my weapong for that time. Did i do something wrong in order to obtain this result or is there no way around that? Also can you guys tell me how my game runs on ur computers and just make some general comments about it please.
[Gandalf]




PostPosted: Mon Apr 17, 2006 10:03 pm   Post subject: (No subject)

It's a pretty good start, haven't seen too many games similar to it made before. The wallpapers and everything is nice, though you set it up for an amazingly high resolution which doesn't work well with my 1024x768.

Time.Elapsed doesn't pause input at all (well, only as long as it takes to call the function). Something like this should work perfectly fine without pauses:
code:
var timeWastingInt : real
put Time.Elapsed
for i : 1 .. 50000
    timeWastingInt := i * 4 ** 3 / 4
end for
put Time.Elapsed

The first output should be slightly larger than the second because of the execution time of the for loop.
bozi39




PostPosted: Tue Apr 18, 2006 7:50 pm   Post subject: (No subject)

Hey guys. I improved the animations and i think that they work significantly better now. I used iker's methond so thanks a lot iker. However i now cant make it so that the user has to let go of the mouse button so that they can fire again when using a semi automatic weapon like a pistol. Is there a way to make it that way or not because i have seen some pretty good fps games where that detail was not integrated - did the guy not pay attention to it or is there no way to do what i want to do. I would post my new code version as .rar file but it sais i have reaced my 2.00 mb limit and it tells me to remove my old attatchments but i dont kno how cause no such button appears on the attatchement screen. Thanks
bozi39




PostPosted: Tue Apr 18, 2006 7:53 pm   Post subject: (No subject)

never mind guys i got the thing so u have to release the button. as i was writing the last reply i thaught of it. Now can u please tell me how to upload new attatchments and remove my old ones
[Gandalf]




PostPosted: Tue Apr 18, 2006 8:09 pm   Post subject: (No subject)

The update your attachment, just edit the original post and use the "Update Attachment" button. To manage your attachments in other ways, go to the user attachment control panel.
bozi39




PostPosted: Tue Apr 18, 2006 11:16 pm   Post subject: (No subject)

Thanks Gandalf. I made some progress with my game tonight and i made the animations work and look better. I am posting the latest version of my game if anyone wants to take a look. Please provide me with feedback about it and please tell me how the problems may be solved if you notice any.
P.S please play on the map called Baghdad - i have put made sure all the weapons i have integrated so far are playable

thanks
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 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: