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
ee85ed06
Commit
ee85ed06
authored
4 years ago
by
nargessalehi98
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add back and for movement limit.
parent
94e27df8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
20 deletions
+35
-20
GameState.java
src/GameState.java
+35
-20
No files found.
src/GameState.java
View file @
ee85ed06
...
...
@@ -33,6 +33,8 @@ public class GameState {
private
boolean
two
=
false
;
private
boolean
three
=
false
;
private
int
step
=
0
;
boolean
PermissionUp
=
true
;
boolean
PermissionDown
=
true
;
public
GameState
(
int
num
)
{
...
...
@@ -78,42 +80,55 @@ public class GameState {
locY
=
mouseY
-
diam
/
2
;
locX
=
mouseX
-
diam
/
2
;
}
if
(
step
>
2
)
step
=
0
;
//
// if(step<
2)
//
step=0;
if
(
keyUP
)
{
boolean
PermissionDown
=
true
;
PermissionUp
=
true
;
for
(
Wall
wall
:
Controller
.
walls
)
{
if
(
wall
.
intersects
(
getBounds
(
locX
+
5
,
locY
+
5
)))
{
System
.
out
.
println
(
"4"
);
PermissionDown
=
false
;
break
;
if
(
wall
.
getWidth
()
==
5
&&
wall
.
getHeight
()
==
50
)
{
if
((
getBounds
(
locX
,
locY
).
intersects
(
new
Rectangle
((
int
)
wall
.
getX
(),
(
int
)
wall
.
getY
(),
5
,
50
))))
{
PermissionUp
=
false
;
//System.out.println(wall.getHeight());
break
;
}
}
if
(
wall
.
getWidth
()
==
50
&&
wall
.
getHeight
()
==
5
)
{
if
((
getBounds
(
locX
,
locY
).
intersects
(
new
Rectangle
((
int
)
wall
.
getX
(),
(
int
)
wall
.
getY
(),
50
,
5
))))
{
//System.out.println(wall.getHeight());
PermissionUp
=
false
;
break
;
}
}
}
if
(
Permission
Down
)
if
(
Permission
Up
)
move
(+
5
);
if
(!
PermissionDown
&&
step
<
2
){
if
(!
PermissionDown
){
move
(+
5
);
step
++;
}
}
if
(
keyDOWN
)
{
boolean
PermissionUp
=
true
;
PermissionDown
=
true
;
for
(
Wall
wall
:
Controller
.
walls
)
{
if
(
wall
.
intersects
(
getBounds
(
locX
+
5
,
locY
+
5
)))
{
System
.
out
.
println
(
"5"
);
PermissionUp
=
false
;
break
;
if
(
wall
.
getWidth
()
==
5
&&
wall
.
getHeight
()
==
50
)
{
if
((
getBounds
(
locX
,
locY
).
intersects
(
new
Rectangle
((
int
)
wall
.
getX
(),
(
int
)
wall
.
getY
(),
5
,
50
))))
{
PermissionDown
=
false
;
break
;
}
}
if
(
wall
.
getWidth
()
==
50
&&
wall
.
getHeight
()
==
5
)
{
if
((
getBounds
(
locX
,
locY
).
intersects
(
new
Rectangle
((
int
)
wall
.
getX
(),
(
int
)
wall
.
getY
(),
50
,
5
))))
{
PermissionDown
=
false
;
break
;
}
}
}
if
(
Permission
Up
)
if
(
Permission
Down
)
move
(-
5
);
if
(!
PermissionUp
&&
step
<
2
)
{
if
(!
PermissionUp
)
{
move
(-
5
);
step
++;
System
.
out
.
println
(
step
);
}
}
...
...
This diff is collapsed.
Click to expand it.
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