Browse Source

Faster clearing/updating of pixels

master
Lee 12 years ago
parent
commit
a63355cbeb
1 changed files with 6 additions and 8 deletions
  1. +6
    -8
      src/Render.java

+ 6
- 8
src/Render.java View File

@@ -123,16 +123,15 @@ public class Render extends Canvas implements Runnable, MouseListener,
_frame.setVisible(true); _frame.setVisible(true);
} }


private void clear() {
for (int x = 0; x < _pixels.length; x++) {
_pixels[x] = 0;
}
}

int state;
private void update() { private void update() {
for (int i = 0; i < width; i++) { for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) { for (int j = 0; j < height; j++) {
draw(i, j, _grid.getPatch(i, j).getState() * 0xffffff);
state = _grid.getPatch(i, j).getState();
if(_pixels[i + j * width] == state) {
} else {
draw(i, j, state * 0xffffff);
}
} }
} }
} }
@@ -147,7 +146,6 @@ public class Render extends Canvas implements Runnable, MouseListener,
return; return;
} }


clear();
update(); update();


g = bs.getDrawGraphics(); g = bs.getDrawGraphics();


Loading…
Cancel
Save