Pages

Friday, August 24, 2012

10b: Taking Swipes Return

One thing I neglected to mention in the last post was the bugs that crept up on me. When i originally worked on the last blog post, I actually wrote it all out before even trying it. Not the smartest thing to do, no, but since what I was doing would work in theory (and wasn't too complicated), I figured it was worth a shot. Fortunately it worked, but not without a lot of bugs. What you ended up seeing me typing was a fully working version, but I actually had several problems along the way. I figure I should go over them now, since debugging is a very important skill to learn.

The biggest problem early on is the alarm event. Originally the code read like this:

End Step:

if (sprite_index == spr_tswingr)
{
     if (image_index == 4)
     {
          image_speed = 0
          lightable = 1
          alarm[0] = 8
     }
}

This originally caused me trouble. Why? Because in the current code, the alarm is reset to 8 every frame as long as Tanner is on his 4th slashing frame, leaving him stuck there. That's why I finally touched it up to:

End Step:

if (sprite_index == spr_tswingr)
{
     if (image_index == 4)
     {
          image_speed = 0
          lightable = 1
          if (alarm < 0)
          {
               alarm[0] = 8
          }
     }
}

With this if statement added, the alarm won't constantly reset itself. Unfortunately, this also means that we have to make sure the alarm is turned off before it reaches this bit of code.

Next off is a small detail, but one I forgot early on.


Step Event:
if (keyboard_check_pressed(z) && lightable == 1)
{
     runable = 0
     jumpable = 0
     lightable = 0
     sprite_index = spr_tswingr
     image_index = 0
     image_speed = (1/2)
}

Early on when repeating the attack animation, I noticed that he wouldn't actually change frames because I never bothered to type in image_index = 0.

That's about it for now. I just thought I'd address the issue, since the last post I ignored all the bugs I ran into.


No comments:

Post a Comment