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
3a518db6
Commit
3a518db6
authored
Jul 28, 2020
by
nargessalehi98
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add formula for tank movement limit in map.
parent
893fe053
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
15 deletions
+25
-15
GameState.java
src/GameState.java
+25
-15
No files found.
src/GameState.java
View file @
3a518db6
...
@@ -64,9 +64,10 @@ public class GameState {
...
@@ -64,9 +64,10 @@ public class GameState {
}
}
public
Rectangle
getBounds
(
int
locX
,
int
locY
)
{
public
Rectangle
getBounds
(
int
locX
,
int
locY
)
{
return
new
Rectangle
(
locX
,
locY
,
25
,
25
);
return
new
Rectangle
(
locX
,
locY
,
25
,
25
);
}
}
/**
/**
* The method which updates the game state.
* The method which updates the game state.
*/
*/
...
@@ -78,20 +79,28 @@ public class GameState {
...
@@ -78,20 +79,28 @@ public class GameState {
}
}
if
(
keyUP
)
{
if
(
keyUP
)
{
// boolean Permission=
true;
boolean
Permission
=
true
;
//
for (Wall wall : Controller.walls) {
for
(
Wall
wall
:
Controller
.
walls
)
{
// if(wall.intersects(getBounds(locX+5,locY+5)))
{
if
(
wall
.
intersects
(
getBounds
(
locX
+
5
,
locY
+
5
)))
{
//
System.out.println("4");
System
.
out
.
println
(
"4"
);
//
Permission = false;
Permission
=
false
;
//
break;
break
;
//
}
}
//
}
}
//
if (Permission)
if
(
Permission
)
move
(+
5
);
move
(+
5
);
}
}
if
(
keyDOWN
)
{
if
(
keyDOWN
)
{
boolean
Permission
=
true
;
boolean
Permission
=
true
;
for
(
Wall
wall
:
Controller
.
walls
)
{
if
(
wall
.
intersects
(
getBounds
(
locX
+
5
,
locY
+
5
)))
{
System
.
out
.
println
(
"5"
);
Permission
=
false
;
break
;
}
}
if
(
Permission
)
move
(-
5
);
move
(-
5
);
}
}
...
@@ -102,10 +111,11 @@ public class GameState {
...
@@ -102,10 +111,11 @@ public class GameState {
if
(
keyRIGHT
)
if
(
keyRIGHT
)
rotateAmount
+=
15
;
rotateAmount
+=
15
;
locX
=
Math
.
max
(
locX
,
42
);
locX
=
Math
.
max
(
locX
,
40
);
locX
=
Math
.
min
(
locX
,
GameFrame
.
GAME_WIDTH
-
diam
-
42
);
locX
=
Math
.
min
(
locX
,
20
+
(((
Controller
.
col
-
1
)
/
2
)
*
50
)
+
(((
Controller
.
col
-
1
)
/
2
)
+
1
)
*
5
-
25
);
locY
=
Math
.
max
(
locY
,
70
);
locY
=
Math
.
max
(
locY
,
70
);
locY
=
Math
.
min
(
locY
,
((
Controller
.
row
-
1
)/
2
)*
50
+
60
);
locY
=
Math
.
min
(
locY
,
50
+
((
Controller
.
row
-
1
)
/
2
)
*
50
+
(((
Controller
.
row
-
1
)
/
2
)
+
1
)*
5
-
25
);
}
}
public
void
move
(
int
px
)
{
public
void
move
(
int
px
)
{
...
...
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