[Remove] Darn annoying test speach bubble!!
-- Ima get back to work on pathfinding.
This commit is contained in:
parent
7f9426acbc
commit
f2f4c43545
@ -7,21 +7,21 @@ const float Player::PLAYER_SPEED = Character::CHARACTER_SPEED + 0.5f;
|
|||||||
|
|
||||||
// Amount of Exp needed every level
|
// Amount of Exp needed every level
|
||||||
const int Player::EXP_TABLE[10] = {
|
const int Player::EXP_TABLE[10] = {
|
||||||
10,
|
10,
|
||||||
30,
|
30,
|
||||||
90,
|
90,
|
||||||
150,
|
150,
|
||||||
300,
|
300,
|
||||||
512,
|
512,
|
||||||
1000,
|
1000,
|
||||||
2000,
|
2000,
|
||||||
3500,
|
3500,
|
||||||
5000
|
5000
|
||||||
};
|
};
|
||||||
|
|
||||||
Player::Player(LevelGen *mapArg) : Character(mapArg) {
|
Player::Player(LevelGen *mapArg) : Character(mapArg) {
|
||||||
_level = 1;
|
_level = 1;
|
||||||
_exp = 0;
|
_exp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::~Player(void) {
|
Player::~Player(void) {
|
||||||
@ -29,112 +29,112 @@ Player::~Player(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Player::HandleInput(void) {
|
void Player::HandleInput(void) {
|
||||||
if(event.key.type == SDL_KEYDOWN) {
|
if(event.key.type == SDL_KEYDOWN) {
|
||||||
switch(event.key.keysym.sym) {
|
switch(event.key.keysym.sym) {
|
||||||
case SDLK_w:
|
case SDLK_w:
|
||||||
case SDLK_UP:
|
case SDLK_UP:
|
||||||
yVel -= PLAYER_SPEED;
|
yVel -= PLAYER_SPEED;
|
||||||
xVel = 0;
|
xVel = 0;
|
||||||
directionFacing = FACING_UP;
|
directionFacing = FACING_UP;
|
||||||
break;
|
break;
|
||||||
case SDLK_s:
|
case SDLK_s:
|
||||||
case SDLK_DOWN:
|
case SDLK_DOWN:
|
||||||
yVel += PLAYER_SPEED;
|
yVel += PLAYER_SPEED;
|
||||||
xVel = 0;
|
xVel = 0;
|
||||||
directionFacing = FACING_DOWN;
|
directionFacing = FACING_DOWN;
|
||||||
break;
|
break;
|
||||||
case SDLK_a:
|
case SDLK_a:
|
||||||
case SDLK_LEFT:
|
case SDLK_LEFT:
|
||||||
xVel -= PLAYER_SPEED;
|
xVel -= PLAYER_SPEED;
|
||||||
yVel = 0;
|
yVel = 0;
|
||||||
directionFacing = FACING_LEFT;
|
directionFacing = FACING_LEFT;
|
||||||
break;
|
break;
|
||||||
case SDLK_d:
|
case SDLK_d:
|
||||||
case SDLK_RIGHT:
|
case SDLK_RIGHT:
|
||||||
xVel += PLAYER_SPEED;
|
xVel += PLAYER_SPEED;
|
||||||
yVel = 0;
|
yVel = 0;
|
||||||
directionFacing = FACING_RIGHT;
|
directionFacing = FACING_RIGHT;
|
||||||
break;
|
break;
|
||||||
case SDLK_SPACE:
|
case SDLK_SPACE:
|
||||||
attacking = true;
|
attacking = true;
|
||||||
attackTimer.Start();
|
attackTimer.Start();
|
||||||
map->GetWorld().OnPlayerAttack(this);
|
map->GetWorld().OnPlayerAttack(this);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(event.key.type == SDL_KEYUP) {
|
else if(event.key.type == SDL_KEYUP) {
|
||||||
switch(event.key.keysym.sym) {
|
switch(event.key.keysym.sym) {
|
||||||
case SDLK_w: case SDLK_UP: yVel = 0; break;
|
case SDLK_w: case SDLK_UP: yVel = 0; break;
|
||||||
case SDLK_s: case SDLK_DOWN: yVel = 0; break;
|
case SDLK_s: case SDLK_DOWN: yVel = 0; break;
|
||||||
case SDLK_a: case SDLK_LEFT: xVel = 0; break;
|
case SDLK_a: case SDLK_LEFT: xVel = 0; break;
|
||||||
case SDLK_d: case SDLK_RIGHT: xVel = 0; break;
|
case SDLK_d: case SDLK_RIGHT: xVel = 0; break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(event.type == SDL_MOUSEBUTTONDOWN) {
|
else if(event.type == SDL_MOUSEBUTTONDOWN) {
|
||||||
if(event.button.button == SDL_BUTTON_LEFT) {
|
if(event.button.button == SDL_BUTTON_LEFT) {
|
||||||
attacking = true;
|
attacking = true;
|
||||||
attackTimer.Start();
|
attackTimer.Start();
|
||||||
map->GetWorld().OnPlayerAttack(this);
|
map->GetWorld().OnPlayerAttack(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Update(void) {
|
void Player::Update(void) {
|
||||||
Move();
|
Move();
|
||||||
AddSpeachBubble("Woot, My name is Allanis, welcome to my home. Just testing some more text to see if this works..");
|
//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.
|
// For now The camera will be static.
|
||||||
//SetCamera();
|
//SetCamera();
|
||||||
|
|
||||||
_healthBar.SetProgress((float)GetHealth() / 100.0f);
|
_healthBar.SetProgress((float)GetHealth() / 100.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SetName(string nameArg) {
|
void Player::SetName(string nameArg) {
|
||||||
_name = nameArg;
|
_name = nameArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SetCamera(void) {
|
void Player::SetCamera(void) {
|
||||||
camera.x = (Sint16)((x + w / 2) - SCREEN_WIDTH / 2);
|
camera.x = (Sint16)((x + w / 2) - SCREEN_WIDTH / 2);
|
||||||
camera.y = (Sint16)((y + h / 2) - SCREEN_HEIGHT / 2);
|
camera.y = (Sint16)((y + h / 2) - SCREEN_HEIGHT / 2);
|
||||||
|
|
||||||
if(camera.x < 0)
|
if(camera.x < 0)
|
||||||
camera.x = 0;
|
camera.x = 0;
|
||||||
if(camera.y < 0)
|
if(camera.y < 0)
|
||||||
camera.y = 0;
|
camera.y = 0;
|
||||||
|
|
||||||
if(camera.x > levelWidth - camera.w)
|
if(camera.x > levelWidth - camera.w)
|
||||||
camera.x = levelWidth - camera.w;
|
camera.x = levelWidth - camera.w;
|
||||||
if(camera.y > levelHeight - camera.h)
|
if(camera.y > levelHeight - camera.h)
|
||||||
camera.y = levelHeight = camera.h;
|
camera.y = levelHeight = camera.h;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Move() {
|
void Player::Move() {
|
||||||
Character::Move();
|
Character::Move();
|
||||||
if(map->GetMapTransitionName(tileX, tileY) != "null") {
|
if(map->GetMapTransitionName(tileX, tileY) != "null") {
|
||||||
SetXY((float)map->GetMapTransitionX(tileX, tileY), (float)map->GetMapTransitionY(tileX, tileY));
|
SetXY((float)map->GetMapTransitionX(tileX, tileY), (float)map->GetMapTransitionY(tileX, tileY));
|
||||||
map->Load(map->GetMapTransitionName(tileX, tileY));
|
map->Load(map->GetMapTransitionName(tileX, tileY));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SetLevel(int level) {
|
void Player::SetLevel(int level) {
|
||||||
_level = level;
|
_level = level;
|
||||||
_exp = _exp - EXP_TABLE[level];
|
_exp = _exp - EXP_TABLE[level];
|
||||||
if(_exp < 0) {
|
if(_exp < 0) {
|
||||||
_exp = 0;
|
_exp = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SetExp(int exp) {
|
void Player::SetExp(int exp) {
|
||||||
std::stringstream evtMsg;
|
std::stringstream evtMsg;
|
||||||
evtMsg << "Gained " << (exp - _exp) << " Experience Points.";
|
evtMsg << "Gained " << (exp - _exp) << " Experience Points.";
|
||||||
eventHistory->LogEvent(evtMsg.str());
|
eventHistory->LogEvent(evtMsg.str());
|
||||||
|
|
||||||
_exp = exp;
|
_exp = exp;
|
||||||
if(_level != MAX_LEVEL && _exp >= EXP_TABLE[_level]) {
|
if(_level != MAX_LEVEL && _exp >= EXP_TABLE[_level]) {
|
||||||
eventHistory->LogEvent("Player leveled up!");
|
eventHistory->LogEvent("Player leveled up!");
|
||||||
SetLevel(_level + 1);
|
SetLevel(_level + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user