Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
COMS327
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jake Feddersen
COMS327
Commits
290d9c50
Commit
290d9c50
authored
5 years ago
by
Jake Feddersen
Browse files
Options
Downloads
Patches
Plain Diff
Fix ship health
parent
606743f4
Branches
master
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
feddersen_jacob.assignment-2/board.cpp
+2
-2
2 additions, 2 deletions
feddersen_jacob.assignment-2/board.cpp
feddersen_jacob.assignment-2/ship.cpp
+3
-1
3 additions, 1 deletion
feddersen_jacob.assignment-2/ship.cpp
feddersen_jacob.assignment-2/ship.h
+4
-1
4 additions, 1 deletion
feddersen_jacob.assignment-2/ship.h
with
9 additions
and
4 deletions
feddersen_jacob.assignment-2/board.cpp
+
2
−
2
View file @
290d9c50
...
...
@@ -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
();
...
...
This diff is collapsed.
Click to expand it.
feddersen_jacob.assignment-2/ship.cpp
+
3
−
1
View file @
290d9c50
...
...
@@ -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
,
'*'
);
...
...
This diff is collapsed.
Click to expand it.
feddersen_jacob.assignment-2/ship.h
+
4
−
1
View file @
290d9c50
#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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment