Skip to content
Snippets Groups Projects
Commit 290d9c50 authored by Jake Feddersen's avatar Jake Feddersen
Browse files

Fix ship health

parent 606743f4
Branches master
No related tags found
No related merge requests found
......@@ -218,7 +218,7 @@ void board::draw() {
}
for (int i = 0; i < 5; i++) {
ships[i]->print_ship(x_offset, 16+i);
ships[i]->print_ship(x_offset, 16+i, side);
}
refresh();
......@@ -263,7 +263,7 @@ void board::draw_game_over() {
}
for (int i = 0; i < 5; i++) {
ships[i]->print_ship(x_offset, 16+i);
ships[i]->print_ship(x_offset, 16+i, side);
}
refresh();
......
......@@ -46,7 +46,7 @@ int ship::get_dir() {
return dir;
}
void ship::print_ship(int x, int y) {
void ship::print_ship(int x, int y, int side) {
if (is_sunk()) {
attron(COLOR_PAIR(TEXT_RED));
} else {
......@@ -61,6 +61,8 @@ void ship::print_ship(int x, int y) {
attroff(COLOR_PAIR(TEXT_WHITE));
}
if (side==SHIP_OPPONENT) return;
attron(COLOR_PAIR(TEXT_GREEN));
for (int i = maxHP; i > (maxHP - HP); i--) {
mvaddch(y, x+23-i, '*');
......
#ifndef SHIP_H
#define SHIP_H
#define SHIP_PLAYER 0
#define SHIP_OPPONENT 1
#include <ncurses.h>
#include <string>
......@@ -31,7 +34,7 @@ public:
int get_y();
int get_dir();
void print_ship(int x, int y);
void print_ship(int x, int y, int side);
};
#endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment