Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tetris
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Brady James Garvin
tetris
Commits
8a8bfe90
Commit
8a8bfe90
authored
8 years ago
by
Brady James Garvin
Browse files
Options
Downloads
Patches
Plain Diff
Added code to support logging.
parent
b63aed0c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tetris/logs/tetris.log
+0
-0
0 additions, 0 deletions
tetris/logs/tetris.log
tetris/src/main/java/edu/unl/cse/soft160/tetris/Tetris.java
+17
-0
17 additions, 0 deletions
tetris/src/main/java/edu/unl/cse/soft160/tetris/Tetris.java
with
17 additions
and
0 deletions
tetris/logs/tetris.log
0 → 100644
+
0
−
0
View file @
8a8bfe90
This diff is collapsed.
Click to expand it.
tetris/src/main/java/edu/unl/cse/soft160/tetris/Tetris.java
+
17
−
0
View file @
8a8bfe90
...
@@ -10,10 +10,26 @@ import javax.swing.JFrame;
...
@@ -10,10 +10,26 @@ import javax.swing.JFrame;
import
java.awt.event.KeyEvent
;
import
java.awt.event.KeyEvent
;
import
java.awt.event.KeyListener
;
import
java.awt.event.KeyListener
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.nio.file.StandardOpenOption
;
public
class
Tetris
extends
JFrame
{
public
class
Tetris
extends
JFrame
{
private
static
final
long
serialVersionUID
=
-
6851893161385783635L
;
private
static
final
long
serialVersionUID
=
-
6851893161385783635L
;
protected
static
void
log
(
String
message
)
{
try
{
Files
.
write
(
Paths
.
get
(
"logs/tetris.log"
),
(
message
+
"\n"
).
getBytes
(),
StandardOpenOption
.
CREATE
,
StandardOpenOption
.
APPEND
);
}
catch
(
IOException
exception
)
{
exception
.
printStackTrace
();
}
}
protected
static
void
log
(
String
moveName
,
int
shape
)
{
log
(
"Attempted move failed: "
+
moveName
+
" on shape "
+
shape
+
" (\""
+
SHAPE_NAMES
[
shape
]
+
"\")"
);
}
protected
static
int
mod
(
int
value
,
int
modulus
)
{
protected
static
int
mod
(
int
value
,
int
modulus
)
{
int
result
=
value
%
modulus
;
int
result
=
value
%
modulus
;
return
result
<
0
?
result
+
modulus
:
result
;
return
result
<
0
?
result
+
modulus
:
result
;
...
@@ -44,6 +60,7 @@ public class Tetris extends JFrame {
...
@@ -44,6 +60,7 @@ public class Tetris extends JFrame {
protected
static
final
Color
[]
COLORS
=
{
new
Color
(
0
,
0
,
204
),
new
Color
(
142
,
0
,
204
),
new
Color
(
204
,
204
,
0
),
protected
static
final
Color
[]
COLORS
=
{
new
Color
(
0
,
0
,
204
),
new
Color
(
142
,
0
,
204
),
new
Color
(
204
,
204
,
0
),
new
Color
(
204
,
0
,
204
),
new
Color
(
0
,
204
,
204
),
new
Color
(
0
,
204
,
0
),
new
Color
(
204
,
0
,
0
),
};
new
Color
(
204
,
0
,
204
),
new
Color
(
0
,
204
,
204
),
new
Color
(
0
,
204
,
0
),
new
Color
(
204
,
0
,
0
),
};
protected
static
final
String
[]
SHAPE_NAMES
=
{
"O"
,
"L"
,
"J"
,
"S"
,
"Z"
,
"T"
,
"I"
,
};
protected
static
final
int
[]
SHAPE_WIDTHS
=
{
2
,
3
,
3
,
3
,
3
,
3
,
4
,
};
protected
static
final
int
[]
SHAPE_WIDTHS
=
{
2
,
3
,
3
,
3
,
3
,
3
,
4
,
};
protected
static
final
int
[][][][]
SHAPES
=
{
protected
static
final
int
[][][][]
SHAPES
=
{
{
// O
{
// O
...
...
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