-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
9820b14
commit b894847
Showing
2 changed files
with
94 additions
and
65 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package gazillion; | ||
|
||
import java.awt.*; | ||
import java.swing.*; | ||
|
||
public class QImagePanel extends QPanel { | ||
private BufferedImage image; | ||
|
||
pulic QImagePanel(QPanel parent, QFrame frame, String image){ | ||
super(parent, frame); | ||
this.image = ImageIO.read(new File(image)); | ||
} | ||
|
||
@Override | ||
protected void paintComponent(Graphics g) { | ||
super.paintComponent(g); | ||
g.drawImage(image, 0, 0, null); | ||
} | ||
} |
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,65 +1,75 @@ | ||
package gazillion; | ||
|
||
import quadrillion.*; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
|
||
/** | ||
* QMainMenu: PURELY TEST | ||
* | ||
* @author Unsal Ozturk | ||
* @version 20190328 | ||
*/ | ||
public class QMainMenu extends QPanel { | ||
private JButton newGame; | ||
private JButton resumeGame; | ||
private QGazillionPanel gamePanel; | ||
public QMainMenu(QPanel parent, QFrame frame) { | ||
super(parent, frame); | ||
newGame = new JButton("New Game"); | ||
resumeGame = new JButton("Resume Game"); | ||
ActionListener newGameListener = new ActionListener() { | ||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
QGameBuilder g = new QGameBuilder(); | ||
QGame game = g.setGrid(QGridType.GRID_TYPE_1, 2) | ||
.setGrid(QGridType.GRID_TYPE_2, 1) | ||
.setGrid(QGridType.GRID_TYPE_3, 0) | ||
.setGrid(QGridType.GRID_TYPE_4,1) | ||
.setBoard(QBoardType.BOARD_TYPE_1) | ||
.build(600000); | ||
QGridFactory gridFact = new QGridFactory(); | ||
QBoardFactory boardFact = new QBoardFactory(); | ||
|
||
QPlayer player = new QPlayer(); | ||
QThemeManager man = new QThemeManager(); | ||
|
||
gamePanel = new QGazillionPanel(QMainMenu.this, frame, player, man.getThemes().get(0), game); | ||
resumeGame.setEnabled(true); | ||
frame.setActivePanel(gamePanel); | ||
} | ||
}; | ||
|
||
ActionListener resumeGameListener = new ActionListener() { | ||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
frame.setActivePanel(gamePanel); | ||
} | ||
}; | ||
newGame.addActionListener(newGameListener); | ||
newGame.setEnabled(true); | ||
resumeGame.addActionListener(resumeGameListener); | ||
resumeGame.setEnabled(false); | ||
this.setLayout(new FlowLayout()); | ||
this.add(newGame); | ||
this.add(resumeGame); | ||
} | ||
|
||
public void endGame() { | ||
gamePanel = null; | ||
resumeGame.setEnabled(false); | ||
} | ||
} | ||
package gazillion; | ||
|
||
import quadrillion.*; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
|
||
/** | ||
* QMainMenu: PURELY TEST | ||
* | ||
* @author Unsal Ozturk | ||
* @version 20190328 | ||
*/ | ||
public class QMainMenu extends QPanel { | ||
private JButton newGame; | ||
private JButton resumeGame; | ||
private QImagePanel background; | ||
private QGazillionPanel gamePanel; | ||
public QMainMenu(QPanel parent, QFrame frame) { | ||
super(parent, frame); | ||
newGame = new JButton("New Game"); | ||
resumeGame = new JButton("Resume Game"); | ||
|
||
background = new QImagePanel(parent, frame, "background.jpg"); | ||
@Override | ||
protected void paintComponent(Graphics g) { | ||
|
||
super.paintComponent(g); | ||
g.drawImage(bgImage, 0, 0, null); | ||
} | ||
|
||
ActionListener newGameListener = new ActionListener() { | ||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
QGameBuilder g = new QGameBuilder(); | ||
QGame game = g.setGrid(QGridType.GRID_TYPE_1, 2) | ||
.setGrid(QGridType.GRID_TYPE_2, 1) | ||
.setGrid(QGridType.GRID_TYPE_3, 0) | ||
.setGrid(QGridType.GRID_TYPE_4,1) | ||
.setBoard(QBoardType.BOARD_TYPE_1) | ||
.build(600000); | ||
QGridFactory gridFact = new QGridFactory(); | ||
QBoardFactory boardFact = new QBoardFactory(); | ||
|
||
QPlayer player = new QPlayer(); | ||
QThemeManager man = new QThemeManager(); | ||
|
||
gamePanel = new QGazillionPanel(QMainMenu.this, frame, player, man.getThemes().get(0), game); | ||
resumeGame.setEnabled(true); | ||
frame.setActivePanel(gamePanel); | ||
} | ||
}; | ||
|
||
ActionListener resumeGameListener = new ActionListener() { | ||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
frame.setActivePanel(gamePanel); | ||
} | ||
}; | ||
newGame.addActionListener(newGameListener); | ||
newGame.setEnabled(true); | ||
resumeGame.addActionListener(resumeGameListener); | ||
resumeGame.setEnabled(false); | ||
this.setLayout(new FlowLayout()); | ||
this.add(newGame); | ||
this.add(resumeGame); | ||
} | ||
|
||
public void endGame() { | ||
gamePanel = null; | ||
resumeGame.setEnabled(false); | ||
} | ||
} |