A simple Game of Life implementation in Java
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Screen.java 732 B

il y a 11 ans
il y a 11 ans
il y a 11 ans
12345678910111213141516171819202122232425262728293031323334353637
  1. import java.util.Random;
  2. public class Screen {
  3. private int width, height;
  4. public int[] pixels;
  5. private int[] _grid;
  6. Random random = new Random();
  7. public Screen(int width, int height) {
  8. this.width = width;
  9. this.height = height;
  10. pixels = new int[width * height];
  11. _grid = new int[width * height];
  12. }
  13. public void clear() {
  14. for (int x = 0; x < _grid.length; x++) {
  15. pixels[x] = 0;
  16. }
  17. }
  18. public void render() {
  19. for (int x = 0; x < width; x++) {
  20. for (int y = 0; y < height; y++) {
  21. pixels[x+y*width] = random.nextInt();
  22. //pixels[x + y * width] = _grid[x + y * width];
  23. }
  24. }
  25. }
  26. public void draw(int x, int y, int color) {
  27. _grid[x + y * width] = color;
  28. }
  29. }