コード例 #1
0
 @Override
 public void mouseClicked(MouseEvent mouseEvent) {
   Board b = bgui.getGridView();
   if (b.getAction() == Board.Action.ADD && bgui.getSelectedComponent().equals("Gizmo")) {
     String gizmoShape = bgui.getGizmoShape();
     Point mouseP = MouseInfo.getPointerInfo().getLocation();
     Point gridP = b.getLocationOnScreen();
     int x = mouseP.x - gridP.x;
     int y = mouseP.y - gridP.y;
     boolean added = false;
     switch (gizmoShape) {
       case "Circle":
         added = m.addCircularBumper(x, y, 0, "circle");
         break;
       case "Triangle":
         added = m.addTriangularBumper(x, y, 0, "triangle");
         break;
       case "Square":
         added = m.addSquareBumper(x, y, 0, "square");
         break;
       case "Teleporter":
         added = m.addTeleporterBumper(x, y, 0, "teleporter");
         break;
       default:
     }
     if (added) {
       bgui.setMessageColor(Color.GREEN);
       bgui.setMessage(gizmoShape + " added!");
     } else {
       bgui.setMessageColor(Color.RED);
       bgui.setMessage("That space is occupied, " + gizmoShape + " cannot be added");
     }
   }
 }
コード例 #2
0
ファイル: Main.java プロジェクト: bartoszl/Gizmoball
 public void setModel(GBallModel model) {
   this.model = model;
   if (gui instanceof RunGUI) gui = new RunGUI(this, model, gui.getFrame());
   else gui = new BuildGUI(this, model, gui.getFrame());
   this.model.addObserver(gui.getGridView());
 }
コード例 #3
0
ファイル: Main.java プロジェクト: bartoszl/Gizmoball
 public void switchToRun(JFrame frame) {
   gui = new RunGUI(this, model, frame);
   model.addObserver(gui.getGridView());
 }