38 lines
1.2 KiB
Plaintext
38 lines
1.2 KiB
Plaintext
(defprop &mut :Player player null)
|
|
(defprop &mut :FlxOgmo3Loader map null)
|
|
(defprop &mut :FlxTilemap walls null)
|
|
(defprop &mut :FlxTypedGroup<Coin> coins null)
|
|
|
|
// TODO make a &void meta
|
|
(defmethod &override create []
|
|
(set map (new FlxOgmo3Loader AssetPaths.turnBasedRPG__ogmo AssetPaths.room_001__json))
|
|
(set walls (map.loadTilemap AssetPaths.tiles__png "walls"))
|
|
(walls.follow)
|
|
(walls.setTileProperties 1 FlxObject.NONE)
|
|
(walls.setTileProperties 2 FlxObject.ANY)
|
|
(add walls)
|
|
(set coins (new FlxTypedGroup<Coin>))
|
|
(add coins)
|
|
(map.loadEntities placeEntities "entities")
|
|
(FlxG.camera.follow player TOPDOWN 1)
|
|
(super.create)
|
|
(return))
|
|
|
|
(defmethod placeEntities [:EntityData entity]
|
|
(case entity.name
|
|
("player"
|
|
(set player (new Player entity.x entity.y))
|
|
(add player))
|
|
("coin"
|
|
(coins.add (new Coin (+ entity.x 4) (+ entity.y 4)))))
|
|
(return))
|
|
|
|
(defmethod &override update [:Float elapsed]
|
|
(super.update elapsed)
|
|
(FlxG.collide player walls)
|
|
(FlxG.overlap player coins playerTouchCoin)
|
|
(return))
|
|
|
|
(defmethod playerTouchCoin [:Player player :Coin coin]
|
|
(when (and player.alive player.exists coin.alive coin.exists)
|
|
(coin.kill))) |