New Projekt Stukture
This commit is contained in:
@@ -238,6 +238,10 @@ public class Control {
|
|||||||
public void createControlWindow() {
|
public void createControlWindow() {
|
||||||
gui.createControlWindow();
|
gui.createControlWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCells(){
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+81
-2
@@ -5,8 +5,7 @@ import game.Control;
|
|||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.*;
|
||||||
import java.awt.event.KeyListener;
|
|
||||||
|
|
||||||
public class GameWindow {
|
public class GameWindow {
|
||||||
|
|
||||||
@@ -19,6 +18,8 @@ public class GameWindow {
|
|||||||
private int width, height;
|
private int width, height;
|
||||||
private float ratio;
|
private float ratio;
|
||||||
|
|
||||||
|
private boolean mouseLeft = false, mouseRight = false;
|
||||||
|
|
||||||
public GameWindow(String title, Control control, int cellCountX, int cellCountY) {
|
public GameWindow(String title, Control control, int cellCountX, int cellCountY) {
|
||||||
this.cellCountX = cellCountX;
|
this.cellCountX = cellCountX;
|
||||||
this.cellCountY = cellCountY;
|
this.cellCountY = cellCountY;
|
||||||
@@ -49,6 +50,82 @@ public class GameWindow {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
jfGame.getContentPane().addMouseMotionListener(new MouseMotionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseDragged(MouseEvent e)
|
||||||
|
{
|
||||||
|
if(mouseLeft)
|
||||||
|
{
|
||||||
|
// control.setCell(e.getX(), e.getY(), true);
|
||||||
|
control.addCell(e.getX(), e.getY());
|
||||||
|
}
|
||||||
|
else if(mouseRight)
|
||||||
|
{
|
||||||
|
control.setCell(e.getX(), e.getY(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseMoved(MouseEvent e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
gameWindow.getContentPane().addMouseListener(new MouseListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e)
|
||||||
|
{
|
||||||
|
switch(e.getButton())
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
mouseLeft = true;
|
||||||
|
// control.setCell(e.getX(), e.getY(), true);
|
||||||
|
control.addCell(e.getX(), e.getY());
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
mouseRight = true;
|
||||||
|
// control.setCell(e.getX(), e.getY(), false);
|
||||||
|
control.addCell(e.getX(), e.getY());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(MouseEvent e)
|
||||||
|
{
|
||||||
|
switch(e.getButton())
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
mouseLeft = false;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
mouseRight = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseEntered(MouseEvent e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseExited(MouseEvent e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
jfGame.setResizable(false);
|
jfGame.setResizable(false);
|
||||||
|
|
||||||
ratio = (float) (cellCountY) / (float) (cellCountX);
|
ratio = (float) (cellCountY) / (float) (cellCountX);
|
||||||
@@ -83,4 +160,6 @@ public class GameWindow {
|
|||||||
height = (int) (cellCountY * ratio);
|
height = (int) (cellCountY * ratio);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user