diff --git a/05_heaps_tile_group/Game.hx b/05_heaps_tile_group/Game.hx index 63fe602..22b1f2c 100644 --- a/05_heaps_tile_group/Game.hx +++ b/05_heaps_tile_group/Game.hx @@ -1,31 +1,26 @@ -class Game extends hxd.App -{ - static function main() - { - hxd.Res.initLocal(); - - new Game(); - } +class Game extends hxd.App { + static function main() { + hxd.Res.initLocal(); + new Game(); + } - var g:h2d.TileGroup; + var g:h2d.TileGroup; - override function init() - { - // Разбиваем текстуру на кадры по сетке - var tiles = hxd.Res.haxeLogo.toTile().gridFlatten(10, 0, 0); - // создаем группу - g = new h2d.TileGroup(tiles[0], s2d); - // отключим blend mode для группы, это ускорит отрисовку тайлов - g.blendMode = None; - // и добавляем в нее тайлы, произвольно расположенные на экране - for (i in 0...1000) - { - g.add(Std.random(s2d.width), Std.random(s2d.height), tiles[i % tiles.length]); - } - } + override function init() { + // gridFlatten will split a tile into a list of tiles 10x10 + // https://heaps.io/api/h2d/Tile.html#gridFlatten + var tiles = hxd.Res.haxeLogo.toTile().gridFlatten(10, 0, 0); + // we create a TileGroup + g = new h2d.TileGroup(tiles[0], s2d); + // we disable blend mode (for performance purposes) + g.blendMode = None; + // and then we add to it other radom pieces of the initially split tile + for (i in 0...1000) { + g.add(Std.random(s2d.width), Std.random(s2d.height), tiles[i % tiles.length]); + } + } - override function update(dt:Float) - { - g.rotation += 0.01; - } -} \ No newline at end of file + override function update(dt:Float) { + g.rotation += 0.01; + } +} diff --git a/05_heaps_tile_group/game.hxml b/05_heaps_tile_group/game.hxml index 41376b3..63e661e 100644 --- a/05_heaps_tile_group/game.hxml +++ b/05_heaps_tile_group/game.hxml @@ -1,9 +1,10 @@ -# Подключение библиотеки heaps +# linking heaps library -lib heaps -# Подключение библиотеки hldx (работает только под Windows) -# Альтернативно можно использовать hlsdl --lib hldx -# Задаем основной класс приложения с точкой входа +# linking the hldx (DirectX) library (works only under Windows) +# on other OS you can use hlsdl to link SDL, -lib hlsdl +#-lib hldx +-lib hlsdl +# Define the main class of the application with an entry point -main Game -# Выходной файл +# Output file -hl game.hl \ No newline at end of file