Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
JTankTrouble
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
9831111
JTankTrouble
Commits
f5e45af1
Commit
f5e45af1
authored
Aug 02, 2020
by
9831111
🙂
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add checkTankDestroyed method to destroy tanks.
parent
45505903
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
GameState.java
src/GameState.java
+15
-0
No files found.
src/GameState.java
View file @
f5e45af1
...
@@ -396,6 +396,21 @@ public class GameState {
...
@@ -396,6 +396,21 @@ public class GameState {
}
}
}
}
}
}
public
void
checkTankDestroyed
(
Tank
tankToCheck
,
Bullet
bullet
)
{
Rectangle
rectangle
=
new
Rectangle
(
tankToCheck
.
getX
(),
tankToCheck
.
getY
(),
25
,
25
);
Ellipse2D
ellipse2D
=
new
Ellipse2D
.
Double
(
bullet
.
x
,
bullet
.
y
,
7
,
7
);
if
(
ellipse2D
.
intersects
(
rectangle
))
{
new
AudioPlayer
(
"sound effects/enemydestroyed.wav"
,
0
);
Controller
.
tanks
.
remove
(
tankToCheck
);
tankToCheck
.
alive
=
false
;
bullet
.
alive
=
false
;
rotateAmountTank
=
0
;
bulletTime
=
61
;
}
}
public
void
fire
(
Graphics2D
g2d
)
{
public
void
fire
(
Graphics2D
g2d
)
{
if
(
keyM
&&
Controller
.
tanks
.
size
()
>
0
)
{
if
(
keyM
&&
Controller
.
tanks
.
size
()
>
0
)
{
if
(
rotateAmountBullet
>=
360
||
rotateAmountBullet
<=
-
360
)
rotateAmountBullet
=
0
;
if
(
rotateAmountBullet
>=
360
||
rotateAmountBullet
<=
-
360
)
rotateAmountBullet
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment