From f2f4c435451547155dcc52eaa35dd90358743613 Mon Sep 17 00:00:00 2001 From: Rtch90 Date: Thu, 2 Feb 2012 22:30:47 +0000 Subject: [PATCH] [Remove] Darn annoying test speach bubble!! -- Ima get back to work on pathfinding. --- src/Unuk/Player.cpp | 196 ++++++++++++++++++++++---------------------- 1 file changed, 98 insertions(+), 98 deletions(-) diff --git a/src/Unuk/Player.cpp b/src/Unuk/Player.cpp index c8cb468..f121916 100644 --- a/src/Unuk/Player.cpp +++ b/src/Unuk/Player.cpp @@ -7,21 +7,21 @@ const float Player::PLAYER_SPEED = Character::CHARACTER_SPEED + 0.5f; // Amount of Exp needed every level const int Player::EXP_TABLE[10] = { - 10, - 30, - 90, - 150, - 300, - 512, - 1000, - 2000, - 3500, - 5000 + 10, + 30, + 90, + 150, + 300, + 512, + 1000, + 2000, + 3500, + 5000 }; Player::Player(LevelGen *mapArg) : Character(mapArg) { - _level = 1; - _exp = 0; + _level = 1; + _exp = 0; } Player::~Player(void) { @@ -29,112 +29,112 @@ Player::~Player(void) { } void Player::HandleInput(void) { - if(event.key.type == SDL_KEYDOWN) { - switch(event.key.keysym.sym) { - case SDLK_w: - case SDLK_UP: - yVel -= PLAYER_SPEED; - xVel = 0; - directionFacing = FACING_UP; - break; - case SDLK_s: - case SDLK_DOWN: - yVel += PLAYER_SPEED; - xVel = 0; - directionFacing = FACING_DOWN; - break; - case SDLK_a: - case SDLK_LEFT: - xVel -= PLAYER_SPEED; - yVel = 0; - directionFacing = FACING_LEFT; - break; - case SDLK_d: - case SDLK_RIGHT: - xVel += PLAYER_SPEED; - yVel = 0; - directionFacing = FACING_RIGHT; - break; - case SDLK_SPACE: - attacking = true; - attackTimer.Start(); - map->GetWorld().OnPlayerAttack(this); - break; - default: - break; - } - } - else if(event.key.type == SDL_KEYUP) { - switch(event.key.keysym.sym) { - case SDLK_w: case SDLK_UP: yVel = 0; break; - case SDLK_s: case SDLK_DOWN: yVel = 0; break; - case SDLK_a: case SDLK_LEFT: xVel = 0; break; - case SDLK_d: case SDLK_RIGHT: xVel = 0; break; - default: break; - } - } - else if(event.type == SDL_MOUSEBUTTONDOWN) { - if(event.button.button == SDL_BUTTON_LEFT) { - attacking = true; - attackTimer.Start(); - map->GetWorld().OnPlayerAttack(this); - } - } + if(event.key.type == SDL_KEYDOWN) { + switch(event.key.keysym.sym) { + case SDLK_w: + case SDLK_UP: + yVel -= PLAYER_SPEED; + xVel = 0; + directionFacing = FACING_UP; + break; + case SDLK_s: + case SDLK_DOWN: + yVel += PLAYER_SPEED; + xVel = 0; + directionFacing = FACING_DOWN; + break; + case SDLK_a: + case SDLK_LEFT: + xVel -= PLAYER_SPEED; + yVel = 0; + directionFacing = FACING_LEFT; + break; + case SDLK_d: + case SDLK_RIGHT: + xVel += PLAYER_SPEED; + yVel = 0; + directionFacing = FACING_RIGHT; + break; + case SDLK_SPACE: + attacking = true; + attackTimer.Start(); + map->GetWorld().OnPlayerAttack(this); + break; + default: + break; + } + } + else if(event.key.type == SDL_KEYUP) { + switch(event.key.keysym.sym) { + case SDLK_w: case SDLK_UP: yVel = 0; break; + case SDLK_s: case SDLK_DOWN: yVel = 0; break; + case SDLK_a: case SDLK_LEFT: xVel = 0; break; + case SDLK_d: case SDLK_RIGHT: xVel = 0; break; + default: break; + } + } + else if(event.type == SDL_MOUSEBUTTONDOWN) { + if(event.button.button == SDL_BUTTON_LEFT) { + attacking = true; + attackTimer.Start(); + map->GetWorld().OnPlayerAttack(this); + } + } } void Player::Update(void) { - Move(); - AddSpeachBubble("Woot, My name is Allanis, welcome to my home. Just testing some more text to see if this works.."); + Move(); + //AddSpeachBubble("Woot, My name is Allanis, welcome to my home. Just testing some more text to see if this works.."); - // For now The camera will be static. - //SetCamera(); + // For now The camera will be static. + //SetCamera(); - _healthBar.SetProgress((float)GetHealth() / 100.0f); + _healthBar.SetProgress((float)GetHealth() / 100.0f); } void Player::SetName(string nameArg) { - _name = nameArg; + _name = nameArg; } void Player::SetCamera(void) { - camera.x = (Sint16)((x + w / 2) - SCREEN_WIDTH / 2); - camera.y = (Sint16)((y + h / 2) - SCREEN_HEIGHT / 2); + camera.x = (Sint16)((x + w / 2) - SCREEN_WIDTH / 2); + camera.y = (Sint16)((y + h / 2) - SCREEN_HEIGHT / 2); - if(camera.x < 0) - camera.x = 0; - if(camera.y < 0) - camera.y = 0; + if(camera.x < 0) + camera.x = 0; + if(camera.y < 0) + camera.y = 0; - if(camera.x > levelWidth - camera.w) - camera.x = levelWidth - camera.w; - if(camera.y > levelHeight - camera.h) - camera.y = levelHeight = camera.h; + if(camera.x > levelWidth - camera.w) + camera.x = levelWidth - camera.w; + if(camera.y > levelHeight - camera.h) + camera.y = levelHeight = camera.h; } void Player::Move() { - Character::Move(); - if(map->GetMapTransitionName(tileX, tileY) != "null") { - SetXY((float)map->GetMapTransitionX(tileX, tileY), (float)map->GetMapTransitionY(tileX, tileY)); - map->Load(map->GetMapTransitionName(tileX, tileY)); - } + Character::Move(); + if(map->GetMapTransitionName(tileX, tileY) != "null") { + SetXY((float)map->GetMapTransitionX(tileX, tileY), (float)map->GetMapTransitionY(tileX, tileY)); + map->Load(map->GetMapTransitionName(tileX, tileY)); + } } void Player::SetLevel(int level) { - _level = level; - _exp = _exp - EXP_TABLE[level]; - if(_exp < 0) { - _exp = 0; - } + _level = level; + _exp = _exp - EXP_TABLE[level]; + if(_exp < 0) { + _exp = 0; + } } void Player::SetExp(int exp) { - std::stringstream evtMsg; - evtMsg << "Gained " << (exp - _exp) << " Experience Points."; - eventHistory->LogEvent(evtMsg.str()); - - _exp = exp; - if(_level != MAX_LEVEL && _exp >= EXP_TABLE[_level]) { - eventHistory->LogEvent("Player leveled up!"); - SetLevel(_level + 1); - } + std::stringstream evtMsg; + evtMsg << "Gained " << (exp - _exp) << " Experience Points."; + eventHistory->LogEvent(evtMsg.str()); + + _exp = exp; + if(_level != MAX_LEVEL && _exp >= EXP_TABLE[_level]) { + eventHistory->LogEvent("Player leveled up!"); + SetLevel(_level + 1); + } }