Friday, April 8, 2016

This week was pretty productive. We were able to make the attack function work exactly as we wanted it to. When we started the week, we had an attack function that would never stop. Essentially, the player character could constantly attack by holding "x", which was extremely broken as the character would never take damage when he was attacking, and he could move and such while he was attacking. This was not good. Ideally, we wanted to make the attack so if the player held the attack key, the attack would end and not re-start. This would force the player to only attack when he needed to and to rely on his or her reflexes to lead him to victory rather than an unbalanced combat system.

We made a series of "if" statements to make it so the same thing wasn't happening at every second the player was pressing the "x" key. We had to do this because apparently JavaScript treats button presses as statuses rather than events. This actually really didn't work in our favor. If JavaScript treated button presses as events, we literally wouldn't have to do any work, because we only want the attack to happen once-per-press. To do this, we made three "if" statements that (we think) cover every possibility for a button-press. One: if the time between attacks had elapsed and the button was not pressed in the millisecond before; two: if the button was still being pressed during an attack and the button was pressed in the millisecond before; three: if the button was being pressed after the attack ended but had also been pressed the millisecond before. The first two conditions would lead to the attack animation being played, but the third would not. This fixed it. YAY

5 comments :

  1. Glad to see that the game is balanced again! Are you planning on adding a secondary attack?

    ReplyDelete
  2. Your game has come a long way! How are the statuses and events different?

    ReplyDelete
    Replies
    1. Great question Sparshee! I am curious about the answer too.

      Delete
  3. When you are coding do you actually type your "if statements" just like you did? How does this look when it is actually coded?

    ReplyDelete
  4. So glad to see all the progress you've made! Have you come across any coding issues with the if statements?

    ReplyDelete

Copyright © Totally Radical: Creating an Old-Fashioned Video Game with Modern Spunk

Distributed By My Blogger Themes | Blogger Theme By NewBloggerThemes Up ↑