Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asteroids
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hexboard-games
asteroids
Commits
dd8fec44
Commit
dd8fec44
authored
9 years ago
by
Piers Williams
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/master' into piers
parents
9cc651ed
cd2c1b88
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/asteroids/Action.java
+12
-0
12 additions, 0 deletions
src/asteroids/Action.java
src/battle/SimpleBattle.java
+21
-4
21 additions, 4 deletions
src/battle/SimpleBattle.java
with
33 additions
and
4 deletions
src/asteroids/Action.java
+
12
−
0
View file @
dd8fec44
...
...
@@ -13,12 +13,24 @@ public class Action {
public
Action
()
{}
/**
* Create a new action to be executed by the controller
*
* @param thrust 1 is full thrust, 0 is nothing
* @param turn 1 is clockwise, -1 is anticlockwise, 0 is don't turn
* @param shoot true is fire, false is don't fire
*/
public
Action
(
double
thrust
,
double
turn
,
boolean
shoot
)
{
this
.
thrust
=
thrust
;
this
.
turn
=
turn
;
this
.
shoot
=
shoot
;
}
/**
* Create an action which is a copy of an existing action
*
* @param a the action to clone
*/
public
Action
(
Action
a
)
{
thrust
=
a
.
thrust
;
turn
=
a
.
turn
;
...
...
This diff is collapsed.
Click to expand it.
src/battle/SimpleBattle.java
+
21
−
4
View file @
dd8fec44
...
...
@@ -86,7 +86,6 @@ public class SimpleBattle {
// apply them to each player's ship, taking actions as necessary
Action
a1
=
p1
.
getAction
(
this
,
0
);
Action
a2
=
p2
.
getAction
(
this
,
1
);
update
(
a1
,
a2
);
}
...
...
@@ -148,7 +147,7 @@ public class SimpleBattle {
return
statsClone
;
}
p
ublic
void
checkCollision
(
GameObject
actor
)
{
p
rotected
void
checkCollision
(
GameObject
actor
)
{
// check with all other game objects
// but use a hack to only consider interesting interactions
// e.g. asteroids do not collide with themselves
...
...
@@ -189,7 +188,7 @@ public class SimpleBattle {
}
}
p
ublic
void
fireMissile
(
Vector2d
s
,
Vector2d
d
,
int
playerId
)
{
p
rotected
void
fireMissile
(
Vector2d
s
,
Vector2d
d
,
int
playerId
)
{
// need all the usual missile firing code here
NeuroShip
currentShip
=
playerId
==
0
?
s1
:
s2
;
PlayerStats
stats
=
this
.
stats
.
get
(
playerId
);
...
...
@@ -222,9 +221,27 @@ public class SimpleBattle {
s2
.
draw
(
g
);
}
public
NeuroShip
getShip
(
int
playerID
)
{
assert
playerID
<
2
;
assert
playerID
>=
0
;
if
(
playerID
==
0
)
{
return
s1
.
copy
();
}
else
{
return
s2
.
copy
();
}
}
public
ArrayList
<
GameObject
>
getObjects
()
{
return
objects
;
return
new
ArrayList
<>(
objects
);
}
public
PlayerStats
getStats
(
int
playerID
)
{
assert
playerID
<
2
;
assert
playerID
>=
0
;
return
stats
.
get
(
playerID
);
}
static
class
PlayerStats
{
...
...
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