Monday, August 27, 2007

Week 8 -- Knocking each other around

The battle prototype came along nicely this week. I added the "wait time" in between attacks (preventing button mashing) and made so that you and the enemies knock each other back with each hit. (I also added not-yet-used displays for MP and SP.)

For the wait time, I realized that I really needed to add some simple state tracking to my player and enemies. In the process, I also cleaned up a couple of details, making it so you can't move while swinging your sword, etc. So far the player has an action state that is either ready, mid-attack, or wait ("cool-down" if you will), with more coming for spells and stuff later. There's also a just-got-hit flag (can't control your movement or attack while you're getting knocked back).

Had some trouble getting the knock-back effect right. It was easy to just knock you straight left or whatever, but I ran into problems trying to knock you back away from the direction of contact. First I tried taking the normal from the collision callback. That worked if you were standing still (after I fiddled with the collision settings), but sometimes would make you go backwards. Not sure why. I eventually got something working with some trig after some trial and error:

%rise = %dstObj.getPositionY() - %this.getPositionY();
%run = %dstObj.getPositionX() - %this.getPositionX();
%collDeg = mRadToDeg (mAtan (%rise, %run)) - 90;
%this.setLinearVelocityPolar (%collDeg, 20);


I think it needs the - 90 because in TGB 0 degrees is up instead of to the right. Or something. It's past my bedtime.

So now you fly backwards when the enemies run into you, and they fly backwards (away from you rather than your sword itself) when you hit them. That was cool.

I also made the enemy movement a bit more interesting. (I had to in order to knock them around. I had just been doing a moveTo and forgetting about them until they arrived, but they might not ever get there once the player started knocking them around.) So now they move towards you in "hops" with regular pauses. Then I was having fun so I made them sometimes take a longer pause and then lunge extra-fast! Yikes! Fun stuff.

There's still not much to see from a screenshot. Maybe I'll figure out how to take a movie sometime soon.

I'm about two weeks behind on my schedule. I'm still going for completing a rough, rough draft of the opening by the end of September. I'm feeling unsure about the plot, specifically the details of how the story starts off. So my "first five minutes" milestone will be more tentative as far as what exactly happens -- I'll use more "placeholder" type dialogue and areas rather than spending significant time on the details of something I'll likely change later.

The final steps for the battle system prototype are the spellcasting system and special techniques. That covers all the things I want to test out, and will set me up to take a running start at the real game.

No comments: