Skip to content

Commit

Permalink
JETRIS Version 1.1.1
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
devng committed Aug 5, 2015
1 parent 1f36338 commit bc939e8
Show file tree
Hide file tree
Showing 54 changed files with 1,312 additions and 713 deletions.
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# Compiled source #
###################
# Compiled source
build/
bin/
war/
*.class

# Eclipse/Gradle/Idea generated files #
##################################
# Eclipse/Gradle/Idea generated files
.classpath
.project
.gradle/
Expand All @@ -16,12 +14,14 @@ war/
*.iml
.idea/

# OS generated files #
######################
# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Jetris HiScore File
JETRIS.DAT
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
2015-08-05
----------
* 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

2015-08-03
----------
* Move the project from sourceforge.net to GitHub
Expand Down
2 changes: 1 addition & 1 deletion JETRIS
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

java -jar JETRIS.jar
java -jar build/libs/jetris.jar
Binary file modified JETRIS.DAT
Binary file not shown.
2 changes: 1 addition & 1 deletion JETRIS.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
rem Batch file to run JETRIS on Windows

start javaw -jar JETRIS.jar
start javaw -jar build\libs\JETRIS.jar
56 changes: 36 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,57 @@
# Jetris 1.1 - A Java-Based Tetris Clone
# Jetris - A Java-Based Tetris Clone

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.

![](http://jetris.sourceforge.net/img/screen1.png)

### This Readme includes:

1. System requirements
2. Running JETRIS on your system
3. How to play
4. Scoring System
6. Saving your old HiScores after version update
1. System Requirements
2. How to Build JETRIS
3. Running JETRIS on Your System
4. How to Play
5. Scoring System
6. Saving Your Old HiScores After Version Update

1. System Requirements
----------------------

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).

1. System requirements
You need JRE 1.6.0 or above. You can download JRE for free at www.java.com

2. How to Build JETRIS
----------------------
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.

JETRIS uses the Gradle build system, you can build the project locally just by typing the following in the console:

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

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.
On Windows use:
```
./gradlew.bat build
```

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

2. Running JETRIS on your system
3. Running JETRIS on Your System
--------------------------------

To start JETRIS try one of the following options:

* 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.

* Double click on JETRIS.bat for Windows users or on JETRIS for Linux users.
* Double click on JETRIS.bat for Windows users or on JETRIS for Linux/OS X users.

* Open the console go to your JETRIS folder and type:

```
java -jar JETRIS.jar
```

### For example:
You have a Windows Operating System, your JETRIS folder is C:\JETRIS then:

Open Start Menu -> Run type "cmd" in the console type "cd C:\JETRIS" hit Enter then type "java -jar JETRIS.jar" hit Enter

3. How to play
3. How to Play
--------------

Use the following keys to play JETRIS:
Expand All @@ -62,7 +78,7 @@ Use the following keys to play JETRIS:

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.

5. Saving your old HiScores after version update
5. Saving Your Old HiScores After Version Update
------------------------------------------------

Copy the old JETRIS.dat File to your new version of Jetris folder.
Expand Down
12 changes: 2 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,8 @@ repositories {
mavenCentral()
}

sourceSets {
main {
java {
srcDir 'src'
}
resources {
srcDir 'src'
}
}
}
sourceCompatibility = 1.7
targetCompatibility = 1.7

jar {
manifest {
Expand Down
2 changes: 1 addition & 1 deletion src/JetrisMain.java → src/main/java/JetrisMain.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import net.sourceforge.jetris.JetrisMainFrame;
import com.devng.jetris.JetrisMainFrame;

public class JetrisMain {
public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package net.sourceforge.jetris;
import java.awt.Color;
package com.devng.jetris;

import java.awt.*;

public abstract class Figure {

protected final static int I = 1;
protected final static int T = 2;
protected final static int O = 3;
protected final static int L = 4;
protected final static int J = 5;
protected final static int S = 6;
protected final static int Z = 7;

protected final static Color COL_I = Color.RED;
protected final static Color COL_T = Color.GRAY;
protected final static Color COL_O = Color.CYAN;
Expand All @@ -21,44 +22,44 @@ public abstract class Figure {

protected int[] arrX;
protected int[] arrY;

protected int offsetX;
protected int offsetY;

protected int offsetXLast;
protected int offsetYLast;
protected Figure(int[] arrX, int[]arrY) {

protected Figure(int[] arrX, int[] arrY) {
this.arrX = arrX;
this.arrY = arrY;
offsetYLast = offsetY = 0;
offsetXLast = offsetX = 4;
}

protected int getMaxRightOffset() {
int r = Integer.MIN_VALUE;
for (int i = 0; i < arrX.length; i++) {
if(r < arrX[i]) r = arrX[i];
if (r < arrX[i]) r = arrX[i];
}
return r+offsetX;
return r + offsetX;
}

protected void setOffset(int x, int y) {
offsetXLast = offsetX;
offsetYLast = offsetY;
offsetYLast = offsetY;
offsetX = x;
offsetY = y;
}

protected void resetOffsets() {
offsetX = offsetY = offsetXLast = offsetYLast = 0;
}

protected abstract void rotationRight();

protected abstract void rotationLeft();

protected abstract int getGridVal();
protected abstract Color getGolor();

protected abstract Color getGolor();
}
Original file line number Diff line number Diff line change
@@ -1,52 +1,67 @@
package net.sourceforge.jetris;
package com.devng.jetris;

import java.util.Random;

/* FigureFactory created on 14.09.2006 */

public class FigureFactory {

Random r;
private int[] counts;
private int lastLastOne;
private int lastOne;

FigureFactory() {
r = new Random();
counts = new int[7];
}

Figure getRandomFigure() {
Figure f;
int i = r.nextInt(7);
while(lastLastOne == lastOne && lastOne == i+1) {
while (lastLastOne == lastOne && lastOne == i + 1) {
i = r.nextInt(7);
}
switch (i) {
case 0: f = new FigureI(); break;
case 1: f = new FigureT(); break;
case 2: f = new FigureO(); break;
case 3: f = new FigureL(); break;
case 4: f = new FigureJ(); break;
case 5: f = new FigureS(); break;
default: f = new FigureZ(); break;
case 0:
f = new FigureI();
break;
case 1:
f = new FigureT();
break;
case 2:
f = new FigureO();
break;
case 3:
f = new FigureL();
break;
case 4:
f = new FigureJ();
break;
case 5:
f = new FigureS();
break;
default:
f = new FigureZ();
break;
}
lastLastOne = lastOne;
lastOne = i+1;
lastOne = i + 1;
counts[i]++;

i = r.nextInt(4);

for (int j = 0; j < i; j++) {
f.rotationRight();
}

return f;
}

protected int[] getCounts() {
return counts;
}

protected void resetCounts() {
for (int i = 0; i < counts.length; i++) {
counts[i] = 0;
Expand Down
Loading

0 comments on commit bc939e8

Please sign in to comment.