Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
brick-breaker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mkandel2
brick-breaker
Commits
b82fb7f3
Commit
b82fb7f3
authored
1 year ago
by
abhatta5
Browse files
Options
Downloads
Patches
Plain Diff
Change graphics and remove few static values
parent
80adfca5
No related branches found
No related tags found
1 merge request
!1
Game graphics
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/src/main/java/brickbreaker/GameMapBuilder.java
+5
-6
5 additions, 6 deletions
app/src/main/java/brickbreaker/GameMapBuilder.java
app/src/main/java/brickbreaker/GamePanel.java
+9
-6
9 additions, 6 deletions
app/src/main/java/brickbreaker/GamePanel.java
with
14 additions
and
12 deletions
app/src/main/java/brickbreaker/GameMapBuilder.java
+
5
−
6
View file @
b82fb7f3
...
@@ -27,8 +27,8 @@ class GameMapBuilder {
...
@@ -27,8 +27,8 @@ class GameMapBuilder {
}
}
}
}
brickWidth
=
5
40
/
col
;
brickWidth
=
5
0
;
brickHeight
=
150
/
row
;
brickHeight
=
20
;
}
}
// this draws the bricks
// this draws the bricks
...
@@ -36,12 +36,11 @@ class GameMapBuilder {
...
@@ -36,12 +36,11 @@ class GameMapBuilder {
for
(
int
i
=
0
;
i
<
map
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
map
.
length
;
i
++)
{
for
(
int
j
=
0
;
j
<
map
[
0
].
length
;
j
++)
{
for
(
int
j
=
0
;
j
<
map
[
0
].
length
;
j
++)
{
if
(
map
[
i
][
j
]
>
0
)
{
if
(
map
[
i
][
j
]
>
0
)
{
g
.
setColor
(
new
Color
(
0X
FF8787
));
// brick color
g
.
setColor
(
new
Color
(
0X
0BB5FB
));
// brick color
g
.
fillRect
(
j
*
brickWidth
+
80
,
i
*
brickHeight
+
50
,
brickWidth
,
brickHeight
);
g
.
fillRect
(
j
*
brickWidth
,
i
*
brickHeight
,
brickWidth
,
brickHeight
);
g
.
setStroke
(
new
BasicStroke
(
4
));
g
.
setColor
(
Color
.
BLACK
);
g
.
setColor
(
Color
.
BLACK
);
g
.
drawRect
(
j
*
brickWidth
+
80
,
i
*
brickHeight
+
50
,
brickWidth
,
brickHeight
);
g
.
drawRect
(
j
*
brickWidth
,
i
*
brickHeight
,
brickWidth
,
brickHeight
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
app/src/main/java/brickbreaker/GamePanel.java
+
9
−
6
View file @
b82fb7f3
...
@@ -11,7 +11,9 @@ public class GamePanel extends JPanel implements KeyListener, ActionListener {
...
@@ -11,7 +11,9 @@ public class GamePanel extends JPanel implements KeyListener, ActionListener {
private
boolean
play
=
true
;
private
boolean
play
=
true
;
private
int
score
=
0
;
private
int
score
=
0
;
private
int
totalBricks
=
21
;
private
int
totalBricks
;
private
int
rows
=
10
;
private
int
columns
=
14
;
private
Timer
timer
;
private
Timer
timer
;
private
int
delay
=
8
;
private
int
delay
=
8
;
...
@@ -27,8 +29,9 @@ public class GamePanel extends JPanel implements KeyListener, ActionListener {
...
@@ -27,8 +29,9 @@ public class GamePanel extends JPanel implements KeyListener, ActionListener {
public
GamePanel
()
{
public
GamePanel
()
{
this
.
ballPosition
=
new
Vector
(
120
,
350
);
this
.
ballPosition
=
new
Vector
(
120
,
350
);
this
.
ballDirection
=
new
Vector
(-
1
,
-
2
);
this
.
ballDirection
=
new
Vector
(-
1
,
-
2
);
this
.
totalBricks
=
rows
*
columns
;
map
=
new
GameMapBuilder
(
4
,
8
);
map
=
new
GameMapBuilder
(
rows
,
columns
);
addKeyListener
(
this
);
addKeyListener
(
this
);
setFocusable
(
true
);
setFocusable
(
true
);
setFocusTraversalKeysEnabled
(
false
);
setFocusTraversalKeysEnabled
(
false
);
...
@@ -93,8 +96,8 @@ public class GamePanel extends JPanel implements KeyListener, ActionListener {
...
@@ -93,8 +96,8 @@ public class GamePanel extends JPanel implements KeyListener, ActionListener {
for
(
int
i
=
0
;
i
<
map
.
map
.
length
;
i
++)
{
// Ball - Brick interaction
for
(
int
i
=
0
;
i
<
map
.
map
.
length
;
i
++)
{
// Ball - Brick interaction
for
(
int
j
=
0
;
j
<
map
.
map
[
0
].
length
;
j
++)
{
// map.map[0].length is the number of columns
for
(
int
j
=
0
;
j
<
map
.
map
[
0
].
length
;
j
++)
{
// map.map[0].length is the number of columns
if
(
map
.
map
[
i
][
j
]
>
0
)
{
if
(
map
.
map
[
i
][
j
]
>
0
)
{
int
brickX
=
j
*
map
.
brickWidth
+
80
;
int
brickX
=
j
*
map
.
brickWidth
;
int
brickY
=
i
*
map
.
brickHeight
+
50
;
int
brickY
=
i
*
map
.
brickHeight
;
int
brickWidth
=
map
.
brickWidth
;
int
brickWidth
=
map
.
brickWidth
;
int
brickHeight
=
map
.
brickHeight
;
int
brickHeight
=
map
.
brickHeight
;
...
@@ -168,8 +171,8 @@ public class GamePanel extends JPanel implements KeyListener, ActionListener {
...
@@ -168,8 +171,8 @@ public class GamePanel extends JPanel implements KeyListener, ActionListener {
ballDirection
.
x
=
-
1
;
ballDirection
.
x
=
-
1
;
ballDirection
.
y
=
-
2
;
ballDirection
.
y
=
-
2
;
score
=
0
;
score
=
0
;
totalBricks
=
21
;
totalBricks
=
rows
*
columns
;
;
map
=
new
GameMapBuilder
(
7
,
8
);
map
=
new
GameMapBuilder
(
rows
,
columns
);
repaint
();
repaint
();
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment