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
554f701b
Commit
554f701b
authored
5 years ago
by
Jake Feddersen
Browse files
Options
Downloads
Patches
Plain Diff
Better picking up of objects
parent
85f8c314
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
feddersen_jacob.assignment-1.09/character.cpp
+16
-6
16 additions, 6 deletions
feddersen_jacob.assignment-1.09/character.cpp
feddersen_jacob.assignment-1.09/dungeon.h
+1
-1
1 addition, 1 deletion
feddersen_jacob.assignment-1.09/dungeon.h
with
17 additions
and
7 deletions
feddersen_jacob.assignment-1.09/character.cpp
+
16
−
6
View file @
554f701b
...
...
@@ -252,14 +252,15 @@ int player_character::pick_up(std::vector<item *> &floor) {
if
(
floor
.
size
()
==
0
)
{
mvaddstr
(
7
,
(
80
-
strlen
(
pickup_no_items
))
/
2
,
pickup_no_items
);
}
else
{
int
missing_top
=
std
::
max
(
0
,
k
-
2
);
int
top
=
std
::
max
(
0
,
k
-
2
);
top
=
std
::
min
(
top
,
std
::
max
(
0
,
(
int
)
floor
.
size
()
-
5
));
int
bottom
=
std
::
min
((
int
)
floor
.
size
()
-
1
,
top
+
4
);
int
missing_top
=
top
;
if
(
missing_top
>
0
)
{
mvprintw
(
7
,
38
,
"(+%d)"
,
missing_top
);
}
int
top
=
std
::
max
(
0
,
k
-
2
);
int
bottom
=
std
::
min
((
int
)
floor
.
size
()
-
1
,
top
+
5
);
int
missing_bottom
=
floor
.
size
()
-
1
-
bottom
;
if
(
missing_bottom
>
0
)
{
mvprintw
(
19
,
38
,
"(+%d)"
,
missing_bottom
);
...
...
@@ -278,7 +279,7 @@ int player_character::pick_up(std::vector<item *> &floor) {
}
}
char
c
=
getch
();
int
c
=
getch
();
if
(
c
==
'q'
||
c
==
'Q'
)
{
shouldExit
=
1
;
...
...
@@ -300,7 +301,16 @@ int player_character::pick_up(std::vector<item *> &floor) {
}
if
(
c
==
','
)
{
for
(
i
=
0
;
i
<
for
(
i
=
0
;
i
<
10
;
i
++
)
{
if
(
!
inventory
[
i
])
{
inventory
[
i
]
=
floor
[
k
];
floor
.
erase
(
floor
.
begin
()
+
k
);
break
;
}
}
break
;
}
}
return
shouldExit
;
...
...
This diff is collapsed.
Click to expand it.
feddersen_jacob.assignment-1.09/dungeon.h
+
1
−
1
View file @
554f701b
...
...
@@ -14,7 +14,7 @@
#define MAX_ROOMS 12
#define MIN_ROOMS 6
#define ITEMS_PER_LEVEL
15
#define ITEMS_PER_LEVEL
2000
class
character
;
...
...
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