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
d569ab0f
Commit
d569ab0f
authored
Jul 31, 2020
by
9831111
🙂
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add horizontalWallCollision method.
parent
06746c8f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
21 deletions
+21
-21
GameState.java
src/GameState.java
+21
-21
No files found.
src/GameState.java
View file @
d569ab0f
...
@@ -112,16 +112,16 @@ public class GameState {
...
@@ -112,16 +112,16 @@ public class GameState {
return
null
;
return
null
;
}
}
//
public Wall horizontalWallCollision() {
public
Wall
horizontalWallCollision
()
{
//
for (Wall wall : Controller.walls) {
for
(
Wall
wall
:
Controller
.
walls
)
{
//
if (wall.getWidth() == 50 && wall.getHeight() == 5) {
if
(
wall
.
getWidth
()
==
50
&&
wall
.
getHeight
()
==
5
)
{
//
if ((getBounds(locX, locY).intersects(new Rectangle((int) wall.getX(), (int) wall.getY(), 50, 5)))) {
if
((
getBounds
(
locX
,
locY
).
intersects
(
new
Rectangle
((
int
)
wall
.
getX
(),
(
int
)
wall
.
getY
(),
50
,
5
))))
{
//
return wall;
return
wall
;
//
}
}
//
}
}
//
}
}
//
return null;
return
null
;
//
}
}
public
boolean
isMoveAllowed
(
int
px
)
{
public
boolean
isMoveAllowed
(
int
px
)
{
...
@@ -154,17 +154,17 @@ public class GameState {
...
@@ -154,17 +154,17 @@ public class GameState {
}
}
}
}
//
if (horizontalWallCollision() != null) {
if
(
horizontalWallCollision
()
!=
null
)
{
//
if (horizontalWallCollision().getY() > locY && px > 0 && ((rotateAmount <= 180 && rotateAmount >= 0) || (rotateAmount <= -180 && rotateAmount > -360)))
if
(
horizontalWallCollision
().
getY
()
>
locY
&&
px
>
0
&&
((
rotateAmount
<=
180
&&
rotateAmount
>=
0
)
||
(
rotateAmount
<=
-
180
&&
rotateAmount
>
-
360
)))
//
return false;
return
false
;
//
if (horizontalWallCollision().getY() < locY && px < 0 && ((rotateAmount <= 180 && rotateAmount >= 0) || (rotateAmount <= -180 && rotateAmount > -360)))
if
(
horizontalWallCollision
().
getY
()
<
locY
&&
px
<
0
&&
((
rotateAmount
<=
180
&&
rotateAmount
>=
0
)
||
(
rotateAmount
<=
-
180
&&
rotateAmount
>
-
360
)))
//
return false;
return
false
;
//
if (horizontalWallCollision().getY() < locY && px > 0 && ((rotateAmount >= -180 && rotateAmount <= 0) || (rotateAmount >= 180 && rotateAmount < 360)))
if
(
horizontalWallCollision
().
getY
()
<
locY
&&
px
>
0
&&
((
rotateAmount
>=
-
180
&&
rotateAmount
<=
0
)
||
(
rotateAmount
>=
180
&&
rotateAmount
<
360
)))
//
return false;
return
false
;
//
if (horizontalWallCollision().getY() > locY && px < 0 && ((rotateAmount >= -180 && rotateAmount <= 0) || (rotateAmount >= 180 && rotateAmount < 360)))
if
(
horizontalWallCollision
().
getY
()
>
locY
&&
px
<
0
&&
((
rotateAmount
>=
-
180
&&
rotateAmount
<=
0
)
||
(
rotateAmount
>=
180
&&
rotateAmount
<
360
)))
//
return false;
return
false
;
//
//
}
}
return
true
;
return
true
;
}
}
...
...
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