[common] added GameState

This commit is contained in:
2018-01-25 22:55:39 +03:00
parent 36c5f161fe
commit 7ac181ed5a
16 changed files with 121 additions and 208 deletions

View File

@@ -1,5 +1,7 @@
package ru.m.tankz; package ru.m.tankz;
import ru.m.tankz.game.ClassicGame;
import ru.m.tankz.game.Game;
import flash.ui.Keyboard; import flash.ui.Keyboard;
import flash.events.KeyboardEvent; import flash.events.KeyboardEvent;
import flash.text.Font; import flash.text.Font;
@@ -10,8 +12,6 @@ import haxework.resources.IResources;
import haxework.gui.VGroupView; import haxework.gui.VGroupView;
import haxework.gui.ViewBuilder; import haxework.gui.ViewBuilder;
import haxework.gui.ButtonView; import haxework.gui.ButtonView;
import flash.display.Sprite;
import haxework.gui.IGroupView;
import ru.m.tankz.PacketBuilder; import ru.m.tankz.PacketBuilder;
import haxework.log.JSLogger; import haxework.log.JSLogger;
import haxework.gui.frame.IFrameSwitcher; import haxework.gui.frame.IFrameSwitcher;
@@ -74,6 +74,8 @@ class Client implements IConnectionHandler {
view.switcher.change(StartFrame.ID); view.switcher.change(StartFrame.ID);
} }
}); });
Provider.setFactory(Game, ClassicGame, ClassicGame.TYPE);
} }
public function onPress(view:ButtonView):Void { public function onPress(view:ButtonView):Void {

View File

@@ -1,6 +1,6 @@
package ru.m.tankz.view.frames; package ru.m.tankz.view.frames;
import ru.m.tankz.config.Config; import ru.m.tankz.game.GameState;
import ru.m.tankz.control.PlayerControl; import ru.m.tankz.control.PlayerControl;
import flash.events.Event; import flash.events.Event;
import haxe.Timer; import haxe.Timer;
@@ -9,8 +9,6 @@ import haxework.gui.ViewBuilder;
import haxework.provider.Provider; import haxework.provider.Provider;
import protohx.Message; import protohx.Message;
import ru.m.connect.IConnection; import ru.m.connect.IConnection;
import ru.m.tankz.config.ConfigBundle;
import ru.m.tankz.game.ClassicGame;
import ru.m.tankz.game.Game; import ru.m.tankz.game.Game;
import ru.m.tankz.proto.pack.GameUpdateResponse; import ru.m.tankz.proto.pack.GameUpdateResponse;
@@ -29,15 +27,15 @@ class GameFrame extends VGroupView implements ViewBuilder implements IPacketHand
} }
public function onShow():Void { public function onShow():Void {
var config:Config = Provider.get(Config); var state:GameState = Provider.get(GameState);
game = switch (config.type) { game = Provider.build(Game, state.type);
case ClassicGame.TYPE: new ClassicGame(config); if (game == null) {
case x: throw 'Unsupported game type "${x}"'; throw 'Unsupported game type "${state.type}"';
} }
game.engine.listeners.push(render); game.engine.listeners.push(render);
game.start(); game.start(state);
for (index in 0...game.config.getTeam('human').size) { for (human in state.players['human'].iterator()) {
game.setControl({team:'human', index:index}, PlayerControl.forPlayer(index)); game.setControl({team:'human', index:human.index}, PlayerControl.forPlayer(human.index));
} }
content.addEventListener(Event.ENTER_FRAME, redraw); content.addEventListener(Event.ENTER_FRAME, redraw);
Provider.get(IConnection).packetHandler.addListener(this); Provider.get(IConnection).packetHandler.addListener(this);

View File

@@ -1,14 +1,14 @@
package ru.m.tankz.view.frames; package ru.m.tankz.view.frames;
import ru.m.tankz.config.Config; import ru.m.tankz.game.GameState;
import ru.m.tankz.game.ClassicGame; import ru.m.tankz.game.ClassicGame;
import ru.m.tankz.config.ConfigBundle;
import haxework.gui.frame.IFrameSwitcher; import haxework.gui.frame.IFrameSwitcher;
import haxework.provider.Provider; import haxework.provider.Provider;
import haxework.gui.ButtonView; import haxework.gui.ButtonView;
import haxework.gui.ViewBuilder; import haxework.gui.ViewBuilder;
import haxework.gui.VGroupView; import haxework.gui.VGroupView;
@:template("layout/frames/start.json", "layout/styles.json") @:template("layout/frames/start.json", "layout/styles.json")
class StartFrame extends VGroupView implements ViewBuilder { class StartFrame extends VGroupView implements ViewBuilder {
@@ -28,11 +28,8 @@ class StartFrame extends VGroupView implements ViewBuilder {
} }
} }
private function startGame(players:Int):Void { private function startGame(humans:Int):Void {
var config = ConfigBundle.get(ClassicGame.TYPE, 0); Provider.set(GameState, ClassicGame.buildState(0, humans));
config.getTeam('human').size = players;
config.getTeam('bot').size = 2 + 2 * players;
Provider.set(Config, config);
Provider.get(IFrameSwitcher).change(GameFrame.ID); Provider.get(IFrameSwitcher).change(GameFrame.ID);
} }
} }

