Author |
Message |
bozi39

|
Posted: 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

|
|
 |
Tony

|
|
|
|
 |
[Gandalf]

|
Posted: 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

|
Posted: 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

|
Posted: 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). |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
bozi39

|
Posted: 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

|
Posted: 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

|
|
|
|
 |
Sponsor Sponsor

|
|
 |
[Gandalf]

|
Posted: 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

|
Posted: 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]

|
Posted: 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

|
Posted: 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

|
Posted: 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]

|
Posted: 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

|
Posted: 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 |
|
|
|
|
 |
|