Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed FishGame/bin/com/mypro/base/graphics/Bitmap.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/base/graphics/Canvas.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/base/graphics/Matrix.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/base/graphics/Paint.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/base/tools/Log.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/basecomponet/JMatrix.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/constant/Constant.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/mainsurface/MainSurface.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/manager/CannonManager$1.class
Binary file not shown.
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/manager/CatchFishManager$1.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/manager/FishManager.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/manager/GameInitManager.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/manager/GamePartInfo.class
Binary file not shown.
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/manager/GamePartManager.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/manager/HeadFish.class
Binary file not shown.
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/manager/ImageConfig.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/manager/ImageManager.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/manager/LayoutInfo.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/manager/LayoutManager$1.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/manager/LayoutManager.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/manager/PathManager.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/manager/ScoreManager$1.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/manager/ScoreManager$2.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/manager/ScoreManager$3.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/manager/ScoreManager.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/manager/ShoalManager$1.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/manager/ShoalManager$2.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/manager/ShoalManager.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/manager/XmlManager.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/model/Ammo.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/model/BackGround.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/model/DrawableAdapter.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/model/FishGold.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/model/FishInfo.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/model/FishingNet.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/model/GamingInfo.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/model/HighPoint.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/model/HundredPoint.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/model/componets/Bottom.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/model/componets/Cannon$1.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/model/componets/Cannon.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/model/componets/Componet.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/model/fish/Fish$1.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/model/fish/Fish.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/model/interfaces/Button.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/model/interfaces/Drawable.class
Binary file not shown.
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/threads/FishRunThread$1.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/threads/FishRunThread.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/threads/PicActThread.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/threads/ShotThread$1.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/threads/ShotThread.class
Binary file not shown.
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/tools/LogTools.class
Binary file not shown.
Binary file removed FishGame/bin/com/mypro/tools/Tool.class
Binary file not shown.
Binary file added Tetris/bin/tetris/Cell.class
Binary file not shown.
Binary file added Tetris/bin/tetris/GameConfig.class
Binary file not shown.
Binary file added Tetris/bin/tetris/GameManager.class
Binary file not shown.
Binary file added Tetris/bin/tetris/GameOverPanel$1.class
Binary file not shown.
Binary file added Tetris/bin/tetris/GameOverPanel$2.class
Binary file not shown.
Binary file added Tetris/bin/tetris/GameOverPanel$3.class
Binary file not shown.
Binary file added Tetris/bin/tetris/GameOverPanel.class
Binary file not shown.
Binary file added Tetris/bin/tetris/GameState.class
Binary file not shown.
Binary file added Tetris/bin/tetris/MenuPanel$1.class
Binary file not shown.
Binary file added Tetris/bin/tetris/MenuPanel$2.class
Binary file not shown.
Binary file added Tetris/bin/tetris/MenuPanel$3.class
Binary file not shown.
Binary file added Tetris/bin/tetris/MenuPanel$4.class
Binary file not shown.
Binary file added Tetris/bin/tetris/MenuPanel.class
Binary file not shown.
Binary file added Tetris/bin/tetris/SettingsPanel$1.class
Binary file not shown.
Binary file added Tetris/bin/tetris/SettingsPanel$2.class
Binary file not shown.
Binary file added Tetris/bin/tetris/SettingsPanel$3.class
Binary file not shown.
Binary file added Tetris/bin/tetris/SettingsPanel$4.class
Binary file not shown.
Binary file added Tetris/bin/tetris/SettingsPanel$5.class
Binary file not shown.
Binary file added Tetris/bin/tetris/SettingsPanel$6.class
Binary file not shown.
Binary file added Tetris/bin/tetris/SettingsPanel.class
Binary file not shown.
Binary file added Tetris/bin/tetris/TetrisFrame$1.class
Binary file not shown.
Binary file added Tetris/bin/tetris/TetrisFrame.class
Binary file not shown.
Binary file added Tetris/bin/tetris/TetrisPane$1.class
Binary file not shown.
Binary file added Tetris/bin/tetris/TetrisPane$2.class
Binary file not shown.
Binary file added Tetris/bin/tetris/TetrisPane$DropExecution.class
Binary file not shown.
Binary file added Tetris/bin/tetris/TetrisPane$IShaped.class
Binary file not shown.
Binary file added Tetris/bin/tetris/TetrisPane$JShaped.class
Binary file not shown.
Binary file added Tetris/bin/tetris/TetrisPane$KeyControl.class
Binary file not shown.
Binary file added Tetris/bin/tetris/TetrisPane$LShaped.class
Binary file not shown.
Binary file added Tetris/bin/tetris/TetrisPane$OShaped.class
Binary file not shown.
Binary file added Tetris/bin/tetris/TetrisPane$SShaped.class
Binary file not shown.
Binary file added Tetris/bin/tetris/TetrisPane$TShaped.class
Binary file not shown.
Binary file added Tetris/bin/tetris/TetrisPane$ZShaped.class
Binary file not shown.
Binary file added Tetris/bin/tetris/TetrisPane.class
Binary file not shown.
Binary file added Tetris/bin/tetris/Tetromino.class
Binary file not shown.
52 changes: 30 additions & 22 deletions Tetris/src/tetris/Cell.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import java.awt.Graphics;

/**
* ������
* Cell class for Tetris game
* @author Leslie Leung
*/
public class Cell {
public static final int CELL_SIZE = 25; //һ������Ĵ�С
public static final int CELL_SIZE = 25;

/* ���ӵ�������ɫ */
/* Color constants for cells */
public static final int COLOR_CYAN = 0;
public static final int COLOR_BLUE = 1;
public static final int COLOR_GREEN = 2;
Expand All @@ -19,18 +19,18 @@ public class Cell {
public static final int COLOR_RED = 5;
public static final int COLOR_PINK = 6;

private int color; //���ӵ���ɫ
private int x; //������
private int y; //������
private int color;
private int x;
private int y;

/**
* ���췽��
* @param x ������
* @param y ������
* @param style ���ӵ���ʽ��ͨ����ɫ��ָ��
* Constructor
* @param x X coordinate
* @param y Y coordinate
* @param style Style/color of the cell
*/
public Cell(int x, int y, int style) {
/* ���ݴ���������ʽ�������ӵ���ɫ */
/* Set color based on style */
switch(style) {
case 0: color = COLOR_CYAN; break;
case 1: color = COLOR_BLUE; break;
Expand All @@ -46,40 +46,48 @@ public Cell(int x, int y, int style) {
}

/**
* ���øø��ӵĺ�����
* @param newX �µĺ�����
* Set X coordinate
* @param newX New X coordinate
*/
public void setX(int newX) {
x = newX;
}

/**
* ���øø��ӵ�������
* @param newY �µ�������
* Set Y coordinate
* @param newY New Y coordinate
*/
public void setY(int newY) {
y = newY;
}

/**
* ��ȡ��Cell�ĺ�����
* @return ������
* Get X coordinate
* @return X coordinate
*/
public int getX() {
return x;
}

/**
* ��ȡ��Cell��������
* @return ������
* Get Y coordinate
* @return Y coordinate
*/
public int getY() {
return y;
}

/**
* Get color
* @return Color
*/
public int getColor() {
return color;
}

/**
* ��ͼ����
* @param g Graphics����
* Paint the cell
* @param g Graphics object
*/
public void paintCell(Graphics g) {
switch(color) {
Expand All @@ -106,4 +114,4 @@ public void paintCell(Graphics g) {
break;
}
}
}
}
124 changes: 124 additions & 0 deletions Tetris/src/tetris/GameConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package tetris;

import java.io.Serializable;

public class GameConfig implements Serializable {
private static final long serialVersionUID = 1L;

public static final int DIFFICULTY_EASY = 0;
public static final int DIFFICULTY_MEDIUM = 1;
public static final int DIFFICULTY_HARD = 2;

public static final int LANGUAGE_CHINESE = 0;
public static final int LANGUAGE_ENGLISH = 1;

public static final int RESOLUTION_SMALL = 0;
public static final int RESOLUTION_MEDIUM = 1;
public static final int RESOLUTION_LARGE = 2;

private int difficulty;
private int language;
private int resolution;
private int cellSize;

public GameConfig() {
this.difficulty = DIFFICULTY_MEDIUM;
this.language = LANGUAGE_CHINESE;
this.resolution = RESOLUTION_MEDIUM;
this.cellSize = 25;
}

public int getDifficulty() {
return difficulty;
}

public void setDifficulty(int difficulty) {
this.difficulty = difficulty;
}

public int getLanguage() {
return language;
}

public void setLanguage(int language) {
this.language = language;
}

public int getResolution() {
return resolution;
}

public void setResolution(int resolution) {
this.resolution = resolution;
switch(resolution) {
case RESOLUTION_SMALL:
cellSize = 20;
break;
case RESOLUTION_MEDIUM:
cellSize = 25;
break;
case RESOLUTION_LARGE:
cellSize = 30;
break;
}
}

public int getCellSize() {
return cellSize;
}

public int getSpeedMultiplier() {
switch(difficulty) {
case DIFFICULTY_EASY:
return 2;
case DIFFICULTY_MEDIUM:
return 1;
case DIFFICULTY_HARD:
return 0;
default:
return 1;
}
}

public String getDifficultyText() {
switch(language) {
case LANGUAGE_CHINESE:
switch(difficulty) {
case DIFFICULTY_EASY: return "简单";
case DIFFICULTY_MEDIUM: return "中等";
case DIFFICULTY_HARD: return "困难";
default: return "中等";
}
case LANGUAGE_ENGLISH:
switch(difficulty) {
case DIFFICULTY_EASY: return "Easy";
case DIFFICULTY_MEDIUM: return "Medium";
case DIFFICULTY_HARD: return "Hard";
default: return "Medium";
}
default:
return "中等";
}
}

public String getResolutionText() {
switch(language) {
case LANGUAGE_CHINESE:
switch(resolution) {
case RESOLUTION_SMALL: return "小";
case RESOLUTION_MEDIUM: return "中";
case RESOLUTION_LARGE: return "大";
default: return "中";
}
case LANGUAGE_ENGLISH:
switch(resolution) {
case RESOLUTION_SMALL: return "Small";
case RESOLUTION_MEDIUM: return "Medium";
case RESOLUTION_LARGE: return "Large";
default: return "Medium";
}
default:
return "中";
}
}
}
144 changes: 144 additions & 0 deletions Tetris/src/tetris/GameManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
package tetris;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class GameManager {
private static GameManager instance;

private JFrame mainFrame;
private GameConfig config;
private GameState state;

public static final int SCENE_MENU = 0;
public static final int SCENE_GAME = 1;
public static final int SCENE_SETTINGS = 2;
public static final int SCENE_GAME_OVER = 3;

private int currentScene;

private MenuPanel menuPanel;
private TetrisPane gamePanel;
private SettingsPanel settingsPanel;
private GameOverPanel gameOverPanel;

private GameManager() {
config = new GameConfig();
state = new GameState();
currentScene = SCENE_MENU;
}

public static GameManager getInstance() {
if (instance == null) {
instance = new GameManager();
}
return instance;
}

public void setMainFrame(JFrame frame) {
this.mainFrame = frame;
}

public GameConfig getConfig() {
return config;
}

public GameState getState() {
return state;
}

public JFrame getMainFrame() {
return mainFrame;
}

public int getCurrentScene() {
return currentScene;
}

public void setScene(int sceneType) {
if (mainFrame == null) {
return;
}

JPanel currentPanel = getCurrentPanel();
if (currentPanel != null) {
mainFrame.remove(currentPanel);
}

JPanel newPanel = getPanelForScene(sceneType);
if (newPanel != null) {
mainFrame.add(newPanel);
mainFrame.revalidate();
mainFrame.repaint();
newPanel.requestFocusInWindow();
}

currentScene = sceneType;
}

private JPanel getCurrentPanel() {
switch (currentScene) {
case SCENE_MENU:
return menuPanel;
case SCENE_GAME:
return gamePanel;
case SCENE_SETTINGS:
return settingsPanel;
case SCENE_GAME_OVER:
return gameOverPanel;
default:
return null;
}
}

private JPanel getPanelForScene(int sceneType) {
switch (sceneType) {
case SCENE_MENU:
if (menuPanel == null) {
menuPanel = new MenuPanel();
}
return menuPanel;

case SCENE_GAME:
if (gamePanel == null) {
gamePanel = new TetrisPane();
}
gamePanel.resetGame();
state.reset();
state.startGame();
return gamePanel;

case SCENE_SETTINGS:
if (settingsPanel == null) {
settingsPanel = new SettingsPanel();
}
return settingsPanel;

case SCENE_GAME_OVER:
if (gameOverPanel == null) {
gameOverPanel = new GameOverPanel();
}
return gameOverPanel;

default:
return null;
}
}

public void startNewGame() {
setScene(SCENE_GAME);
}

public void showMenu() {
setScene(SCENE_MENU);
}

public void showSettings() {
setScene(SCENE_SETTINGS);
}

public void showGameOver() {
state.endGame();
setScene(SCENE_GAME_OVER);
}
}
Loading