Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TDT4240 Tank Wars
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
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
Snorre Skjellestad Kristiansen
TDT4240 Tank Wars
Commits
27ecfd44
Commit
27ecfd44
authored
2 years ago
by
Magnus Segtnan Skjølberg
Browse files
Options
Downloads
Patches
Plain Diff
(
#18
): create hud for gameplay class
parent
29777a26
No related branches found
Branches containing commit
No related tags found
4 merge requests
!51
Resolve "Adjust cannon angle from touch input"
,
!35
Draft: Resolve "Adjust cannon angle from touch input"
,
!32
Combine hud with gameplay
,
!25
Draft: Resolve "Create UI for gameplay"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/core/src/com/game/tankwars/view/GameHud.java
+106
-0
106 additions, 0 deletions
frontend/core/src/com/game/tankwars/view/GameHud.java
with
106 additions
and
0 deletions
frontend/core/src/com/game/tankwars/view/GameHud.java
0 → 100644
+
106
−
0
View file @
27ecfd44
package
com.game.tankwars.view
;
import
com.badlogic.gdx.Gdx
;
import
com.badlogic.gdx.graphics.g2d.SpriteBatch
;
import
com.badlogic.gdx.scenes.scene2d.Stage
;
import
com.badlogic.gdx.scenes.scene2d.ui.Button
;
import
com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup
;
import
com.badlogic.gdx.scenes.scene2d.ui.Label
;
import
com.badlogic.gdx.scenes.scene2d.ui.ProgressBar
;
import
com.badlogic.gdx.scenes.scene2d.ui.Skin
;
import
com.badlogic.gdx.scenes.scene2d.ui.Slider
;
import
com.badlogic.gdx.scenes.scene2d.ui.Table
;
import
com.badlogic.gdx.scenes.scene2d.ui.TextButton
;
import
com.badlogic.gdx.utils.viewport.Viewport
;
import
com.ray3k.stripe.FreeTypeSkin
;
public
class
GameHud
{
private
Stage
stage
;
private
Table
table
;
private
Skin
skin
;
private
ProgressBar
healthProgressBarPlayer
;
private
ProgressBar
healthProgressBarOpponent
;
private
TextButton
fireButton
;
private
HorizontalGroup
powerContainer
;
private
Label
powerLabel
;
private
Slider
powerSlider
;
private
Button
moveLeft
;
private
Button
moveRight
;
private
HorizontalGroup
moveContainer
;
public
GameHud
(
Viewport
viewport
,
SpriteBatch
batch
)
{
stage
=
new
Stage
(
viewport
,
batch
);
table
=
new
Table
();
table
.
setFillParent
(
true
);
table
.
setDebug
(
true
);
stage
.
addActor
(
table
);
skin
=
new
FreeTypeSkin
(
Gdx
.
files
.
internal
(
"gameplay-skin.json"
));
healthProgressBarPlayer
=
new
ProgressBar
(
0
,
100
,
1
,
false
,
skin
);
healthProgressBarPlayer
.
setValue
(
40
);
healthProgressBarOpponent
=
new
ProgressBar
(
0
,
100
,
1
,
false
,
skin
);
healthProgressBarOpponent
.
setValue
(
40
);
table
.
add
(
healthProgressBarPlayer
).
expand
().
top
().
left
().
padTop
(
10
).
padLeft
(
10
);
table
.
add
(
healthProgressBarOpponent
).
expand
().
top
().
right
().
padTop
(
10
).
padRight
(
10
);
table
.
row
();
fireButton
=
new
TextButton
(
"Fire!"
,
skin
);
table
.
add
(
fireButton
).
expand
().
bottom
().
left
().
padLeft
(
10
).
padBottom
(
10
);
powerLabel
=
new
Label
(
"Power"
,
skin
.
get
(
"roboto-black-white"
,
Label
.
LabelStyle
.
class
));
powerSlider
=
new
Slider
(
0
,
100
,
1
,
false
,
skin
);
powerContainer
=
new
HorizontalGroup
().
space
(
10
);
powerContainer
.
addActor
(
powerLabel
);
powerContainer
.
addActor
(
powerSlider
);
table
.
add
(
powerContainer
).
expand
().
bottom
().
padBottom
(
10
);
moveLeft
=
new
Button
(
skin
.
get
(
"move-left"
,
Button
.
ButtonStyle
.
class
));
moveRight
=
new
Button
(
skin
.
get
(
"move-right"
,
Button
.
ButtonStyle
.
class
));
moveContainer
=
new
HorizontalGroup
().
space
(
10
);
moveContainer
.
addActor
(
moveLeft
);
moveContainer
.
addActor
(
moveRight
);
table
.
add
(
moveContainer
).
expand
().
bottom
().
right
().
padBottom
(
10
).
padRight
(
10
);
}
public
Stage
getStage
()
{
return
stage
;
}
public
Skin
getSkin
()
{
return
skin
;
}
public
TextButton
getFireButton
()
{
return
fireButton
;
}
public
Slider
getPowerSlider
()
{
return
powerSlider
;
}
public
Button
getMoveLeft
()
{
return
moveLeft
;
}
public
Button
getMoveRight
()
{
return
moveRight
;
}
}
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