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
Friday, April 8, 2016
Related Posts:
Week 4Hello all! As most of you know, my blog and Alex's got blog of the week last week, which is super exciting! Hopefully I can keep it up in the weeks to follow! This week began with a decision to extend the previously-completed… Read More
This week was our first week after our spring break week, and we made a lot of progress! We mostly focused this week on implementing the combat system so the player could damage his enemies through other means than simply jum… Read More
Week 3This week was all about making our own level 1 and putting it into the game, with original art for the character sprites. By this point in our project, Alex and I have reached the place where we can work independently of one … Read More
Week 5 This week, Alex and I continued to work out some more game mechanics not included in the base MelonJS engine. My biggest task was to figure out how to make tiles like spikes and acid hurt the player character. After searching… Read More
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 con… Read More
Subscribe to:
Post Comments
(
Atom
)
Glad to see that the game is balanced again! Are you planning on adding a secondary attack?
ReplyDeleteYour game has come a long way! How are the statuses and events different?
ReplyDeleteGreat question Sparshee! I am curious about the answer too.
DeleteWhen you are coding do you actually type your "if statements" just like you did? How does this look when it is actually coded?
ReplyDeleteSo glad to see all the progress you've made! Have you come across any coding issues with the if statements?
ReplyDelete