Thursday, 5 May 2016

Class 50 - Making My Own Timer

Post 133

Making My Own Timer

Today I started to fix my problem from last class, I spent a good two or so hours trying various ways to fix this problem using the image_index function. However it didn't seem to matter how I did it as long as I was using the Image_index function it wouldn't work. So I decided to try and find away around it, so what I did was make a normal timer that just sets off at the same time the animation starts, this should give the same effect. The problem with this is I couldn't use the alarm functions because I would have to have a different alarm for all the different variations of attack. This would make coding in the delay not worth it. So instead I created a timer that I could use on all of them at once.


I first started with my 3 variables. "Attacklate" Tells the code when the attack should be happening, so when this is set to true the attack occurs, so obviously I want this to be set to true moments after the player clicks the attack button.
"Attacktimer" Is when the code has been told to actually start the timer, so if it is set to true that means the player is attacking.
"Attacktimernumber" Is the time between when the player presses the button and when the attack should actually occur. Once this reaches 5 or greater it resets everything and sets "Attacklate'" to true, thus allowing the player to attack. Once the attack has finished "Attacklate" is set back to false and the process can repeat.




Next class I will continue to work on the code of my game and possible improve attacking in general by creating a heavy attack for the player.

No comments:

Post a Comment