Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
J
JIAXI3-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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jiaxi liu
JIAXI3-project-1
Commits
e70bd79b
Commit
e70bd79b
authored
Aug 30, 2022
by
jiaxi liu
Browse files
Options
Downloads
Patches
Plain Diff
1. Complete the start screen.
2. Complete the CSV reading. 3. Complete the player display.
parent
3898fcad
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Player.java
+52
-0
52 additions, 0 deletions
src/Player.java
with
52 additions
and
0 deletions
src/Player.java
0 → 100644
+
52
−
0
View file @
e70bd79b
import
bagel.DrawOptions
;
import
bagel.Font
;
import
bagel.Image
;
public
class
Player
{
public
int
X
=
0
;
public
int
Y
=
0
;
private
final
static
Image
FaceLeftImage
=
new
Image
(
"res/faeLeft.png"
);
private
final
static
Image
FaceRightImage
=
new
Image
(
"res/faeRight.png"
);
private
static
int
Life
=
100
;
private
static
Image
Img
;
private
final
Font
LifeFont
=
new
Font
(
"res/frostbite.ttf"
,
30
);
private
final
DrawOptions
LifeHighColor
=
new
DrawOptions
();
private
final
DrawOptions
LifeMidColor
=
new
DrawOptions
();
private
final
DrawOptions
LifeLowColor
=
new
DrawOptions
();
public
Player
()
{
/*Init player image*/
Img
=
FaceRightImage
;
/*Init life color*/
LifeHighColor
.
setBlendColour
(
0
,
0.8
,
0.2
);
LifeMidColor
.
setBlendColour
(
0.9
,
0.6
,
0
);
LifeLowColor
.
setBlendColour
(
1
,
0
,
0
);
}
public
void
Update
()
{
/*Show play image*/
Img
.
drawFromTopLeft
(
X
,
Y
);
/*Show life text*/
if
(
Life
>=
65
)
{
LifeFont
.
drawString
(
Life
+
"%"
,
20
,
25
,
LifeHighColor
);
}
else
if
(
Life
>=
35
)
{
LifeFont
.
drawString
(
Life
+
"%"
,
20
,
25
,
LifeMidColor
);
}
else
{
LifeFont
.
drawString
(
Life
+
"%"
,
20
,
25
,
LifeLowColor
);
}
}
public
void
ToLeft
()
{
/*Changing user orientation to left*/
Img
=
FaceLeftImage
;
}
public
void
ToRight
()
{
/*Changing user orientation to right*/
Img
=
FaceRightImage
;
}
}
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