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
51f1d0d5
Commit
51f1d0d5
authored
Aug 03, 2020
by
nargessalehi98
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add computer player.
parent
bb466c9a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
GameLoop.java
src/GameLoop.java
+11
-7
No files found.
src/GameLoop.java
View file @
51f1d0d5
...
@@ -29,8 +29,9 @@ public class GameLoop implements Runnable {
...
@@ -29,8 +29,9 @@ public class GameLoop implements Runnable {
private
GameFrame
canvas
;
private
GameFrame
canvas
;
private
GameState
state
;
private
GameState
state
;
//state for other player
//state for other player
private
GameState
state1
;
//private GameState state1;
private
GameState
state2
;
//private GameState state2;
//private GameState pcState;
public
GameLoop
(
GameFrame
frame
)
{
public
GameLoop
(
GameFrame
frame
)
{
canvas
=
frame
;
canvas
=
frame
;
...
@@ -41,8 +42,9 @@ public class GameLoop implements Runnable {
...
@@ -41,8 +42,9 @@ public class GameLoop implements Runnable {
*/
*/
public
void
init
()
{
public
void
init
()
{
state
=
new
GameState
(
1
);
state
=
new
GameState
(
1
);
state1
=
new
GameState
(
2
);
//state1 = new GameState(2);
state2
=
new
GameState
(
3
);
//state2 = new GameState(3);
//pcState=new GameState(4);
canvas
.
addKeyListener
(
state
.
getKeyListener
());
canvas
.
addKeyListener
(
state
.
getKeyListener
());
canvas
.
addMouseListener
(
state
.
getMouseListener
());
canvas
.
addMouseListener
(
state
.
getMouseListener
());
canvas
.
addMouseMotionListener
(
state
.
getMouseMotionListener
());
canvas
.
addMouseMotionListener
(
state
.
getMouseMotionListener
());
...
@@ -57,14 +59,16 @@ public class GameLoop implements Runnable {
...
@@ -57,14 +59,16 @@ public class GameLoop implements Runnable {
@Override
@Override
public
void
run
()
{
public
void
run
()
{
boolean
gameOver
=
false
;
boolean
gameOver
=
false
;
while
(!
gameOver
)
{
while
(!
gameOver
)
{
try
{
try
{
long
start
=
System
.
currentTimeMillis
();
long
start
=
System
.
currentTimeMillis
();
//
//
state
.
update
();
state
.
update
();
state
.
pcUpdate
();
//pcState.pcUpdate();
// state1.update();
// state1.update();
// state2.update();
// state2.update();
canvas
.
render
(
state
,
state2
,
state1
);
canvas
.
render
(
state
);
gameOver
=
state
.
gameOver
;
gameOver
=
state
.
gameOver
;
//
//
...
@@ -76,7 +80,7 @@ public class GameLoop implements Runnable {
...
@@ -76,7 +80,7 @@ public class GameLoop implements Runnable {
}
}
}
}
try
{
try
{
canvas
.
render
(
state
,
state1
,
state2
);
canvas
.
render
(
state
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
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