瀏覽代碼

Go draw some blue lines in Brian's Brain. Right mouse button.

master
Lee 12 年之前
父節點
當前提交
0b21556a57
共有 1 個檔案被更改,包括 11 行新增12 行删除
  1. +11
    -12
      src/Render.java

+ 11
- 12
src/Render.java 查看文件

@@ -212,22 +212,28 @@ public class Render extends Canvas implements Runnable, MouseListener,
}
}
@Override
public void mouseDragged(MouseEvent e) {
int states = Goldfish.getMaxStates(rule) - 1;
public void mouseDraw(MouseEvent e) {
int states = Goldfish.getMaxStates(rule);
if (e.getX() < 0 || e.getY() < 0 || e.getX() / scale >= width || e.getY() / scale >= height)
return;
Patch p = _grid.getPatch(e.getX()/scale, e.getY()/scale);
if (_lastPatch != p) {
if (p.getState() != 0) {
p.setState(0);
} else if (states > 2 && SwingUtilities.isRightMouseButton(e)) {
p.setState(1);
} else {
_grid.getPatch(e.getX() / scale, e.getY() / scale).setState(states);
p.setState(states - 1);
}
_lastPatch = p;
}
e.consume();
}
@Override
public void mouseDragged(MouseEvent e) {
mouseDraw(e);
}
@Override
public void mouseClicked(MouseEvent e) {
@@ -243,14 +249,7 @@ public class Render extends Canvas implements Runnable, MouseListener,
@Override
public void mousePressed(MouseEvent e) {
int states = Goldfish.getMaxStates(rule) - 1;
Patch p = _grid.getPatch(e.getX()/scale, e.getY()/scale);
if (p.getState() == states) {
p.setState(0);
} else {
_grid.getPatch(e.getX() / scale, e.getY() / scale).setState(states);
}
e.consume();
mouseDraw(e);
}
@Override


Loading…
取消
儲存