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
3aa528a8
Commit
3aa528a8
authored
Aug 02, 2020
by
9831111
🙂
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add shotBullet method.
parent
d53304e0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
GameState.java
src/GameState.java
+59
-0
No files found.
src/GameState.java
View file @
3aa528a8
...
...
@@ -308,6 +308,65 @@ public class GameState {
}
return
0
;
}
public
void
shotBullet
(
int
px
,
Bullet
bullet
)
{
double
d
;
double
r
=
rotateAmountBullet
;
if
(
r
==
0
)
bullet
.
x
+=
px
;
if
(
r
==
90
||
r
==
-
270
)
bullet
.
y
+=
px
;
if
(
r
==
-
90
||
r
==
270
)
bullet
.
y
-=
px
;
if
(
r
==
180
||
r
==
-
180
)
bullet
.
x
-=
px
;
if
((
r
>
0
&&
r
<
90
)
||
(
r
<
-
270
&&
r
>
-
360
))
{
if
(
px
>
0
)
{
bullet
.
x
+=
px
*
Math
.
cos
(
r
*
Math
.
PI
/
180
);
bullet
.
y
+=
px
*
Math
.
sin
(
r
*
Math
.
PI
/
180
);
}
else
{
bullet
.
x
+=
px
*
Math
.
cos
(
r
*
Math
.
PI
/
180
);
bullet
.
y
+=
px
*
Math
.
sin
(
r
*
Math
.
PI
/
180
);
}
}
if
((
r
>
90
&&
r
<
180
)
||
(
r
<
-
180
&&
r
>
-
270
))
{
if
(
px
>
0
)
{
d
=
r
-
90
;
bullet
.
x
-=
px
*
Math
.
sin
(
d
*
Math
.
PI
/
180
);
bullet
.
y
+=
px
*
Math
.
cos
(
d
*
Math
.
PI
/
180
);
}
else
{
d
=
r
+
270
;
bullet
.
x
-=
px
*
Math
.
sin
(
d
*
Math
.
PI
/
180
);
bullet
.
y
+=
px
*
Math
.
cos
(
d
*
Math
.
PI
/
180
);
}
}
if
((
r
>
180
&&
r
<
270
)
||
(
r
<
-
90
&&
r
>
-
180
))
{
if
(
px
>
0
)
{
d
=
r
-
180
;
bullet
.
x
-=
px
*
Math
.
cos
(
d
*
Math
.
PI
/
180
);
bullet
.
y
-=
px
*
Math
.
sin
(
d
*
Math
.
PI
/
180
);
}
else
{
d
=
r
+
180
;
bullet
.
x
-=
px
*
Math
.
cos
(
d
*
Math
.
PI
/
180
);
bullet
.
y
-=
px
*
Math
.
sin
(
d
*
Math
.
PI
/
180
);
}
}
if
((
r
>
270
&&
r
<
360
)
||
(
r
<
0
&&
r
>
-
90
))
{
if
(
px
>
0
)
{
d
=
r
-
270
;
bullet
.
x
+=
px
*
Math
.
sin
(
d
*
Math
.
PI
/
180
);
bullet
.
y
-=
px
*
Math
.
cos
(
d
*
Math
.
PI
/
180
);
}
else
{
d
=
r
+
90
;
bullet
.
x
+=
px
*
Math
.
sin
(
d
*
Math
.
PI
/
180
);
bullet
.
y
-=
px
*
Math
.
cos
(
d
*
Math
.
PI
/
180
);
}
}
}
public
KeyListener
getKeyListener
()
{
...
...
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