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
812da24b
Commit
812da24b
authored
9 years ago
by
Memo Akten
Browse files
Options
Downloads
Patches
Plain Diff
player ships are drawn different colors (green and blue)
parent
6ebca243
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/battle/NeuroShip.java
+7
-2
7 additions, 2 deletions
src/battle/NeuroShip.java
src/battle/SimpleBattle.java
+4
-4
4 additions, 4 deletions
src/battle/SimpleBattle.java
with
11 additions
and
6 deletions
src/battle/NeuroShip.java
+
7
−
2
View file @
812da24b
...
...
@@ -40,14 +40,18 @@ public class NeuroShip extends GameObject {
// position and velocity
public
Vector2d
d
;
// played id (used for drawing)
int
playerID
;
public
NeuroShip
(
Vector2d
s
,
Vector2d
v
,
Vector2d
d
)
{
public
NeuroShip
(
Vector2d
s
,
Vector2d
v
,
Vector2d
d
,
int
playerID
)
{
super
(
new
Vector2d
(
s
),
new
Vector2d
(
v
));
this
.
d
=
new
Vector2d
(
d
);
this
.
playerID
=
playerID
;
}
public
NeuroShip
copy
()
{
NeuroShip
ship
=
new
NeuroShip
(
s
,
v
,
d
);
NeuroShip
ship
=
new
NeuroShip
(
s
,
v
,
d
,
playerID
);
ship
.
releaseVelocity
=
releaseVelocity
;
return
ship
;
}
...
...
@@ -137,6 +141,7 @@ public class NeuroShip extends GameObject {
}
public
void
draw
(
Graphics2D
g
)
{
color
=
playerID
==
0
?
Color
.
green
:
Color
.
blue
;
AffineTransform
at
=
g
.
getTransform
();
g
.
translate
(
s
.
x
,
s
.
y
);
double
rot
=
Math
.
atan2
(
d
.
y
,
d
.
x
)
+
Math
.
PI
/
2
;
...
...
This diff is collapsed.
Click to expand it.
src/battle/SimpleBattle.java
+
4
−
4
View file @
812da24b
...
...
@@ -68,17 +68,17 @@ public class SimpleBattle {
protected
void
reset
()
{
stats
.
clear
();
objects
.
clear
();
s1
=
buildShip
(
250
,
250
);
s2
=
buildShip
(
300
,
300
);
s1
=
buildShip
(
250
,
250
,
0
);
s2
=
buildShip
(
300
,
300
,
1
);
this
.
currentTick
=
0
;
}
protected
NeuroShip
buildShip
(
int
x
,
int
y
)
{
protected
NeuroShip
buildShip
(
int
x
,
int
y
,
int
playerID
)
{
Vector2d
position
=
new
Vector2d
(
x
,
y
);
Vector2d
speed
=
new
Vector2d
();
Vector2d
direction
=
new
Vector2d
(
1
,
0
);
return
new
NeuroShip
(
position
,
speed
,
direction
);
return
new
NeuroShip
(
position
,
speed
,
direction
,
playerID
);
}
public
void
update
()
{
...
...
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