Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
nagaik-project-1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Keigo Nagai
nagaik-project-1
Commits
1b55c470
Commit
1b55c470
authored
4 years ago
by
zlatax
Browse files
Options
Downloads
Patches
Plain Diff
everything runs without error
parent
ee4da0a7
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
project-1/src/Entity.java
+2
-7
2 additions, 7 deletions
project-1/src/Entity.java
project-1/src/ShadowTreasure.java
+14
-9
14 additions, 9 deletions
project-1/src/ShadowTreasure.java
with
16 additions
and
16 deletions
project-1/src/Entity.java
+
2
−
7
View file @
1b55c470
...
@@ -12,18 +12,13 @@ public class Entity {
...
@@ -12,18 +12,13 @@ public class Entity {
this
.
pos
=
pos
;
this
.
pos
=
pos
;
}
}
public
Image
getImg
()
{
public
Image
getImg
()
{
return
img
;
}
return
img
;
}
public
APoint
getPos
()
{
public
APoint
getPos
()
{
return
pos
;
return
pos
;
}
}
public
void
setPos
(
APoint
pos
)
{
public
void
setPos
(
APoint
pos
)
{
this
.
pos
=
pos
;
}
this
.
pos
=
pos
;
}
// @Override
// @Override
// public String toString() {
// public String toString() {
// }
// }
...
...
This diff is collapsed.
Click to expand it.
project-1/src/ShadowTreasure.java
+
14
−
9
View file @
1b55c470
...
@@ -100,24 +100,28 @@ public class ShadowTreasure extends AbstractGame {
...
@@ -100,24 +100,28 @@ public class ShadowTreasure extends AbstractGame {
bg
.
drawFromTopLeft
(
0
,
0
);
bg
.
drawFromTopLeft
(
0
,
0
);
deja
.
drawString
(
String
.
format
(
"energy: %d"
,
player
.
getEnergy
()),
20
,
760
);
deja
.
drawString
(
String
.
format
(
"energy: %d"
,
player
.
getEnergy
()),
20
,
760
);
if
(
count
>
10
)
{
if
(
count
==
10
)
{
APoint
playerPos
=
player
.
getPos
();
APoint
zombiePos
=
zombie
.
getPos
();
// Logic to update the game, as per specification must go here
// Logic to update the game, as per specification must go here
if
(
player
.
get
Pos
()
.
distanceTo
(
zombie
.
get
Pos
()
)
<
50
)
{
if
(
playerPos
.
distanceTo
(
zombiePos
)
<
50
)
{
player
.
addEnergy
(-
3
);
player
.
addEnergy
(-
3
);
System
.
exit
(
0
);
System
.
exit
(
0
);
}
else
if
(
sandwich
!=
null
&&
player
.
get
Pos
()
.
distanceTo
(
sandwich
.
getPos
())
<
50
)
{
}
else
if
(
sandwich
!=
null
&&
playerPos
.
distanceTo
(
sandwich
.
getPos
())
<
50
)
{
player
.
addEnergy
(
5
);
player
.
addEnergy
(
5
);
sandwich
=
null
;
sandwich
=
null
;
}
// after user reaches sandwich, the object does ot exist therefore we need to rethink ocndiiton
}
// after user reaches sandwich, the object does ot exist therefore we need to rethink ocndiiton
if
(
player
.
getEnergy
()
>=
3
)
{
if
(
player
.
getEnergy
()
>=
3
)
{
APoint
dir
=
player
.
get
Pos
()
.
getDirection
(
zombie
.
get
Pos
()
);
APoint
dir
=
playerPos
.
getDirection
(
zombiePos
);
player
.
get
Pos
()
.
setX
(
player
.
get
Pos
()
.
getX
()
+
dir
.
getX
()
*
player
.
getStepsize
());
playerPos
.
setX
(
playerPos
.
getX
()
+
dir
.
getX
()
*
player
.
getStepsize
());
player
.
get
Pos
()
.
setY
(
player
.
get
Pos
()
.
getY
()
+
dir
.
getY
()
*
player
.
getStepsize
());
playerPos
.
setY
(
playerPos
.
getY
()
+
dir
.
getY
()
*
player
.
getStepsize
());
}
else
{
}
else
{
APoint
dir
=
player
.
get
Pos
()
.
getDirection
(
sandwich
.
getPos
());
APoint
dir
=
playerPos
.
getDirection
(
sandwich
.
getPos
());
player
.
get
Pos
()
.
setX
(
player
.
get
Pos
()
.
getX
()
+
dir
.
getX
()
*
player
.
getStepsize
());
playerPos
.
setX
(
playerPos
.
getX
()
+
dir
.
getX
()
*
player
.
getStepsize
());
player
.
get
Pos
()
.
setY
(
player
.
get
Pos
()
.
getY
()
+
dir
.
getY
()
*
player
.
getStepsize
());
playerPos
.
setY
(
playerPos
.
getY
()
+
dir
.
getY
()
*
player
.
getStepsize
());
}
}
printInfo
(
playerPos
.
getX
(),
playerPos
.
getY
(),
player
.
getEnergy
());
count
=
0
;
count
=
0
;
}
}
count
++;
count
++;
...
@@ -137,6 +141,7 @@ public class ShadowTreasure extends AbstractGame {
...
@@ -137,6 +141,7 @@ public class ShadowTreasure extends AbstractGame {
}
}
// Removes
private
static
String
removeUTF8BOM
(
String
string
)
{
private
static
String
removeUTF8BOM
(
String
string
)
{
if
(
string
.
startsWith
(
UTF8_BOM
))
{
if
(
string
.
startsWith
(
UTF8_BOM
))
{
string
=
string
.
substring
(
1
);
string
=
string
.
substring
(
1
);
...
...
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