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
45505903
Commit
45505903
authored
Aug 02, 2020
by
9831111
🙂
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add fire method.
parent
4522d483
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
GameState.java
src/GameState.java
+28
-0
No files found.
src/GameState.java
View file @
45505903
...
...
@@ -396,6 +396,34 @@ public class GameState {
}
}
}
public
void
fire
(
Graphics2D
g2d
)
{
if
(
keyM
&&
Controller
.
tanks
.
size
()
>
0
)
{
if
(
rotateAmountBullet
>=
360
||
rotateAmountBullet
<=
-
360
)
rotateAmountBullet
=
0
;
Bullet
bullet
=
new
Bullet
(
calculateBullet
(
"x"
),
calculateBullet
(
"y"
),
rotateAmountBullet
,
30
);
bullets
.
add
(
bullet
);
bulletCollision
(
bullets
.
get
(
0
));
shotBullet
(
8
,
bullets
.
get
(
0
));
g2d
.
fillOval
(
bullets
.
get
(
0
).
x
,
bullets
.
get
(
0
).
y
,
7
,
7
);
if
(
bullets
.
size
()
>
5
&&
Controller
.
tanks
.
size
()
>
0
)
checkTankDestroyed
(
Controller
.
tanks
.
get
(
0
),
bullets
.
get
(
0
));
if
(
bulletTime
>
60
)
{
bullets
.
get
(
0
).
x
=
calculateBullet
(
"x"
);
bullets
.
get
(
0
).
y
=
calculateBullet
(
"y"
);
bullets
.
get
(
0
).
rotateAmountBullet
=
rotateAmountTank
;
bullets
.
clear
();
keyM
=
false
;
bulletTime
=
0
;
}
bulletTime
++;
}
}
...
...
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