Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Group-15
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container 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
TDT4240 - Group 15
Group-15
Merge requests
!12
#8
.client,joystick
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
#8
.client,joystick
#8.Client,joystick
into
client
Overview
0
Commits
6
Pipelines
0
Changes
6
Merged
Hallvard Molin Morstøl
requested to merge
#8.Client,joystick
into
client
3 years ago
Overview
0
Commits
6
Pipelines
0
Changes
6
Expand
0
0
Merge request reports
Compare
client
client (base)
and
latest version
latest version
b5629aec
6 commits,
3 years ago
6 files
+
100
−
4
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
6
Search (e.g. *.vue) (Ctrl+P)
core/src/com/tdt4240/paint2win/controller/controls/DualJoysticks.java
+
23
−
2
Options
@@ -10,11 +10,15 @@ import com.tdt4240.paint2win.utility.IObserver;
import
java.util.ArrayList
;
import
java.util.List
;
/**Represents both joysticks on the screen
* @author JLK
*/
public
class
DualJoysticks
{
private
Joystick
PosJoystick
;
private
Joystick
RotJoystick
;
//List of observers that observes both jyosticks
private
List
<
IObserver
>
observers
=
new
ArrayList
<>();
public
DualJoysticks
(
Stage
stage
){
@@ -27,7 +31,9 @@ public class DualJoysticks {
RotJoystick
.
setBounds
(
stage
.
getWidth
()-
600
,
450
,
500
,
500
);
}
/**Render method that need to be run every frame
*
*/
public
void
render
(){
PosJoystick
.
render
();
RotJoystick
.
render
();
@@ -35,16 +41,31 @@ public class DualJoysticks {
}
/**Sends info to observers of DualJoysticks
*
* @param position sends PosJoysticks position with getJoystickCoordinates()
* @param rotation send RotJoysticks rotation with getDegrees()
* @param usingRotJoystick send a boolean true if the RotJoystick is beeing used
*/
private
void
notifyObservers
(
Vector2
position
,
float
rotation
,
boolean
usingRotJoystick
)
{
for
(
IObserver
observer:
this
.
observers
){
observer
.
UpdateEvent
(
position
,
rotation
,
usingRotJoystick
);
}
}
/** Add a observer to observer list of this class
*
* @param observer needs to be a observable object of IObserver
*/
public
void
addObserver
(
IObserver
observer
)
{
observers
.
add
(
observer
);
}
/**removers the observer from List
* should be done in desctructors to avoid index errors
*
* @param observer needs to be a observable object of IObserver
*/
public
void
removeObserver
(
IObserver
observer
)
{
this
.
observers
.
remove
(
observer
);
}
Loading