Author: smiddy Date: Sun Apr 12 16:45:00 2009 New Revision: 313 Log: - fixed jumping bug - modified how far you get pushed back after a punch Modified: trunk/Debug/re-write.exe trunk/re-write.vcproj trunk/src/fight.cpp trunk/src/player.cpp Modified: trunk/Debug/re-write.exe ============================================================================== Binary file (source and/or target). No diff available. Modified: trunk/re-write.vcproj ============================================================================== --- trunk/re-write.vcproj Sat Apr 11 22:37:16 2009 (r312) +++ trunk/re-write.vcproj Sun Apr 12 16:45:00 2009 (r313) @@ -167,6 +167,10 @@ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > <File + RelativePath=".\ai.cpp" + > + </File> + <File RelativePath=".\src\credits.cpp" > </File> @@ -217,6 +221,10 @@ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > <File + RelativePath=".\ai.h" + > + </File> + <File RelativePath=".\src\common.h" > </File> Modified: trunk/src/fight.cpp ============================================================================== --- trunk/src/fight.cpp Sat Apr 11 22:37:16 2009 (r312) +++ trunk/src/fight.cpp Sun Apr 12 16:45:00 2009 (r313) @@ -1,242 +1,244 @@ -#include "fight.h" -#include "game.h" -#include "common.h" -#include "util.h" -#include "menu.h" - -PVN_fight::PVN_fight(PVN_game* game) : - player1(new Player(100,100,128,128,500,200)), - player2(new Player(600,100,128,128,500,200)), - PVN_state(game) -{ - for( int i = 0; i < 323; i++) keys_held[i] = false; - - background = Image_Load("../data/images/simple.png"); - if(background == NULL) { - //error! - } - - healthbar_p1 = new PVN_progressbar( - Image_Load("../data/images/tubereflectionssex.png"), - 0,0, - 360,80, - 0,0, - 100 - ); - - healthbar_p2 = new PVN_progressbar( - Image_Load("../data/images/tubereflectionssex.png"), - 0,0, - 360,80, - 360,0, - 100 - ); - healthbar_p2->direction = -1; - hasHit = false; -} - -PVN_fight::~PVN_fight() -{ - SDL_FreeSurface(background); - - delete player1; - delete player2; - delete healthbar_p1; - delete healthbar_p2; -} - -void PVN_fight::Init() -{ -} - -PVN_state* PVN_fight::Step() -{ - SDL_Event event; - - while( SDL_PollEvent(&event) ) - { - //game->Validate_Events(event); - - if( event.type == SDL_KEYDOWN ) - { - switch( event.key.keysym.sym ) - { - case SDLK_ESCAPE: return new PVN_menu(game); - /*********** - * Player 1 * - ***********/ - //movement - case SDLK_w: keys_held[SDLK_w] = true; break; - case SDLK_d: keys_held[SDLK_d] = true; break; - case SDLK_a: keys_held[SDLK_a] = true; break; - case SDLK_s: keys_held[SDLK_s] = true; break; - //actions - case SDLK_LCTRL: keys_held[SDLK_LCTRL] = true; break; - case SDLK_LSHIFT: keys_held[SDLK_LSHIFT] = true; break; - /*********** - * Player 2 * - ***********/ - //movement - case SDLK_UP: keys_held[SDLK_UP] = true; break; - case SDLK_DOWN: keys_held[SDLK_DOWN] = true; break; - case SDLK_LEFT: keys_held[SDLK_LEFT] = true; break; - case SDLK_RIGHT: keys_held[SDLK_RIGHT] = true; break; - //actions - case SDLK_RCTRL: keys_held[SDLK_RCTRL] = true; break; - case SDLK_RSHIFT: keys_held[SDLK_RSHIFT] = true; break; - } - } - else if( event.type == SDL_KEYUP ) - { - switch( event.key.keysym.sym ) - { - case SDLK_w: keys_held[SDLK_w] = false; break; - case SDLK_d: keys_held[SDLK_d] = false; break; - 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; - } - } - } - - Logic(); - - // draw - SDL_BlitSurface(background, NULL, game->screen_surface, NULL); - - player1->Draw(game->screen_surface); - player2->Draw(game->screen_surface); - healthbar_p1->Draw(SDL_GetVideoSurface()); - healthbar_p2->Draw(SDL_GetVideoSurface()); - - return this; -} - -void PVN_fight::Logic() -{ - if( player1->dead == false ) - { - 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_LCTRL] == true ) player1->Attack(); - - if( (keys_held[SDLK_d] == false) && - (keys_held[SDLK_a] == false) && - (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_RCTRL] == true ) player2->Attack(); - - if( (keys_held[SDLK_RIGHT] == false) && - (keys_held[SDLK_LEFT] == false) && - (keys_held[SDLK_UP] == false) && - (keys_held[SDLK_RCTRL] == false)) player2->IdleItUp(); - } - - if( Check_Collision(player1->hitbox_body, player2->hitbox_body) == true && - player1->dead == false && - player2->dead == false ) - { - if (player1->xPos < player2->xPos) - { - if (keys_held[SDLK_a] == true) - { - player1->RunLeft(); - } else { - player1->xVel = 0; - } - if (keys_held[SDLK_RIGHT] == true) - { - player2->RunRight(); - } else { - player2->xVel = 0; - } - } else { - if (keys_held[SDLK_d] == true) - { - player1->RunRight(); - } else { - player1->xVel = 0; - } - if (keys_held[SDLK_LEFT] == true) - { - player2->RunLeft(); - } else { - player2->xVel = 0; - } - - } - - } - if( Check_Collision(player1->hitbox_punch, player2->hitbox_body) == true) - { +#include "fight.h" +#include "game.h" +#include "common.h" +#include "util.h" +#include "menu.h" + +PVN_fight::PVN_fight(PVN_game* game) : + player1(new Player(100,100,128,128,500,200)), + player2(new Player(600,100,128,128,500,200)), + PVN_state(game) +{ + for( int i = 0; i < 323; i++) keys_held[i] = false; + + background = Image_Load("../data/images/simple.png"); + if(background == NULL) { + //error! + } + + healthbar_p1 = new PVN_progressbar( + Image_Load("../data/images/tubereflectionssex.png"), + 0,0, + 360,80, + 0,0, + 100 + ); + + healthbar_p2 = new PVN_progressbar( + Image_Load("../data/images/tubereflectionssex.png"), + 0,0, + 360,80, + 360,0, + 100 + ); + healthbar_p2->direction = -1; + hasHit = false; +} + +PVN_fight::~PVN_fight() +{ + SDL_FreeSurface(background); + + delete player1; + delete player2; + delete healthbar_p1; + delete healthbar_p2; +} + +void PVN_fight::Init() +{ +} + +PVN_state* PVN_fight::Step() +{ + SDL_Event event; + + while( SDL_PollEvent(&event) ) + { + //game->Validate_Events(event); + + if( event.type == SDL_KEYDOWN ) + { + switch( event.key.keysym.sym ) + { + case SDLK_ESCAPE: return new PVN_menu(game); + /*********** + * Player 1 * + ***********/ + //movement + case SDLK_w: keys_held[SDLK_w] = true; break; + case SDLK_d: keys_held[SDLK_d] = true; break; + case SDLK_a: keys_held[SDLK_a] = true; break; + case SDLK_s: keys_held[SDLK_s] = true; break; + //actions + case SDLK_LCTRL: keys_held[SDLK_LCTRL] = true; break; + case SDLK_LSHIFT: keys_held[SDLK_LSHIFT] = true; break; + /*********** + * Player 2 * + ***********/ + //movement + case SDLK_UP: keys_held[SDLK_UP] = true; break; + case SDLK_DOWN: keys_held[SDLK_DOWN] = true; break; + case SDLK_LEFT: keys_held[SDLK_LEFT] = true; break; + case SDLK_RIGHT: keys_held[SDLK_RIGHT] = true; break; + //actions + case SDLK_RCTRL: keys_held[SDLK_RCTRL] = true; break; + case SDLK_RSHIFT: keys_held[SDLK_RSHIFT] = true; break; + } + } + else if( event.type == SDL_KEYUP ) + { + switch( event.key.keysym.sym ) + { + case SDLK_w: keys_held[SDLK_w] = false; break; + case SDLK_d: keys_held[SDLK_d] = false; break; + 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; + } + } + } + + Logic(); + + // draw + SDL_BlitSurface(background, NULL, game->screen_surface, NULL); + + player1->Draw(game->screen_surface); + player2->Draw(game->screen_surface); + healthbar_p1->Draw(SDL_GetVideoSurface()); + healthbar_p2->Draw(SDL_GetVideoSurface()); + + return this; +} + +void PVN_fight::Logic() +{ + if( player1->dead == false ) + { + 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_LCTRL] == true ) player1->Attack(); + + if( (keys_held[SDLK_d] == false) && + (keys_held[SDLK_a] == false) && + (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_RCTRL] == true ) player2->Attack(); + + if( (keys_held[SDLK_RIGHT] == false) && + (keys_held[SDLK_LEFT] == false) && + (keys_held[SDLK_UP] == false) && + (keys_held[SDLK_RCTRL] == false)) player2->IdleItUp(); + } + + if( Check_Collision(player1->hitbox_body, player2->hitbox_body) == true && + player1->dead == false && + player2->dead == false ) + { + if (player1->xPos < player2->xPos) + { + if (keys_held[SDLK_a] == true) + { + player1->RunLeft(); + } else { + player1->xVel = 0; + } + if (keys_held[SDLK_RIGHT] == true) + { + player2->RunRight(); + } else { + player2->xVel = 0; + } + } else { + if (keys_held[SDLK_d] == true) + { + player1->RunRight(); + } else { + player1->xVel = 0; + } + if (keys_held[SDLK_LEFT] == true) + { + player2->RunLeft(); + } else { + player2->xVel = 0; + } + + } + + } + if( Check_Collision(player1->hitbox_punch, player2->hitbox_body) == true) + { player2->health -= 10; - healthbar_p2->Sub(10); - if (player1->xPos < player2->xPos) - { - player2->xVel = 20; - } else { - player2->xVel = -20; - } - if (player2->health <=0) - { - player2->Die(); - deathclock = SDL_GetTicks() + 5000; - } - - } - - if( Check_Collision(player2->hitbox_punch, player1->hitbox_body) == true) - { + healthbar_p2->Sub(10); + player2->yVel = 100; + if (player1->xPos < player2->xPos) + { + player2->xVel = 200; + } else { + player2->xVel = -200; + } + if (player2->health <=0) + { + player2->Die(); + deathclock = SDL_GetTicks() + 5000; + } + + } + + if( Check_Collision(player2->hitbox_punch, player1->hitbox_body) == true) + { player1->health -= 10; - healthbar_p1->Sub(10); - if (player2->xPos < player1->xPos) - { - player1->xVel = 20; - } else { - player1->xVel = -20; - } - if (player1->health <=0) - { - player1->Die(); - deathclock = SDL_GetTicks() + 5000; - } - - } - - player1->hitbox_punch.x = -500; - player2->hitbox_punch.x = 1000; - - player1->FrameMove(game); - player2->FrameMove(game); - - if (player1->dead == 2 || player2->dead == 2) - { - if (SDL_GetTicks() >= deathclock) - { + healthbar_p1->Sub(10); + player1->yVel = 100; + if (player2->xPos < player1->xPos) + { + player1->xVel = 200; + } else { + player1->xVel = -200; + } + if (player1->health <=0) + { + player1->Die(); + deathclock = SDL_GetTicks() + 5000; + } + + } + + player1->hitbox_punch.x = -500; + player2->hitbox_punch.x = 1000; + + player1->FrameMove(game); + player2->FrameMove(game); + + if (player1->dead == 2 || player2->dead == 2) + { + if (SDL_GetTicks() >= deathclock) + { SDL_Event event; event.type = SDL_KEYDOWN; event.key.keysym.sym = SDLK_ESCAPE; - SDL_PushEvent(&event); - } - } - -} - + SDL_PushEvent(&event); + } + } + +} + Modified: trunk/src/player.cpp ============================================================================== --- trunk/src/player.cpp Sat Apr 11 22:37:16 2009 (r312) +++ trunk/src/player.cpp Sun Apr 12 16:45:00 2009 (r313) @@ -31,6 +31,7 @@ Player::~Player() { delete anim_idle; + delete anim_idle_run; delete anim_run; delete anim_jump; delete anim_punch; @@ -99,7 +100,7 @@ else currentAnimation = anim_jump; jumping = 1; } - if (jumping == 1 && currentAnimation->cframe >= 8){ + if (jumping == 1 && currentAnimation->cframe >= 7){ yVel = jumpPower; jumping = 2; } @@ -191,6 +192,7 @@ jumping = 3; currentAnimation->Change_Frame(9); } + if (jumping == 1) Jump(); } if( xPos >= 680 ) {