Hi everyone, as a newbie programmer, I am trying to develop a 2D side scrolling Streets of Rage like fighting game with a lot of characters, moves, and animations. I started to learn programming 1 year ago, and I managed to have a game where I have two player controllable characters hit each other, jump to higher elevations in a streets of rage style map, etc...
However, since I am new to programming, and rushed enthusiastically into programming the game without any plan, my code got really messy.
My problem is how to handle character states ( or moves ) , and their animation...
How I proceeded is: I have a huge switch function with states, another one with animations, another one with hitboxes for example:
//this is the base punch for the ninja character. // this is the state switch function case NINJA_BASEPUNCH: falsify(); // set everything to false (i.e. he cant jump while punch animation is on) bCanBasePunch = true; enumAnimState = NINJA_AS_BASEPUNCH; //animation is set to base punch animation enumHitMessage = HIT_LIGHT_HI; //this will tell the enemy entity the damage type ( light ) and its position ( high ) basePunch(); //punch function break; //once this is executed, the program will set the animation settings //this is from animation switch function case NINJA_AS_BASEPUNCH: sprite.w = 36; sprite.h = 36; iCurrentFrameCol = (bFaceRight ? 13:14); iCurrentFrameRow = 0; animation.maxFrames = 2; animation.setFrameRate(animation.getCurrentFrame() > 0 ? 100:60); break; } //this is from the hitbox update function. case NINJA_AS_PUNCH: hitbox.w = groundPos.w; hitbox.h = 35;
All this is only for a simple basic punch. Now imagine how would it be if there was a big move list, big combos, stunts, etc... I need to get a better system for it, anyone who can think of a better implementation system?







