Initial Source Commit
This commit is contained in:
parent
f27b385066
commit
2eacf58314
10 changed files with 400 additions and 0 deletions
64
lib/game/Game.dart
Normal file
64
lib/game/Game.dart
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
import 'dart:html';
|
||||
|
||||
class Game {
|
||||
List<List<Color>> grid;
|
||||
CanvasElement canvas;
|
||||
CanvasRenderingContext2D ctx;
|
||||
|
||||
double _oscill = 0.0;
|
||||
bool _fwd = true;
|
||||
|
||||
Game(CanvasElement this.canvas) {
|
||||
grid = buildGrid(5,5, new Color(255, 100, 255));
|
||||
ctx = this.canvas.getContext('2d');
|
||||
}
|
||||
|
||||
void update([num dt]) {}
|
||||
|
||||
void draw([num interp]) {
|
||||
// CanvasRenderingContext2D ctx = this.canvas.getContext('2d');
|
||||
// print(grid.toString());
|
||||
int brickW = (canvas.width ~/ grid[0].length);
|
||||
int brickH = (canvas.height ~/ grid.length);
|
||||
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
for(int y=0;y<grid.length;y++) {
|
||||
for(int x=0;x<grid[y].length;x++) {
|
||||
Color col = grid[y][x];
|
||||
ctx.setFillColorRgb(col.r, col.g, col.b);
|
||||
ctx.fillRect(x*brickW, y*brickH, brickW, brickH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Color _oscillate(Color) {
|
||||
|
||||
}
|
||||
|
||||
List<List<Color>> buildGrid(int w, int h, Color col) {
|
||||
List<List<Color>> grid = new List(h);
|
||||
|
||||
|
||||
for(int y = 0; y< h; y++) {
|
||||
grid[y] = new List(w);
|
||||
for(int x = 0; x< w; x++) {
|
||||
grid[y][x] = col;
|
||||
}
|
||||
}
|
||||
return grid;
|
||||
}
|
||||
}
|
||||
|
||||
class Color {
|
||||
final int r;
|
||||
final int g;
|
||||
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
|
||||
8
lib/game/LoopExample.dart
Normal file
8
lib/game/LoopExample.dart
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import 'package:browserloop/game/Game.dart';
|
||||
|
||||
abstract class LoopExample{
|
||||
Game game;
|
||||
|
||||
void stop() {}
|
||||
void start() {}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue