Skip to content

Commit

Permalink
translated example 5
Browse files Browse the repository at this point in the history
  • Loading branch information
vikkio88 committed May 29, 2020
1 parent bbacfc0 commit b495bfe
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 34 deletions.
51 changes: 23 additions & 28 deletions 05_heaps_tile_group/Game.hx
Original file line number Diff line number Diff line change
@@ -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;
}
}
override function update(dt:Float) {
g.rotation += 0.01;
}
}
13 changes: 7 additions & 6 deletions 05_heaps_tile_group/game.hxml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b495bfe

Please sign in to comment.