Cooldowns and linking to keys?
Author |
Message |
C4mMC1
|
Posted: Fri May 01, 2009 12:41 pm Post subject: Cooldowns and linking to keys? |
|
|
What is it you are trying to achieve?
<Replace all the <> with your answers/code and remove the <>>
I trying to make an arena fighting game in turing and am having some trouble.
What is the problem you are having?
<Answer Here>
I want to have cooldowns on all the attacks and link the second players controls to WASD but I dont know how to do that.
Describe what you have tried to solve this problem
<Answer Here>
I have tried to use delay for cooldowns but all it does is slow down the game and I cant figure out the code to link the controls.
Any help would be appreciated. Thanks.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
<Add your code here>
|
Please specify what version of Turing you are using
<Answer Here> |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
corriep
|
Posted: Fri May 01, 2009 3:00 pm Post subject: RE:Cooldowns and linking to keys? |
|
|
Can we see what you have so far? |
|
|
|
|
 |
Euphoracle

|
Posted: Fri May 01, 2009 3:09 pm Post subject: RE:Cooldowns and linking to keys? |
|
|
You'd have to store the Time.Sec (or the millisec variant) for each attack, and check each iteration if it has expired. You can do that using something like this:
Turing: | const cooldown := 5
var last := 0
var diff := 0
var x, y, b := 0
loop
locate (1, 1)
diff := last - Time.Sec
if (diff <= 0) then
put "Ready to attack!"
else
put "Wait ", diff, " seconds."
end if
Mouse.Where (x, y, b )
if (b = 1 and diff <= 0) then
last := Time.Sec + cooldown
elsif (b = 1) then
put "Wait!!!"
else
put ""
end if
end loop
|
|
|
|
|
|
 |
Insectoid

|
Posted: Fri May 01, 2009 3:25 pm Post subject: Re: Cooldowns and linking to keys? |
|
|
use a counter in the loop like...
counter := 50 % dependent on cooldown
loop
%your stuff here
counter := counter - 1
if counter := 0 then
% allow for use of power again
counter := 50
end if
end loop
you will need a counter for each power and a counter state to determine if the power should be activatable or still requires cooldown |
|
|
|
|
 |
|
|