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
b5102fc7
Commit
b5102fc7
authored
2 years ago
by
Sander Østrem Fagernes
Browse files
Options
Downloads
Patches
Plain Diff
feat: Welcome box added
Issue
#14
parent
69a5ea69
No related branches found
Branches containing commit
No related tags found
1 merge request
!13
14 Main menu screen setup
Pipeline
#204244
passed
2 years ago
Stage: backend test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/assets/main-menu-welcome-box.png
+0
-0
0 additions, 0 deletions
frontend/assets/main-menu-welcome-box.png
frontend/core/src/com/game/tankwars/view/MainMenuScreen.java
+15
-1
15 additions, 1 deletion
frontend/core/src/com/game/tankwars/view/MainMenuScreen.java
with
15 additions
and
1 deletion
frontend/assets/main-menu-welcome-box.png
0 → 100644
+
0
−
0
View file @
b5102fc7
462 B
This diff is collapsed.
Click to expand it.
frontend/core/src/com/game/tankwars/view/MainMenuScreen.java
+
15
−
1
View file @
b5102fc7
...
...
@@ -5,6 +5,7 @@ import com.badlogic.gdx.Screen;
import
com.badlogic.gdx.graphics.OrthographicCamera
;
import
com.badlogic.gdx.graphics.Texture
;
import
com.badlogic.gdx.graphics.g2d.BitmapFont
;
import
com.badlogic.gdx.graphics.g2d.GlyphLayout
;
import
com.badlogic.gdx.graphics.g2d.SpriteBatch
;
import
com.badlogic.gdx.math.Vector3
;
import
com.badlogic.gdx.utils.Array
;
...
...
@@ -24,6 +25,7 @@ public class MainMenuScreen implements Screen {
private
final
MainMenuController
controller
;
private
final
Texture
logo
;
private
final
Texture
welcomeBox
;
private
final
Texture
background
;
private
final
Array
<
MenuButton
>
menuButtons
;
...
...
@@ -38,9 +40,11 @@ public class MainMenuScreen implements Screen {
this
.
controller
=
new
MainMenuController
(
tankWarsGame
);
this
.
logo
=
new
Texture
(
"tankwars-logo.png"
);
this
.
welcomeBox
=
new
Texture
(
"main-menu-welcome-box.png"
);
// TODO: Create our own pixel art background. ZyWDE4.jpg is a dummy background image
this
.
background
=
new
Texture
(
"ZyWDE4.jpg"
);
// TODO: Instantiate in Controller instead ?
this
.
menuButtons
=
new
Array
<>();
this
.
menuButtons
.
add
(
new
MenuButton
(
batch
,
font
,
0
,
"Find Game"
,
0
,
-
50
+
viewport
.
getWorldHeight
()
/
6
));
this
.
menuButtons
.
add
(
new
MenuButton
(
batch
,
font
,
1
,
"Leaderboard"
,
0
,
-
50
));
...
...
@@ -72,13 +76,23 @@ public class MainMenuScreen implements Screen {
batch
.
draw
(
logo
,
-
logo
.
getWidth
()
*
logoScaling
/
2
f
,
viewport
.
getWorldHeight
()
/
3
,
logo
.
getWidth
()
*
logoScaling
,
logo
.
getHeight
()
*
logoScaling
);
// TODO: Clean up the font rendering code
String
welcomeMessage
=
"Welcome to duty"
;
String
username
=
"Commander"
;
GlyphLayout
welcomeLayout
=
new
GlyphLayout
(
font
,
welcomeMessage
);
GlyphLayout
usernameLayout
=
new
GlyphLayout
(
font
,
username
);
batch
.
draw
(
welcomeBox
,
-
viewport
.
getWorldWidth
()
/
2
,
viewport
.
getWorldHeight
()
/
6
);
font
.
draw
(
batch
,
welcomeMessage
,
-
welcomeLayout
.
width
/
2
,
viewport
.
getWorldHeight
()
/
6
+
welcomeBox
.
getHeight
()
*
8
f
/
10
f
);
font
.
draw
(
batch
,
username
,
-
usernameLayout
.
width
/
2
,
viewport
.
getWorldHeight
()
/
6
+
welcomeBox
.
getHeight
()
*
8
f
/
10
f
-
2
*
welcomeLayout
.
height
);
for
(
MenuButton
menuButton
:
menuButtons
)
{
menuButton
.
draw
();
}
batch
.
end
();
}
private
void
checkInput
()
{
// TODO: Write as listener instead of polling
if
(
Gdx
.
input
.
justTouched
())
{
touchPos
.
set
(
Gdx
.
input
.
getX
(),
Gdx
.
input
.
getY
(),
0
);
viewport
.
unproject
(
touchPos
);
...
...
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