Author: smiddy Date: Sat Apr 11 13:50:30 2009 New Revision: 310 Log: updated jumping animation to be more realistic added punching updated anim_512x to support sublooping began working on event firing Modified: trunk/Debug/re-write.exe trunk/data/NinjaDie.txt trunk/data/NinjaIdle.txt trunk/data/NinjaJump.txt trunk/data/NinjaPunch.txt trunk/data/NinjaRun.txt trunk/src/fight.cpp trunk/src/object.cpp trunk/src/object.h trunk/src/player.cpp trunk/src/player.h Modified: trunk/Debug/re-write.exe ============================================================================== Binary file (source and/or target). No diff available. Modified: trunk/data/NinjaDie.txt ============================================================================== --- trunk/data/NinjaDie.txt Thu Apr 2 00:39:43 2009 (r309) +++ trunk/data/NinjaDie.txt Sat Apr 11 13:50:30 2009 (r310) @@ -1,19 +1,20 @@ -../data/images/blankAnimationYellow.png -1 -../data/effects/boing.ogg -#1 -#2 -#3 -#4 -#5 -#6 -#7 -#8 -#9 -#10 -#11 -#12 -#13 -#14 -#15 +../data/images/blankAnimationYellow.png +0 +1 +../data/effects/boing.ogg +#1 +#2 +#3 +#4 +#5 +#6 +#7 +#8 +#9 +#10 +#11 +#12 +#13 +#14 +#15 #16 Modified: trunk/data/NinjaIdle.txt ============================================================================== --- trunk/data/NinjaIdle.txt Thu Apr 2 00:39:43 2009 (r309) +++ trunk/data/NinjaIdle.txt Sat Apr 11 13:50:30 2009 (r310) @@ -1,19 +1,20 @@ -../data/images/genman/r_idle.png -1 -../data/effects/bling.ogg -#1 -#2 -#3 -#4 -#5 -#6 -#7 -#8 -#9 -#10 -#11 -#12 -#13 -#14 -#15 +../data/images/genman/r_idle.png +0 +1 +../data/effects/bling.ogg +#1 +#2 +#3 +#4 +#5 +#6 +#7 +#8 +#9 +#10 +#11 +#12 +#13 +#14 +#15 #16 Modified: trunk/data/NinjaJump.txt ============================================================================== --- trunk/data/NinjaJump.txt Thu Apr 2 00:39:43 2009 (r309) +++ trunk/data/NinjaJump.txt Sat Apr 11 13:50:30 2009 (r310) @@ -1,19 +1,22 @@ -../data/images/genman/r_idle_jump.png -1 -../data/effects/boing.ogg -#1 -#2 -#3 -#4 -#5 -#6 -#7 -#8 -#9 -#10 -#11 -#12 -#13 -#14 -#15 -#16 +../data/images/genman/r_idle_jump.png +1 +7 +8 +1 +../data/effects/boing.ogg +#1 +#2 +#3 +#4 +#5 +#6 +#7 +#8 +#9 +#10 +#11 +#12 +#13 +#14 +#15 +#16 \ No newline at end of file Modified: trunk/data/NinjaPunch.txt ============================================================================== --- trunk/data/NinjaPunch.txt Thu Apr 2 00:39:43 2009 (r309) +++ trunk/data/NinjaPunch.txt Sat Apr 11 13:50:30 2009 (r310) @@ -1,19 +1,22 @@ -../data/images/genman/r_idle_attack.png -1 -../data/effects/bling.ogg -#1 -#2 -#3 -#4 -#5 -#6 -#7 -#8 -#9 -#10 -#11 -#12 -#13 -#14 -#15 -#16 +../data/images/genman/r_idle_attack.png +1 +7 +7 +1 +../data/effects/bling.ogg +#1 +#2 +#3 +#4 +#5 +#6 +#7 +#8 +#9 +#10 +#11 +#12 +#13 +#14 +#15 +#16 \ No newline at end of file Modified: trunk/data/NinjaRun.txt ============================================================================== --- trunk/data/NinjaRun.txt Thu Apr 2 00:39:43 2009 (r309) +++ trunk/data/NinjaRun.txt Sat Apr 11 13:50:30 2009 (r310) @@ -1,19 +1,21 @@ -../data/images/genman/r_run.png -1 -../data/effects/bling.ogg -#1 -#2 -#3 -#4 -#5 -#6 -#7 -#8 -#9 -#10 -#11 -#12 -#13 -#14 -#15 +../data/images/genman/r_run.png +0 + +1 +../data/effects/bling.ogg +#1 +#2 +#3 +#4 +#5 +#6 +#7 +#8 +#9 +#10 +#11 +#12 +#13 +#14 +#15 #16 Modified: trunk/src/fight.cpp ============================================================================== --- trunk/src/fight.cpp Thu Apr 2 00:39:43 2009 (r309) +++ trunk/src/fight.cpp Sat Apr 11 13:50:30 2009 (r310) @@ -95,10 +95,16 @@ case SDLK_a: keys_held[SDLK_a] = false; break; case SDLK_s: keys_held[SDLK_s] = false; break; + case SDLK_LCTRL: keys_held[SDLK_LCTRL] = false; break; + case SDLK_LSHIFT: keys_held[SDLK_LSHIFT] = false; break; + case SDLK_UP: keys_held[SDLK_UP] = false; break; case SDLK_DOWN: keys_held[SDLK_DOWN] = false; break; case SDLK_LEFT: keys_held[SDLK_LEFT] = false; break; case SDLK_RIGHT: keys_held[SDLK_RIGHT] = false; break; + + case SDLK_RCTRL: keys_held[SDLK_RCTRL] = false; break; + case SDLK_RSHIFT: keys_held[SDLK_RSHIFT] = false; break; } } } @@ -122,22 +128,26 @@ { if( keys_held[SDLK_d] == true ) player1->RunRight(); if( keys_held[SDLK_a] == true ) player1->RunLeft(); - if( keys_held[SDLK_w] == true ) player1->Jump(); + if( keys_held[SDLK_w] == true ) player1->Jump(); + if( keys_held[SDLK_LCTRL] == true ) player1->Attack(); if( (keys_held[SDLK_d] == false) && (keys_held[SDLK_a] == false) && - (keys_held[SDLK_w] == false) ) player1->IdleItUp(); + (keys_held[SDLK_w] == false) && + (keys_held[SDLK_LCTRL] == false)) player1->IdleItUp(); } if( player2->dead == false ) { if( keys_held[SDLK_RIGHT] == true ) player2->RunRight(); if( keys_held[SDLK_LEFT] == true ) player2->RunLeft(); - if( keys_held[SDLK_UP] == true ) player2->Jump(); + if( keys_held[SDLK_UP] == true ) player2->Jump(); + if( keys_held[SDLK_RCTRL] == true ) player2->Attack(); if( (keys_held[SDLK_RIGHT] == false) && (keys_held[SDLK_LEFT] == false) && - (keys_held[SDLK_UP] == false) ) player2->IdleItUp(); + (keys_held[SDLK_UP] == false) && + (keys_held[SDLK_RCTRL] == false)) player2->IdleItUp(); } if( Check_Collision(player1->hitbox_body, player2->hitbox_body) == true && Modified: trunk/src/object.cpp ============================================================================== --- trunk/src/object.cpp Thu Apr 2 00:39:43 2009 (r309) +++ trunk/src/object.cpp Sat Apr 11 13:50:30 2009 (r310) @@ -476,6 +476,16 @@ getline (myfile, line); imagedata = Image_Load(line.c_str()); + /* check if an animation loop exists */ + getline (myfile, line); + loopcheck = atoi(line.c_str()); + if(loopcheck == 1) + { + getline (myfile, line); + loopStart = atoi(line.c_str()); + getline (myfile, line); + loopEnd = atoi(line.c_str()); + } /* get number of effects */ getline (myfile, line); neffects = atoi(line.c_str()); @@ -540,6 +550,7 @@ Mix_PlayChannel(channel, effects[feffect[cframe]], 0); } cframe++; + if (cframe == loopEnd + 1) cframe = loopStart; if(cframe > 15)cframe = 0; } Modified: trunk/src/object.h ============================================================================== --- trunk/src/object.h Thu Apr 2 00:39:43 2009 (r309) +++ trunk/src/object.h Sat Apr 11 13:50:30 2009 (r310) @@ -130,6 +130,10 @@ int cframe; SDL_Surface *imagedata; SDL_Rect src; + /* anim looping */ + int loopcheck; + int loopStart; + int loopEnd; /* sound */ int channel; int neffects; @@ -138,6 +142,7 @@ /* frame limiting */ int time, time_old, time_frame; + __event void anim_finished(); PVN_anim512x(const char*, int); ~PVN_anim512x(); void Change_Frame(); Modified: trunk/src/player.cpp ============================================================================== --- trunk/src/player.cpp Thu Apr 2 00:39:43 2009 (r309) +++ trunk/src/player.cpp Sat Apr 11 13:50:30 2009 (r310) @@ -6,7 +6,7 @@ float arg_x, float arg_y, int arg_width, int arg_height, float arg_jumpPower, float arg_speed) : - health(100), gravity(9.8), jumping(false), dead(false), xPos(arg_x), + health(100), gravity(9.8), jumping(0), dead(false), attacking(false), xPos(arg_x), yPos(arg_y), xVel(0), yVel(0), width(arg_width), height(arg_height), jumpPower(arg_jumpPower), topSpeed(arg_speed), accelerationRate(10) { @@ -35,7 +35,7 @@ void Player::RunLeft() { - if( jumping == true ) + if( jumping > 0 ) { accelerationRate = 2; } else { @@ -51,7 +51,7 @@ void Player::RunRight() { - if( jumping == true ) + if( jumping > 0 ) { accelerationRate = 5; } else { @@ -67,17 +67,21 @@ void Player::Jump() { - if( jumping == false ) + if( jumping == 0 ) { - yVel = jumpPower; + currentAnimation->cframe = 0; currentAnimation = anim_jump; - jumping = true; + jumping = 1; + } + if (jumping == 1 && currentAnimation->cframe == 8){ + yVel = jumpPower; + jumping = 2; } } void Player::IdleItUp() { - if( jumping == false ) + if( jumping == 0 && attacking == false) { if( xVel < 0 ) { @@ -91,6 +95,17 @@ } } +void Player::Attack() +{ + if (attacking == false) + { + currentAnimation->cframe = 0; + currentAnimation = anim_punch; + attacking = true; + } + +} + void Player::Die() { dead = true; @@ -133,7 +148,15 @@ { yPos = 300; yVel = 0; - jumping = false; + if (jumping == 2) + { + jumping = 3; + currentAnimation->Change_Frame(9); + } + if (jumping == 3 && currentAnimation->cframe < 9) + { + jumping = 0; + } } if( xPos >= 680 ) { @@ -146,6 +169,13 @@ xVel = 0; } + currentAnimation->Change_Frame(); } + +void Player::AnimFinished() + { + + } + Modified: trunk/src/player.h ============================================================================== --- trunk/src/player.h Thu Apr 2 00:39:43 2009 (r309) +++ trunk/src/player.h Sat Apr 11 13:50:30 2009 (r310) @@ -13,8 +13,8 @@ topSpeed, accelerationRate, gravity; - int width, height, health; - bool jumping, dead; + int width, height, health, jumping; + bool dead, attacking; SDL_Surface *temp, *image; PVN_anim512x *currentAnimation; PVN_anim512x *anim_idle, *anim_run, *anim_jump, *anim_punch, *anim_die; @@ -34,9 +34,11 @@ void RunRight(); void Jump(); void IdleItUp(); + void Attack(); void Die(); void Draw(SDL_Surface*); void FrameMove(PVN_game*); + void AnimFinished(); }; #endif