Devestating Update #4 Jumpy JumpnessSo I really had no idea how much was involved to get a character to jump!
My initial thought for workload would be to have the Up key to make the character move upwards, and then 'gravity' would do its thing and make the character fall down again. Its a lot more involved I found out in regards to getting it to feel right.
So though my experimenting and reading there seems to be 3 ways a character can jump in a game. Here is what I believe they are...
#1 Shot out of a cannon jumpingBasically, when pressing the jump button, your character is given a set vertical momentum upwards. Its the same amount each time regardless if you hold the jump button or just tap it. This type of jumping is in a lot of first person shooters. Once you are given that initial burst, gravity does the rest, slowing you down and then falling.
#2 Rocket boots jumpingDepending on how long you hold the jump button, will depend on how high your jump is. Mario Brothers is a good example of this. If you light tap the button you only do a little weeny jump, but if you press and hold Mario goes a lot higher.
Basically you have an initial boost upwards and then if you are still holding the jump button another boost is given, this time with a fraction of the initial power. The longer you hold it the more boost you get until it reaches a certain point and gravity takes over.
I spent a fair bit of time experimenting with this as it's my chosen form of jumping in this game. It took a while to get the values right. Too much initial boost and additional boosts afterwards shot my character into space. To little and the character wouldn't jump over a rock. There was also the problem with it feeling like you are actually using a jetpack when you held down the jump button, so getting the fractions of the initial boost right was hard.
What I ended up doing was to have an initial velocity, and make sure my boost velocities never exceeded the initial velocity. Otherwise you'd get and acceleration feeling when jumping, not a spring feeling. Also I upped the gravity significantly, so now its much more brutal when bringing you down to the ground, thus it means I had a lot more play room for the jump boost variables.
#3 Powerup and release jumpingBasically, you hold the jump button down and when you release it, the character performs the jump. The longer you hold the button down, the higher the jump power will be when you release.
I imagine this type of jump mechanic is closer to real life. IRL you bend and then jump, setting up your own power for the launch upwards. But the downside to this is you have a feeling of laggy jump response.
You could go about it in 2 ways. Wait for the player to release the button and then apply the velocity upwards. There would be some sort of cap so the player doesn't shoot off to space. OR once the power has reached the cap you make the character jump regardless if the player released the button or not. (this would probably be done in half a second)
So with the physics of jumping implemented, I needed to get back to the character state/animation system so it could take advantage of it.
What I ended up doing is scrapping the old Animation Structures I had, which contained details like, 'if the animation was to loop', its 'play speed', etc, and moved onto a more universal structure that basically held the character's state, their texture for a particular state, and various other values.
It took about 2 days worth of work to get going, couldn't run the game during the re-work as there would be too many errors. But it seems a lot more solid now. Its still got a few bugs when it comes to transitioning from one state to another, but as I add more character states in I should be able to identify the common problems and re-work a portion of the system again so it runs smoother.
The advantage of the new system is I can add 1 line of code for each character state, instead of multiple lines across multiple files. Previously I would have to make sure the Character Class loaded the correct assets, that the sizing was right and the animation speeds were right. I'd then have to make matching variables in an Animation class that would pass details onto the draw system as to what to use. There were some annoying limitations to that system and to get jumping the way I wanted would have mean a lot of crazy code in that system.
The new system basically allows me to fill in the Type Of Character, The State these details will be matched to, the Texture thats used in this state, the frame size for the state, etc.
void NewState( Core.CHARACTERSTATE _characterState,
Core.CHARACTERSTATE _characterStateNextPreferred,
string _textureLocation,
int _textureNumOfFrames,
int _playSpeed,
int _playSpeedModifyer,
bool _animLoop,
bool _animHoldOnFinish,
int _updatesUntilFinish)
Well with one week left and I start work again on Monday the 4th (after finishing Xmas holiday), time is going to be short and I'm already cutting features galore.
The first one to go today was
Walking->Running transition. While it may seem small to get done, its just another item on the list with other small things that would be nice to get done, but every moment something small like that takes away, it may leave a dent in a larger feature that would be better to have in.
The Main menu will probably also go, and starting the game will throw you directly into gameplay.
BUT, there are things that I really want to get done.
* Enemies (even if they are mindless fodder)
* Dragon Princess attacking enemies
* Some sort of item system that you pick up things and give them to the princess
* Trigger systems for traps
Theres a lot of things I'd like to get in, but I doubt I will before the challenge ends.
* Puzzle systems with levers and other cool things
* Advanced traps
* Smart enemies
* Much more varied role for you as the sidekick
While I like to think big as to what this game could become, I know a lot of it wont get done for the deadline. So I'll put together a sort of proof of concept and see what people think.
And maybe, assuming I'm not too burnt out by the end of it, see if the artists would like to continue the game further outside of the challenge which would yield more art assets to play with hopefully.
My goal tomorrow is going to be fairly small as I need to get ready for work. I want to get some sort of enemy added and hopefully the attack system implemented.
Assuming it all looks hunky dory I'll try and release v0.2 that night.