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
4702bff7
Commit
4702bff7
authored
2 years ago
by
Magnus Segtnan Skjølberg
Browse files
Options
Downloads
Patches
Plain Diff
(
#18
): connect hud input to tank shoot and movement
parent
fd8cfb8f
No related branches found
Branches containing commit
No related tags found
3 merge requests
!51
Resolve "Adjust cannon angle from touch input"
,
!35
Draft: Resolve "Adjust cannon angle from touch input"
,
!32
Combine hud with gameplay
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/core/src/com/game/tankwars/controller/GameController.java
+8
-19
8 additions, 19 deletions
...core/src/com/game/tankwars/controller/GameController.java
with
8 additions
and
19 deletions
frontend/core/src/com/game/tankwars/controller/GameController.java
+
8
−
19
View file @
4702bff7
...
...
@@ -5,7 +5,6 @@ import com.badlogic.gdx.Input;
import
com.badlogic.gdx.scenes.scene2d.Actor
;
import
com.badlogic.gdx.scenes.scene2d.InputEvent
;
import
com.badlogic.gdx.scenes.scene2d.InputListener
;
import
com.badlogic.gdx.scenes.scene2d.Touchable
;
import
com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
;
import
com.game.tankwars.TankWarsGame
;
import
com.game.tankwars.model.Bullet
;
...
...
@@ -39,17 +38,20 @@ public class GameController {
tank
.
rotateCannonRight
();
}
if
(
Gdx
.
input
.
justTouched
())
{
bullet
=
new
Bullet
(
tank
);
bullet
.
shoot
();
if
(
moveRightTouched
)
{
tank
.
moveRight
();
}
else
if
(
moveLeftTouched
)
{
tank
.
moveLeft
();
}
}
public
void
handleHudEvents
()
{
hud
.
getFireButton
().
addListener
(
new
ChangeListener
()
{
public
void
changed
(
ChangeEvent
event
,
Actor
actor
)
{
System
.
out
.
println
(
"Changed!"
);
actor
.
setTouchable
(
Touchable
.
disabled
);
bullet
=
new
Bullet
(
tank
);
bullet
.
shoot
();
//actor.setTouchable(Touchable.disabled);
// TODO: send turn to server + enable touchable when it is players turn
endPlayerTurn
();
}
...
...
@@ -91,20 +93,7 @@ public class GameController {
});
if
(
moveRightTouched
)
{
tank
.
moveRight
();
}
if
(
moveLeftTouched
)
{
tank
.
moveLeft
();
}
}
public
boolean
isMoveRightTouched
()
{
return
moveRightTouched
;
}
public
boolean
isMoveLeftTouched
()
{
return
moveLeftTouched
;
}
public
boolean
endPlayerTurn
()
{
...
...
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