View File

@@ -3,7 +3,6 @@ map:
cellHeight: 22 cellHeight: 22
gridWidth: 26 gridWidth: 26
gridHeight: 26 gridHeight: 26
bricks: []
bricks: bricks:
# border # border
@@ -37,7 +36,6 @@ bricks:
teams: teams:
- id: human - id: human
size: 2
spawnInterval: 0 spawnInterval: 0
points: points:
- type: eagle - type: eagle
@@ -56,7 +54,6 @@ teams:
y: 24 y: 24
direction: top direction: top
- id: bot - id: bot
size: 6
spawnInterval: 3000 spawnInterval: 3000
points: points:
- type: tank - type: tank

View File

@@ -1,161 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg"
><metadata
></metadata
><defs
><font horiz-adv-x="300"
><font-face font-family="8BIT WONDER" units-per-em="300" ascent="300" descent="0"
></font-face
><missing-glyph horiz-adv-x="150" d="M19 0V300H131V0H19ZM38 19h75V281H38V19Z"
></missing-glyph
><glyph unicode=" " horiz-adv-x="150" d=""
></glyph
><glyph unicode="#" d="M300 0H0V300H300V0ZM250 50V250H50V50H250Z"
></glyph
><glyph unicode="(" horiz-adv-x="150" d="M150 0H25V25H0V225H25v25H150V200H100V50h50V0Z"
></glyph
><glyph unicode=")" horiz-adv-x="150" d="M150 25H125V0H0V50H50V200H0v50H125V225h25V25Z"
></glyph
><glyph unicode="*" d="M250 220L230 200H220l-20 20v10l20 20h10l20 -20V220ZM200 165L185 150H165l-15 15v20l15 15h20l15 -15V165ZM150 110L140 100H110l-10 10v30l10 10h30l10 -10V110ZM50 220L30 200H20L0 220v10l20 20H30L50 230V220ZM100 165L85 150H65L50 165v20l15 15H85l15 -15V165ZM200 65L185 50H165L150 65V85l15 15h20L200 85V65ZM250 20L230 0H220L200 20V30l20 20h10L250 30V20ZM100 65L85 50H65L50 65V85l15 15H85L100 85V65ZM50 20L30 0H20L0 20V30L20 50H30L50 30V20Z"
></glyph
><glyph unicode="0" d="M250 25H225V0H25V25H0V225H25v25H225V225h25V25ZM150 150v50H100V150h50ZM150 50v50H100V50h50Z"
></glyph
><glyph unicode="1" horiz-adv-x="150" d="M100 0H0V200H-25v50H75V225h25V0Z"
></glyph
><glyph unicode="2" d="M250 0H0V125H25v25H150v50H0v50H225V225h25V125H225V100H100V50H250V0Z"
></glyph
><glyph unicode="3" d="M250 25H225V0H0V50H150v50H75v50h75v50H0v50H225V225h25V150H225V100h25V25Z"
></glyph
><glyph unicode="4" d="M250 0H150V100H25v25H0V250H100V150h50V250H250V0Z"
></glyph
><glyph unicode="5" d="M250 25H225V0H0V50H150v50H25v25H0V250H250V200H100V150H225V125h25V25Z"
></glyph
><glyph unicode="6" d="M250 25H225V0H25V25H0V225H25v25H250V200H100V150H225V125h25V25ZM150 50v50H100V50h50Z"
></glyph
><glyph unicode="7" d="M250 0H150V200H0v50H225V225h25V0Z"
></glyph
><glyph unicode="8" d="M250 25H225V0H25V25H0v75H25v50H0v75H25v25H225V225h25V150H225V100h25V25ZM150 150v50H100V150h50ZM150 50v50H100V50h50Z"
></glyph
><glyph unicode="9" d="M250 25H225V0H0V50H150v50H25v25H0V225H25v25H225V225h25V25ZM150 150v50H100V150h50Z"
></glyph
><glyph unicode="A" d="M250 0H150V100H100V0H0V225H25v25H225V225h25V0ZM150 150v50H100V150h50Z"
></glyph
><glyph unicode="B" d="M250 25H225V0H0V250H225V225h25V150H225V100h25V25ZM150 150v50H100V150h50ZM150 50v50H100V50h50Z"
></glyph
><glyph unicode="C" d="M250 0H25V25H0V225H25v25H250V200H100V50H250V0Z"
></glyph
><glyph unicode="D" d="M250 25H225V0H0V250H225V225h25V25ZM150 50V200H100V50h50Z"
></glyph
><glyph unicode="E" d="M250 0H25V25H0V225H25v25H250V200H100V150h75V100H100V50H250V0Z"
></glyph
><glyph unicode="F" d="M250 200H100V150h75V100H100V0H0V225H25v25H250V200Z"
></glyph
><glyph unicode="G" d="M250 0H25V25H0V225H25v25H250V200H100V50h50v50H125v50H250V0Z"
></glyph
><glyph unicode="H" d="M250 0H150V100H100V0H0V250H100V150h50V250H250V0Z"
></glyph
><glyph unicode="I" horiz-adv-x="150" d="M100 0H0V250H100V0Z"
></glyph
><glyph unicode="J" d="M250 25H225V0H0V50H150V250H250V25Z"
></glyph
><glyph unicode="K" d="M250 0H150V100H100V0H0V250H100V150h50V250H250V150H225V100h25V0Z"
></glyph
><glyph unicode="L" d="M250 0H0V250H100V50H250V0Z"
></glyph
><glyph unicode="M" horiz-adv-x="450" d="M400 0H300V200H250V0H150V200H100V0H0V250H375V225h25V0Z"
></glyph
><glyph unicode="N" d="M250 0H150V200H100V0H0V250H225V225h25V0Z"
></glyph
><glyph unicode="O" d="M250 25H225V0H25V25H0V225H25v25H225V225h25V25ZM150 50V200H100V50h50Z"
></glyph
><glyph unicode="P" d="M250 125H225V100H100V0H0V250H225V225h25V125ZM150 150v50H100V150h50Z"
></glyph
><glyph unicode="Q" d="M250 25H225V0H25V25H0V225H25v25H225V225h25V25ZM150 50V200H100V50h50Z"
></glyph
><glyph unicode="R" d="M250 0H150V100H100V0H0V250H225V225h25V150H225V100h25V0ZM150 150v50H100V150h50Z"
></glyph
><glyph unicode="S" d="M250 25H225V0H0V50H150v50H25v25H0V225H25v25H250V200H100V150H225V125h25V25Z"
></glyph
><glyph unicode="T" d="M250 200H175V0H75V200H0v50H250V200Z"
></glyph
><glyph unicode="U" d="M250 25H225V0H25V25H0V250H100V50h50V250H250V25Z"
></glyph
><glyph unicode="V" d="M250 25H225V0H0V250H100V50h50V250H250V25Z"
></glyph
><glyph unicode="W" horiz-adv-x="450" d="M400 25H375V0H0V250H100V50h50V250H250V50h50V250H400V25Z"
></glyph
><glyph unicode="X" d="M250 0H150V100H100V0H0V100H25v50H0V250H100V150h50V250H250V150H225V100h25V0Z"
></glyph
><glyph unicode="Y" d="M250 125H225V100H175V0H75V100H25v25H0V250H100V150h50V250H250V125Z"
></glyph
><glyph unicode="Z" d="M250 0H0V125H25v25H150v50H0v50H250V125H225V100H100V50H250V0Z"
></glyph
><glyph unicode="[" horiz-adv-x="150" d="M150 0H0V250H150V200H100V50h50V0Z"
></glyph
><glyph unicode="]" horiz-adv-x="150" d="M150 0H0V50H50V200H0v50H150V0Z"
></glyph
><glyph unicode="a" d="M250 0H150V100H100V0H0V225H25v25H225V225h25V0ZM150 150v50H100V150h50Z"
></glyph
><glyph unicode="b" d="M250 25H225V0H0V250H225V225h25V150H225V100h25V25ZM150 150v50H100V150h50ZM150 50v50H100V50h50Z"
></glyph
><glyph unicode="c" d="M250 0H25V25H0V225H25v25H250V200H100V50H250V0Z"
></glyph
><glyph unicode="d" d="M250 25H225V0H0V250H225V225h25V25ZM150 50V200H100V50h50Z"
></glyph
><glyph unicode="e" d="M250 0H25V25H0V225H25v25H250V200H100V150h75V100H100V50H250V0Z"
></glyph
><glyph unicode="f" d="M250 200H100V150h75V100H100V0H0V225H25v25H250V200Z"
></glyph
><glyph unicode="g" d="M250 0H25V25H0V225H25v25H250V200H100V50h50v50H125v50H250V0Z"
></glyph
><glyph unicode="h" d="M250 0H150V100H100V0H0V250H100V150h50V250H250V0Z"
></glyph
><glyph unicode="i" horiz-adv-x="150" d="M100 0H0V250H100V0Z"
></glyph
><glyph unicode="j" d="M250 25H225V0H0V50H150V250H250V25Z"
></glyph
><glyph unicode="k" d="M250 0H150V100H100V0H0V250H100V150h50V250H250V150H225V100h25V0Z"
></glyph
><glyph unicode="l" d="M250 0H0V250H100V50H250V0Z"
></glyph
><glyph unicode="m" horiz-adv-x="450" d="M400 0H300V200H250V0H150V200H100V0H0V250H375V225h25V0Z"
></glyph
><glyph unicode="n" d="M250 0H150V200H100V0H0V250H225V225h25V0Z"
></glyph
><glyph unicode="o" d="M250 25H225V0H25V25H0V225H25v25H225V225h25V25ZM150 50V200H100V50h50Z"
></glyph
><glyph unicode="p" d="M250 125H225V100H100V0H0V250H225V225h25V125ZM150 150v50H100V150h50Z"
></glyph
><glyph unicode="q" d="M250 25H225V0H25V25H0V225H25v25H225V225h25V25ZM150 50V200H100V50h50Z"
></glyph
><glyph unicode="r" d="M250 0H150V100H100V0H0V250H225V225h25V150H225V100h25V0ZM150 150v50H100V150h50Z"
></glyph
><glyph unicode="s" d="M250 25H225V0H0V50H150v50H25v25H0V225H25v25H250V200H100V150H225V125h25V25Z"
></glyph
><glyph unicode="t" d="M250 200H175V0H75V200H0v50H250V200Z"
></glyph
><glyph unicode="u" d="M250 25H225V0H25V25H0V250H100V50h50V250H250V25Z"
></glyph
><glyph unicode="v" d="M250 25H225V0H0V250H100V50h50V250H250V25Z"
></glyph
><glyph unicode="w" horiz-adv-x="450" d="M400 25H375V0H0V250H100V50h50V250H250V50h50V250H400V25Z"
></glyph
><glyph unicode="x" d="M250 0H150V100H100V0H0V100H25v50H0V250H100V150h50V250H250V150H225V100h25V0Z"
></glyph
><glyph unicode="y" d="M250 125H225V100H175V0H75V100H25v25H0V250H100V150h50V250H250V125Z"
></glyph
><glyph unicode="z" d="M250 0H0V125H25v25H150v50H0v50H250V125H225V100H100V50H250V0Z"
></glyph
></font
></defs
><g style="font-family: &quot;8BIT WONDER&quot;; font-size:50;fill:black"
><text x="20" y="50"
>!&quot;#$%&amp;&#39;()*+,-./0123456789:;&#229;&lt;&gt;?</text
><text x="20" y="100"
>@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_</text
><text x="20" y="150"
>` abcdefghijklmnopqrstuvwxyz|{}~</text
></g
></svg
>

Before

Width:  |  Height:  |  Size: 7.4 KiB

View File

@@ -14,7 +14,6 @@ typedef MapConfig = {
var cellHeight:Float; var cellHeight:Float;
var gridWidth:Int; var gridWidth:Int;
var gridHeight:Int; var gridHeight:Int;
var bricks:Array<BrickConfig>;
} }
typedef BrickConfig = { typedef BrickConfig = {
@@ -31,9 +30,12 @@ typedef BulletConfig = {
} }
typedef TankConfig = { typedef TankType = {
var group:String; var group:String;
var type:String; var type:String;
}
typedef TankConfig = { > TankType,
var width:Float; var width:Float;
var height:Float; var height:Float;
var speed:Float; var speed:Float;

View File

@@ -20,20 +20,10 @@ class ConfigBundle {
return raw; return raw;
} }
public static function get(type:String, level:Int):Config { public static function get(type:String):Config {
switch (type) { switch (type) {
case ClassicGame.TYPE: case ClassicGame.TYPE:
var source:ConfigSource = convert(Yaml.parse(Assets.getText('resources/config/${type}.yaml'), Parser.options().useObjects())); var source:ConfigSource = convert(Yaml.parse(Assets.getText('resources/config/${type}.yaml'), Parser.options().useObjects()));
var bricksData:String = Assets.getText('resources/levels/level00${level}.txt');
var bricks:Array<BrickConfig> = [];
for (line in ~/\s+/g.split(bricksData)) {
for (c in line.split('')) {
if (c.length > 0) {
bricks.push(source.bricks[Std.parseInt(c) + 1]);
}
}
}
source.map.bricks = bricks;
var tanks:Array<TankConfig> = []; var tanks:Array<TankConfig> = [];
for (group in Reflect.fields(source.tanks)) { for (group in Reflect.fields(source.tanks)) {
var data:Array<TankConfig> = Reflect.field(source.tanks, group); var data:Array<TankConfig> = Reflect.field(source.tanks, group);

View File

@@ -0,0 +1,22 @@
package ru.m.tankz.config;
import openfl.Assets;
import ru.m.tankz.game.Game;
import ru.m.tankz.config.Config;
class MapBundle {
public static function get(type:GameType, config:Config, level:Int):Array<BrickConfig> {
var bricksData:String = Assets.getText('resources/levels/level00${level}.txt');
var bricks:Array<BrickConfig> = [];
for (line in ~/\s+/g.split(bricksData)) {
for (c in line.split('')) {
if (c.length > 0) {
bricks.push(config.bricks[Std.parseInt(c) + 1]);
}
}
}
return bricks;
}
}

View File

@@ -122,7 +122,8 @@ class Engine implements ControlHandler {
case TankAction.MOVE(direction): case TankAction.MOVE(direction):
tank.move(direction); tank.move(direction);
case TankAction.LEVEL_UP(level): case TankAction.LEVEL_UP(level):
tank.config = config.getTank('player', Std.string(Std.int(Math.min(Std.parseInt(tank.config.type) + level, 3)))); // ToDo:
tank.config = config.getTank('human', Std.string(Std.int(Math.min(Std.parseInt(tank.config.type) + level, 3))));
case TankAction.STOP: case TankAction.STOP:
tank.stop(); tank.stop();
case TankAction.SHOT: case TankAction.SHOT:

View File

@@ -1,5 +1,6 @@
package ru.m.tankz.game; package ru.m.tankz.game;
import ru.m.tankz.game.GameState.PlayerState;
import ru.m.tankz.bot.Bot; import ru.m.tankz.bot.Bot;
import ru.m.tankz.game.Game; import ru.m.tankz.game.Game;
import ru.m.tankz.config.Config; import ru.m.tankz.config.Config;
@@ -9,14 +10,43 @@ class ClassicGame extends Game {
public static var TYPE(default, never):GameType = 'classic'; public static var TYPE(default, never):GameType = 'classic';
public function new(config:Config) { public static var HUMAN(default, never):TeamId = 'human';
super(TYPE, config); public static var BOT(default, never):TeamId = 'bot';
public function new() {
super(TYPE);
} }
override public function start():Void { override public function start(state:GameState):Void {
super.start(); super.start(state);
for (player in teams.get('bot').players) { for (player in teams.get(BOT).players) {
setControl(player.id, new Bot()); setControl(player.id, new Bot());
} }
} }
public static function buildState(level:Int, humans:Int):GameState {
var state = new GameState();
state.type = TYPE;
state.level = level;
state.players[HUMAN] = new Map();
state.players[BOT] = new Map();
for (i in 0...humans) {
state.players[HUMAN][i] = {
index:i,
tank:{
group: HUMAN,
type: '1'
},
life:3,
};
}
for (i in 0...humans*2+2) {
state.players[BOT][i] = {
index:i,
tank:null,
life:-1,
};
}
return state;
}
} }

View File

@@ -1,5 +1,7 @@
package ru.m.tankz.game; package ru.m.tankz.game;
import ru.m.tankz.config.ConfigBundle;
import ru.m.tankz.config.MapBundle;
import ru.m.tankz.game.Spawner; import ru.m.tankz.game.Spawner;
import ru.m.tankz.core.Entity; import ru.m.tankz.core.Entity;
import ru.m.tankz.core.Eagle; import ru.m.tankz.core.Eagle;
@@ -25,15 +27,16 @@ typedef PlayerId = {
class Game implements EngineListener { class Game implements EngineListener {
public var type(default, null):GameType; public var type(default, null):GameType;
public var state(default, null):GameState;
public var teams(default, null):Map<TeamId, Team>; public var teams(default, null):Map<TeamId, Team>;
public var config(default, null):Config; public var config(default, null):Config;
public var engine(default, null):Engine; public var engine(default, null):Engine;
private var spawners:Map<TeamId, Spawner>; private var spawners:Map<TeamId, Spawner>;
public function new(type:GameType, config:Config) { public function new(type:GameType) {
this.type = type; this.type = type;
this.config = config; this.config = ConfigBundle.get(type);
this.engine = new Engine(config); this.engine = new Engine(config);
engine.listeners.push(this); engine.listeners.push(this);
} }
@@ -53,13 +56,16 @@ class Game implements EngineListener {
entity.rect.direction = Direction.fromString(point.direction); entity.rect.direction = Direction.fromString(point.direction);
} }
public function start():Void { public function start(state:GameState):Void {
this.state = state;
var bricks = MapBundle.get(type, config, state.level);
engine.map.setData(bricks);
teams = new Map<TeamId, Team>(); teams = new Map<TeamId, Team>();
spawners = new Map<TeamId, Spawner>(); spawners = new Map<TeamId, Spawner>();
for (teamConfig in config.teams) { for (teamConfig in config.teams) {
var team = new Team(teamConfig); var team = new Team(teamConfig);
for (index in 0...team.config.size) { for (playerState in state.players.get(team.id)) {
var player = new Player({team:team.id, index:index}); var player = new Player({team:team.id, index:playerState.index});
team.players.push(player); team.players.push(player);
teams.set(team.id, team); teams.set(team.id, team);
} }

View File

@@ -0,0 +1,24 @@
package ru.m.tankz.game;
import ru.m.tankz.game.Game;
import ru.m.tankz.config.Config;
typedef PlayerState = {
var index:Int;
var tank:TankType;
var life:Int;
}
class GameState {
public var type:GameType;
public var level:Int;
public var players:Map<TeamId, Map<Int, PlayerState>>;
public function new() {
type = null;
level = -1;
players = new Map();
}
}

View File

@@ -28,13 +28,18 @@ class LevelMap {
gridWidth = config.gridWidth; gridWidth = config.gridWidth;
gridHeight = config.gridHeight; gridHeight = config.gridHeight;
bricksMap = new HashMap(); bricksMap = new HashMap();
bricks = [];
grid = new Grid( grid = new Grid(
Std.int(cellWidth / 2), Std.int(cellWidth / 2),
Std.int(cellHeight / 2), Std.int(cellHeight / 2),
Std.int(cellWidth * gridWidth), Std.int(cellWidth * gridWidth),
Std.int(cellHeight * gridHeight) Std.int(cellHeight * gridHeight)
); );
bricks = Lambda.array(Lambda.mapi(config.bricks, function(i:Int, brickConfig:BrickConfig):Brick { }
public function setData(data:Array<BrickConfig>):Void {
bricksMap = new HashMap();
bricks = Lambda.array(Lambda.mapi(data, function(i:Int, brickConfig:BrickConfig):Brick {
var cellX = Std.int(i % gridWidth); var cellX = Std.int(i % gridWidth);
var cellY = Std.int(Math.floor(i / gridHeight)); var cellY = Std.int(Math.floor(i / gridHeight));
var cells:HashMap<Point, GridCell> = new HashMap(); var cells:HashMap<Point, GridCell> = new HashMap();