Skip to content

Commit bc939e8

Browse files
committed
JETRIS Version 1.1.1
- Use gradle as a build system - Use the standard directory layout - Change the package name to com.devng.jetris - Adjust the documentation - Include the web page files in the repo - Small code adjustments
1 parent 1f36338 commit bc939e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1312
-713
lines changed

.gitignore

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
# Compiled source #
2-
###################
1+
# Compiled source
32
build/
43
bin/
54
war/
65
*.class
76

8-
# Eclipse/Gradle/Idea generated files #
9-
##################################
7+
# Eclipse/Gradle/Idea generated files
108
.classpath
119
.project
1210
.gradle/
@@ -16,12 +14,14 @@ war/
1614
*.iml
1715
.idea/
1816

19-
# OS generated files #
20-
######################
17+
# OS generated files
2118
.DS_Store
2219
.DS_Store?
2320
._*
2421
.Spotlight-V100
2522
.Trashes
2623
ehthumbs.db
2724
Thumbs.db
25+
26+
# Jetris HiScore File
27+
JETRIS.DAT

CHANGES.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
2015-08-05
2+
----------
3+
* JETRIS Version 1.1.1
4+
* Use Gradle as a build system
5+
* Use the standard directory layout
6+
* Change the package name to com.devng.jetris
7+
* Adjust the documentation
8+
* Include the web page files in the repo
9+
* Small code adjustments
10+
111
2015-08-03
212
----------
313
* Move the project from sourceforge.net to GitHub

JETRIS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22

3-
java -jar JETRIS.jar
3+
java -jar build/libs/jetris.jar

JETRIS.DAT

-10 Bytes
Binary file not shown.

JETRIS.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
rem Batch file to run JETRIS on Windows
22

3-
start javaw -jar JETRIS.jar
3+
start javaw -jar build\libs\JETRIS.jar

