From cf12eb8823865c10026194aa33d89dcba1750314 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 20 Jul 2018 14:05:48 +0200 Subject: [PATCH] Game - Create Grid Iteration Function --- lib/game/Game.dart | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/game/Game.dart b/lib/game/Game.dart index f9851c0..7291f59 100644 --- a/lib/game/Game.dart +++ b/lib/game/Game.dart @@ -1,5 +1,7 @@ import 'dart:html'; +typedef void gridIterator(int x, int y); + class Game { List> grid; CanvasElement canvas; @@ -19,28 +21,29 @@ class Game { int brickW = (canvas.width ~/ grid[0].length); int brickH = (canvas.height ~/ grid.length); - ctx.setFillColorRgb(255, 0,0); ctx.clearRect(0, 0, canvas.width, canvas.height); - for(int y=0;y> buildGrid(int w, int h, Color col) { List> grid = new List(h); - - - for(int y = 0; y< h; y++) { + for (int y = 0; y < h; y++) { grid[y] = new List(w); - for(int x = 0; x< w; x++) { + for (int x = 0; x < w; x++) { grid[y][x] = col; } } @@ -54,10 +57,9 @@ class Color { final int b; const Color(this.r, this.g, this.b); - } // Create 2d array // fill with random colors // cycle colors -// set one color to random new one \ No newline at end of file +// set one color to random new one