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
0e5417eb
Commit
0e5417eb
authored
4 years ago
by
nargessalehi98
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add renderLimit controller.
parent
24c4d441
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
GameFrame.java
src/GameFrame.java
+12
-7
No files found.
src/GameFrame.java
View file @
0e5417eb
...
...
@@ -83,13 +83,15 @@ public class GameFrame extends JFrame {
prizes
=
new
ArrayList
<>();
tanks
.
add
(
new
Tank
(
"tank_dark.png"
,
30
,
70
,
0
));
//
tanks.add(new Tank("tank_dark.png", 30, 70, 0));
Controller
.
walls
=
walls
;
Controller
.
prizes
=
prizes
;
Controller
.
getPrize
=
getPrize
;
Controller
.
tanks
=
tanks
;
Controller
.
g2d
=
g2d
;
Controller
.
taken
=
taken
;
Controller
.
renderCount
=
renderCount
;
Controller
.
renderCountLimit
=
renderCountLimit
;
try
{
image1
=
ImageIO
.
read
(
new
File
(
"tank_dark.png"
));
...
...
@@ -203,6 +205,9 @@ public class GameFrame extends JFrame {
setMap
(
g2d
,
new
File
(
"map3.txt"
));
drawMap
(
g2d
);
setPrize
(
g2d
);
for
(
Tank
tank:
tanks
){
tank
.
applyPrize
();
}
state
.
fire
(
g2d
);
...
...
@@ -365,7 +370,7 @@ public class GameFrame extends JFrame {
randomLoc
=
randomLoc
-
1
;
if
(
firstPrize
)
{
g2d
.
drawImage
(
bullet2
,
prizeLoc
.
get
(
randomLoc
),
prizeLoc
.
get
(
randomLoc
+
1
),
null
);
prizes
.
add
(
new
Prize
(
prizeLoc
.
get
(
randomLoc
),
prizeLoc
.
get
(
randomLoc
+
1
),
15
,
15
,
bullet2
.
toString
()
));
prizes
.
add
(
new
Prize
(
prizeLoc
.
get
(
randomLoc
),
prizeLoc
.
get
(
randomLoc
+
1
),
15
,
15
,
"bullet2"
));
firstPrize
=
false
;
lastX
=
prizeLoc
.
get
(
randomLoc
);
lastY
=
prizeLoc
.
get
(
randomLoc
+
1
);
...
...
@@ -378,31 +383,31 @@ public class GameFrame extends JFrame {
if
(
randomNum
==
1
)
{
g2d
.
drawImage
(
shield
,
prizeLoc
.
get
(
randomLoc
),
prizeLoc
.
get
(
randomLoc
+
1
),
null
);
prizes
.
clear
();
prizes
.
add
(
new
Prize
(
prizeLoc
.
get
(
randomLoc
),
prizeLoc
.
get
(
randomLoc
+
1
),
10
,
10
,
shield
.
toString
()
));
prizes
.
add
(
new
Prize
(
prizeLoc
.
get
(
randomLoc
),
prizeLoc
.
get
(
randomLoc
+
1
),
10
,
10
,
"shield"
));
lastPrize
=
shield
;
}
if
(
randomNum
==
0
)
{
g2d
.
drawImage
(
life
,
prizeLoc
.
get
(
randomLoc
),
prizeLoc
.
get
(
randomLoc
+
1
),
null
);
prizes
.
clear
();
prizes
.
add
(
new
Prize
(
prizeLoc
.
get
(
randomLoc
),
prizeLoc
.
get
(
randomLoc
+
1
),
10
,
10
,
life
.
toString
()
));
prizes
.
add
(
new
Prize
(
prizeLoc
.
get
(
randomLoc
),
prizeLoc
.
get
(
randomLoc
+
1
),
10
,
10
,
"life"
));
lastPrize
=
life
;
}
if
(
randomNum
==
3
)
{
g2d
.
drawImage
(
bullet3
,
prizeLoc
.
get
(
randomLoc
),
prizeLoc
.
get
(
randomLoc
+
1
),
null
);
prizes
.
clear
();
prizes
.
add
(
new
Prize
(
prizeLoc
.
get
(
randomLoc
),
prizeLoc
.
get
(
randomLoc
+
1
),
10
,
10
,
bullet3
.
toString
()
));
prizes
.
add
(
new
Prize
(
prizeLoc
.
get
(
randomLoc
),
prizeLoc
.
get
(
randomLoc
+
1
),
10
,
10
,
"bullet3"
));
lastPrize
=
bullet3
;
}
if
(
randomNum
==
2
)
{
g2d
.
drawImage
(
laser
,
prizeLoc
.
get
(
randomLoc
),
prizeLoc
.
get
(
randomLoc
+
1
),
null
);
prizes
.
clear
();
prizes
.
add
(
new
Prize
(
prizeLoc
.
get
(
randomLoc
),
prizeLoc
.
get
(
randomLoc
+
1
),
10
,
10
,
laser
.
toString
()
));
prizes
.
add
(
new
Prize
(
prizeLoc
.
get
(
randomLoc
),
prizeLoc
.
get
(
randomLoc
+
1
),
10
,
10
,
"laser"
));
lastPrize
=
laser
;
}
if
(
randomNum
==
4
)
{
g2d
.
drawImage
(
bullet2
,
prizeLoc
.
get
(
randomLoc
),
prizeLoc
.
get
(
randomLoc
+
1
),
null
);
prizes
.
clear
();
prizes
.
add
(
new
Prize
(
prizeLoc
.
get
(
randomLoc
),
prizeLoc
.
get
(
randomLoc
+
1
),
10
,
10
,
bullet2
.
toString
()
));
prizes
.
add
(
new
Prize
(
prizeLoc
.
get
(
randomLoc
),
prizeLoc
.
get
(
randomLoc
+
1
),
10
,
10
,
"bullet2"
));
lastPrize
=
bullet2
;
}
lastX
=
prizeLoc
.
get
(
randomLoc
);
...
...
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