Maunuel Mode Prototype
This commit is contained in:
+2
-3
@@ -12,14 +12,13 @@ public class Clock extends Thread{
|
||||
public void start(Control control, GUI gui){
|
||||
|
||||
|
||||
|
||||
Timer t = new Timer();
|
||||
TimerTask tt = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if (running){
|
||||
gui.showGrid(control.getCells());
|
||||
control.showGrid(control.getCells());
|
||||
control.nextGen();
|
||||
|
||||
|
||||
@@ -27,7 +26,7 @@ public class Clock extends Thread{
|
||||
}
|
||||
};
|
||||
|
||||
t.scheduleAtFixedRate(tt, 1000, 200);
|
||||
t.scheduleAtFixedRate(tt, 1000, 20000);
|
||||
|
||||
}
|
||||
|
||||
|
||||
+29
-4
@@ -57,14 +57,21 @@ public class Control {
|
||||
gui = new GUI(this);
|
||||
}
|
||||
|
||||
gui.gameWindow(this.xSize, this.ySize);
|
||||
if (startMode == StartMode.Manuel){
|
||||
gui.manuelGameWindow(this.xSize, this.ySize);
|
||||
} else {
|
||||
gui.gameWindow(this.xSize, this.ySize);
|
||||
}
|
||||
|
||||
|
||||
startGame();
|
||||
|
||||
}
|
||||
|
||||
private void buildManuelGame() {
|
||||
System.out.println("Test");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void generateTask1() {
|
||||
@@ -81,7 +88,7 @@ public class Control {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// cells[1][2] = true;
|
||||
// cells[2][2] = true;
|
||||
@@ -204,7 +211,25 @@ public class Control {
|
||||
}
|
||||
|
||||
|
||||
public void showGrid() {
|
||||
public void showGrid(boolean[][] grid) {
|
||||
gui.showGrid(grid);
|
||||
}
|
||||
|
||||
|
||||
public void addCell(int x, int y) {
|
||||
System.out.print("X" + x + "|" + "Y" + y + " ");
|
||||
|
||||
System.out.println((int) (x / (800f / xSize)));
|
||||
|
||||
// cells[(int) ((x / (800f / xSize)) + ((800f / xSize)/2))][(int) ((y / (800f / ySize)) + ((800f / ySize)/2))] = true;
|
||||
showGrid(cells);
|
||||
|
||||
}
|
||||
|
||||
public void removeCell(int x, int y) {
|
||||
|
||||
cells[Math.round(y/(800f/xSize))][Math.round(y/(800f/ySize))] = false;
|
||||
showGrid(cells);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+73
-14
@@ -64,6 +64,7 @@ public class GUI {
|
||||
|
||||
/* End of Game view Elements */
|
||||
|
||||
private JFrame jfGameManuel;
|
||||
|
||||
public GUI(Control control) {
|
||||
|
||||
@@ -375,20 +376,6 @@ public class GUI {
|
||||
|
||||
draw.setVisible(true);
|
||||
|
||||
jfGame.addMouseMotionListener(new MouseMotionListener() {
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
int x=e.getX();
|
||||
int y=e.getY();
|
||||
System.out.println(x+","+y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
System.out.println("Not Pressed");
|
||||
}
|
||||
});
|
||||
|
||||
jfGame.add(draw);
|
||||
|
||||
jfGame.pack();
|
||||
@@ -397,6 +384,78 @@ public class GUI {
|
||||
jfGame.setVisible(true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void manuelGameWindow(int xSize, int ySize) {
|
||||
this.xSize = xSize;
|
||||
this.ySize = ySize;
|
||||
|
||||
|
||||
jfGameManuel = new JFrame(title);
|
||||
|
||||
jfGameManuel.getContentPane().setPreferredSize(new Dimension(1000, 1000));
|
||||
jfGameManuel.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
jfGameManuel.setResizable(false);
|
||||
|
||||
float ratio = (float)(ySize) / (float)(xSize);
|
||||
draw = new Draw(this.xSize, this.ySize, ratio);
|
||||
jfGameManuel.setBounds(0, 0, 800, 800);
|
||||
|
||||
jfGameManuel.setVisible(true);
|
||||
|
||||
jfGameManuel.addMouseListener(new MouseListener() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
control.startGame();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
jfGameManuel.addMouseMotionListener(new MouseMotionListener() {
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
|
||||
control.removeCell(e.getX(), e.getY());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
control.addCell(e.getX(), e.getY());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
jfGameManuel.add(draw);
|
||||
|
||||
jfGameManuel.pack();
|
||||
jfGameManuel.setLayout(null);
|
||||
jfGameManuel.setLocationRelativeTo(null);
|
||||
jfGameManuel.setVisible(true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void initGameComponents() {
|
||||
|
||||
Reference in New Issue
Block a user