README.md

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,57 @@
1-
# Jetris 1.1 - A Java-Based Tetris Clone
1+
# Jetris - A Java-Based Tetris Clone
2+
3+
Jetris is a Java-based Tetris clone for the desktop. Jetris is focused on a fast gaming, so a game usually takes about 10 min.
4+
5+
![](http://jetris.sourceforge.net/img/screen1.png)
26

37
### This Readme includes:
48

5-
1. System requirements
6-
2. Running JETRIS on your system
7-
3. How to play
8-
4. Scoring System
9-
6. Saving your old HiScores after version update
9+
1. System Requirements
10+
2. How to Build JETRIS
11+
3. Running JETRIS on Your System
12+
4. How to Play
13+
5. Scoring System
14+
6. Saving Your Old HiScores After Version Update
15+
16+
1. System Requirements
17+
----------------------
18+
19+
JETRIS is written in the JAVA programming language, this means that it can be run on any Operating System which has JAVA Runtime Environment (JRE).
1020

11-
1. System requirements
21+
You need JRE 1.6.0 or above. You can download JRE for free at www.java.com
22+
23+
2. How to Build JETRIS
1224
----------------------
25+
If you want to build JETRIS on your local machine you need to install the Java Development Kit (JDK). You need JDK 1.6.0 or above.
26+
27+
JETRIS uses the Gradle build system, you can build the project locally just by typing the following in the console:
1328

14-
Jetris is written in JAVA programming language, this means that it can be run on any Operating System which has JAVA Runtime Environment (JRE).
29+
```
30+
./gradlew build
31+
```
1532

16-
You need JRE 1.5.0 (also know as JRE 5) or above. If you have an older JRE version then you will get an error message and the program will exit.
33+
On Windows use:
34+
```
35+
./gradlew.bat build
36+
```
1737

18-
You can download JRE for free at www.java.com
38+
The generated jar file can be found in the folder _build/libs_
1939

20-
2. Running JETRIS on your system
40+
3. Running JETRIS on Your System
2141
--------------------------------
2242

2343
To start JETRIS try one of the following options:
2444

2545
* Double click on the JAR File to start JETRIS. If this didn't work, then you didn't associate your JAR Files with your JRE.
2646

27-
* Double click on JETRIS.bat for Windows users or on JETRIS for Linux users.
47+
* Double click on JETRIS.bat for Windows users or on JETRIS for Linux/OS X users.
2848

2949
* Open the console go to your JETRIS folder and type:
30-
50+
```
3151
java -jar JETRIS.jar
52+
```
3253

33-
### For example:
34-
You have a Windows Operating System, your JETRIS folder is C:\JETRIS then:
35-
36-
Open Start Menu -> Run type "cmd" in the console type "cd C:\JETRIS" hit Enter then type "java -jar JETRIS.jar" hit Enter
37-
38-
3. How to play
54+
3. How to Play
3955
--------------
4056

4157
Use the following keys to play JETRIS:
@@ -62,7 +78,7 @@ Use the following keys to play JETRIS:
6278

6379
The current level is 20 (the highest level) and You clear 4 Lines at once, then You get 1600 + 80 x 20 = 2 x 1600 = 3200. So on level 20 you are making twice as much points as on level 0.
6480

65-
5. Saving your old HiScores after version update
81+
5. Saving Your Old HiScores After Version Update
6682
------------------------------------------------
6783

6884
Copy the old JETRIS.dat File to your new version of Jetris folder.

build.gradle

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,8 @@ repositories {
1010
mavenCentral()
1111
}
1212

13-
sourceSets {
14-
main {
15-
java {
16-
srcDir 'src'
17-
}
18-
resources {
19-
srcDir 'src'
20-
}
21-
}
22-
}
13+
sourceCompatibility = 1.7
14+
targetCompatibility = 1.7
2315

2416
jar {
2517
manifest {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import net.sourceforge.jetris.JetrisMainFrame;
1+
import com.devng.jetris.JetrisMainFrame;
22

33
public class JetrisMain {
44
public static void main(String[] args) {
Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
package net.sourceforge.jetris;
2-
import java.awt.Color;
1+
package com.devng.jetris;
2+
3+
import java.awt.*;
34

45
public abstract class Figure {
5-
6+
67
protected final static int I = 1;
78
protected final static int T = 2;
89
protected final static int O = 3;
910
protected final static int L = 4;
1011
protected final static int J = 5;
1112
protected final static int S = 6;
1213
protected final static int Z = 7;
13-
14+
1415
protected final static Color COL_I = Color.RED;
1516
protected final static Color COL_T = Color.GRAY;
1617
protected final static Color COL_O = Color.CYAN;
@@ -21,44 +22,44 @@ public abstract class Figure {
2122

2223
protected int[] arrX;
2324
protected int[] arrY;
24-
25+
2526
protected int offsetX;
2627
protected int offsetY;
27-
28+
2829
protected int offsetXLast;
2930
protected int offsetYLast;
30-
31-
protected Figure(int[] arrX, int[]arrY) {
31+
32+
protected Figure(int[] arrX, int[] arrY) {
3233
this.arrX = arrX;
3334
this.arrY = arrY;
3435
offsetYLast = offsetY = 0;
3536
offsetXLast = offsetX = 4;
3637
}
37-
38+
3839
protected int getMaxRightOffset() {
3940
int r = Integer.MIN_VALUE;
4041
for (int i = 0; i < arrX.length; i++) {
41-
if(r < arrX[i]) r = arrX[i];
42+
if (r < arrX[i]) r = arrX[i];
4243
}
43-
return r+offsetX;
44+
return r + offsetX;
4445
}
45-
46+
4647
protected void setOffset(int x, int y) {
4748
offsetXLast = offsetX;
48-
offsetYLast = offsetY;
49+
offsetYLast = offsetY;
4950
offsetX = x;
5051
offsetY = y;
5152
}
52-
53+
5354
protected void resetOffsets() {
5455
offsetX = offsetY = offsetXLast = offsetYLast = 0;
5556
}
56-
57+
5758
protected abstract void rotationRight();
58-
59+
5960
protected abstract void rotationLeft();
60-
61+
6162
protected abstract int getGridVal();
62-
63-
protected abstract Color getGolor();
63+
64+
protected abstract Color getGolor();
6465
}

src/net/sourceforge/jetris/FigureFactory.java renamed to src/main/java/com/devng/jetris/FigureFactory.java

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,67 @@
1-
package net.sourceforge.jetris;
1+
package com.devng.jetris;
2+
23
import java.util.Random;
34

45
/* FigureFactory created on 14.09.2006 */
56

67
public class FigureFactory {
7-
8+
89
Random r;
910
private int[] counts;
1011
private int lastLastOne;
1112
private int lastOne;
12-
13+
1314
FigureFactory() {
1415
r = new Random();
1516
counts = new int[7];
1617
}
17-
18+
1819
Figure getRandomFigure() {
1920
Figure f;
2021
int i = r.nextInt(7);
21-
while(lastLastOne == lastOne && lastOne == i+1) {
22+
while (lastLastOne == lastOne && lastOne == i + 1) {
2223
i = r.nextInt(7);
2324
}
2425
switch (i) {
25-
case 0: f = new FigureI(); break;
26-
case 1: f = new FigureT(); break;
27-
case 2: f = new FigureO(); break;
28-
case 3: f = new FigureL(); break;
29-
case 4: f = new FigureJ(); break;
30-
case 5: f = new FigureS(); break;
31-
default: f = new FigureZ(); break;
26+
case 0:
27+
f = new FigureI();
28+
break;
29+
case 1:
30+
f = new FigureT();
31+
break;
32+
case 2:
33+
f = new FigureO();
34+
break;
35+
case 3:
36+
f = new FigureL();
37+
break;
38+
case 4:
39+
f = new FigureJ();
40+
break;
41+
case 5:
42+
f = new FigureS();
43+
break;
44+
default:
45+
f = new FigureZ();
46+
break;
3247
}
3348
lastLastOne = lastOne;
34-
lastOne = i+1;
49+
lastOne = i + 1;
3550
counts[i]++;
36-
51+
3752
i = r.nextInt(4);
3853

3954
for (int j = 0; j < i; j++) {
4055
f.rotationRight();
4156
}
42-
57+
4358
return f;
4459
}
45-
60+
4661
protected int[] getCounts() {
4762
return counts;
4863
}
49-
64+
5065
protected void resetCounts() {
5166
for (int i = 0; i < counts.length; i++) {
5267
counts[i] = 0;

0 commit comments

Comments
 (0)