Skip to content

Commit

Permalink
Tuned difficulty of the enemy attacks
Browse files Browse the repository at this point in the history
Formated text on join screen.
  • Loading branch information
hardhat committed Jan 26, 2019
1 parent 690f9f3 commit 78d1368
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 9 deletions.
14 changes: 12 additions & 2 deletions actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ void Actor::update(int elapsed)
Bullet *b=*p;
if(b->isActive()) {
bulletList.push_back(b);
} else {
b->target->receiveAttack(b->damage,b->attackType);
} else {
if(b->target->attackInRange(b)) {
b->target->receiveAttack(b->damage,b->attackType);
}
delete b; // all done.
}
}
Expand Down Expand Up @@ -197,6 +199,14 @@ void Actor::receiveAttack(int amount, AttackType type) {
sound.playOnce(SFX_HAH);
noticeList.push_back(new Notice(sx,sy,"Blocked"));
}
}

bool Actor::attackInRange(Bullet *b)
{
float dx=b->x-(this->tx*tile->tileWidth);
float dy=b->y-(this->ty*tile->tileHeight);

return dx*dx+dy*dy<24*24;
}

void Actor::block(AttackType type) {
Expand Down
1 change: 1 addition & 0 deletions actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Actor {
bool isAttackReady();
void attack(Actor *target,bool heavy);
void receiveAttack(int amount, AttackType type);
bool attackInRange(Bullet *b);
void block(AttackType type);
void enemyAttack();
};
Expand Down
Binary file added data/fireball.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/force.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ Player *Game::targetPlayer(Actor *enemy)
dx=player->tx-enemy->tx;
dy=player->ty-enemy->ty;
closestDist=dx*dx+dy*dy;
if(dist>8*8) continue;
if(closestDist>8*8) continue;
closest=player;
continue;
}
Expand All @@ -339,7 +339,7 @@ Player *Game::targetPlayer(Actor *enemy)
dx=player->tx-enemy->tx;
dy=player->ty-enemy->ty;
dist=dx*dx+dy*dy;
if(dist>8*8) continue;
if(dist>6*6) continue;
if(dist<closestDist) {
closest=player;
closestDist=dist;
Expand Down
4 changes: 2 additions & 2 deletions join.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ void Join::draw()
{
maptop=0;

drawMessage(FONT_HEADLINE,"Select your player",10,-4);
drawMessage(FONT_LABEL,"Left and right then hit A",10,32);
drawMessage(FONT_HEADLINE,"Select your player",10,-8);
drawMessage(FONT_NOTICE,"Left and right then hit A",10,30);

for(int i=0;i<6;i++) {
char buffer[256];
Expand Down
7 changes: 4 additions & 3 deletions player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ void Player::handleAction(int id,bool down)
else if(id==DPAD_DOWN && down && ty<118) y++;
else if(id==DPAD_A) {
Actor *target=game.targetEnemy(this);
if(target) attack(target,false);
if(target) attack(target,true);
}
else if(id==DPAD_B) {
Actor *target=game.targetEnemy(this);
if(target) attack(target,true);
//Actor *target=game.targetEnemy(this);
//if(target) attack(target,true);
block(AT_FORCE);
}

if(x!=tx || y!=ty) {
Expand Down

0 comments on commit 78d1368

Please sign in to comment.