-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
120 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
package com.github.salif.tetris; | ||
|
||
import java.util.Locale; | ||
import java.util.ResourceBundle; | ||
|
||
import javax.swing.SwingUtilities; | ||
|
||
public class App { | ||
|
||
public static void main(String[] args) { | ||
new GameWindow(); | ||
SwingUtilities.invokeLater(new GameWindow(ResourceBundle.getBundle("m", Locale.getDefault()))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 20 additions & 13 deletions
33
app/src/main/java/com/github/salif/tetris/GameWindow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,33 @@ | ||
package com.github.salif.tetris; | ||
|
||
import java.awt.GridLayout; | ||
import java.util.ResourceBundle; | ||
|
||
import javax.swing.JFrame; | ||
|
||
public class GameWindow extends JFrame { | ||
public class GameWindow implements Runnable { | ||
|
||
private static final long serialVersionUID = 8737819995837542594L; | ||
private final JFrame mainFrame; | ||
private final GameBoardPanel gameBoard; | ||
|
||
public GameWindow() { | ||
setTitle("Tetris :D"); | ||
setSize(400, 814); | ||
setResizable(false); | ||
public GameWindow(ResourceBundle m) { | ||
this.mainFrame = new JFrame(); | ||
this.mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
this.mainFrame.setTitle(m.getString("title")); | ||
this.mainFrame.setSize(400, 814); | ||
this.mainFrame.setResizable(false); | ||
|
||
setLayout(new GridLayout(1, 2)); | ||
this.mainFrame.setLayout(new GridLayout(1, 2)); | ||
|
||
// you can adjust timer resolution here. but it's ideal value for this game. | ||
GameBoardPanel gameBoard = new GameBoardPanel(this, 400); | ||
add(gameBoard); | ||
gameBoard.start(); | ||
this.gameBoard = new GameBoardPanel(this, m, 500); | ||
this.mainFrame.add(gameBoard); | ||
} | ||
|
||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
setLocationRelativeTo(null); | ||
setVisible(true); | ||
@Override | ||
public void run() { | ||
this.mainFrame.setLocationRelativeTo(null); | ||
this.mainFrame.setVisible(true); | ||
this.gameBoard.start(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.github.salif.tetris; | ||
|
||
public enum Tetrominoes { | ||
NO_BLOCK, Z_SHAPE, S_SHAPE, I_SHAPE, T_SHAPE, O_SHAPE, L_SHAPE, J_SHAPE | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
title=Tetris :D | ||
score=Score | ||
level=Level | ||
paused=PAUSED | ||
gameover=Game over! | ||
restart=Play again? |
Oops, something went wrong.