Skip to content

Commit

Permalink
Changed player bullets to be based on score and changed sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
Kandeel4411 committed Jul 31, 2019
1 parent 4696c7f commit 89fab0b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 8 deletions.
Binary file added assets/boss_loop.mp3
Binary file not shown.
Binary file modified invader.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion src/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void Menu::AudioNcolour()
std::string enemy_shooting_sound = ExePath()+"\\assets\\shot.mp3";
std::string player_shooting_sound = ExePath() + "\\assets\\player.mp3";
std::string intro1_sound = ExePath() + "\\assets\\loop.mp3";
std::string intro2_sound = ExePath() + "\\assets\\loop.mp3";
std::string intro2_sound = ExePath() + "\\assets\\boss_loop.mp3";
std::string b_death_sound = ExePath() + "\\assets\\boss.mp3";
std::string enemy_death_sound = ExePath() + "\\assets\\enemy.mp3";
std::string life_lost_sound = ExePath() + "\\assets\\life.mp3";
Expand Down
45 changes: 39 additions & 6 deletions src/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,57 @@ void Player::DrawPlayer(const std::vector<Fire>::iterator first, const std::vect
DrawShip1();
attroff(COLOR_PAIR(C_PLAYER));

DrawPlayerBullet(first, last);
}

void Player::DrawPlayerBullet(const std::vector<Fire>::iterator first, const std::vector<Fire>::iterator last)
{
attron(A_BOLD);
attron(COLOR_PAIR(C_PLAYER_FIRE));

// Set different bullets based on score
int score = Menu::settingsLevel[Invader::setLevel].score;
int bulletColor = -1;

if (score > 500)
bulletColor = RandInt(0, 3);
else
bulletColor = C_PLAYER_FIRE;

attron(COLOR_PAIR(bulletColor));

for (auto i = first; i < last; i++)
{
if (RandInt(0, 1) == 1)
{
if (score > 250)
{
mvaddch(i->x + 1, i->y, '|');
mvaddch(i->x, i->y, ACS_BLOCK);
}
else
{
mvaddch(i->x + 1, i->y, ' ');
mvaddch(i->x, i->y, '1');
}

mvaddch(i->x + 1, i->y, '|');
mvaddch(i->x, i->y, ACS_BLOCK);
}
else
{
mvaddch(i->x + 1, i->y, ' ');
mvaddch(i->x, i->y, ACS_DIAMOND);
if (score > 200)
{
mvaddch(i->x + 1, i->y, ' ');
mvaddch(i->x, i->y, ACS_DIAMOND);
}
else
{
mvaddch(i->x + 1, i->y, ' ');
mvaddch(i->x, i->y, '0');
}
}
}

attroff(A_BOLD);
attroff(COLOR_PAIR(C_PLAYER_FIRE));
attroff(bulletColor);
}

void Player::DrawShip1()
Expand Down
2 changes: 1 addition & 1 deletion src/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Player
int y;

static void DrawPlayer(const std::vector<Fire>::iterator first, const std::vector<Fire>::iterator last);

static void DrawPlayerBullet(const std::vector<Fire>::iterator first, const std::vector<Fire>::iterator last);
static void DrawShip1();

private:
Expand Down

0 comments on commit 89fab0b

Please sign in to comment.