Completely change naming conventions of field forms and definition macros. Close #32

This commit is contained in:
2021-07-24 14:22:10 -06:00
parent 9d6a4b2054
commit f5a5cdfb40
67 changed files with 433 additions and 447 deletions

View File

@@ -1,8 +1,8 @@
(defmethod new [:Float x :Float y]
(method new [:Float x :Float y]
(super x y)
(loadGraphic AssetPaths.coin__png false 8 8))
(defmethod &override :Void kill []
(method &override :Void kill []
(set alive false)
(FlxTween.tween
this
@@ -14,5 +14,5 @@
ease FlxEase.circOut
onComplete finishKill)))
(defmethod finishKill [_]
(set exists false))
(method finishKill [_]
(set exists false))

View File

@@ -1,4 +1,4 @@
(defvar &inline :Float SPEED 140)
(var &inline :Float SPEED 140)
(defnew [:Float x :Float y :EnemyType _type]
[:EnemyType type _type
@@ -29,7 +29,7 @@
(set offset.x 4)
(set offset.y 2))
(defmethod &override :Void update [:Float elapsed]
(method &override :Void update [:Float elapsed]
(when (and
(or !(= velocity.x 0) !(= velocity.y 0))
(= touching FlxObject.NONE))
@@ -54,7 +54,7 @@
(brain.update elapsed)
(super.update elapsed))
(defmethod :Void idle [:Float elapsed]
(method :Void idle [:Float elapsed]
(cond
(seesPlayer
// TODO (the FSM) here should not be necessary!
@@ -74,7 +74,7 @@
(true
(-= idleTimer elapsed))))
(defmethod :Void chase [:Float elapsed]
(method :Void chase [:Float elapsed]
(if !seesPlayer
(set brain.activeState idle)
(FlxVelocity.moveTowardsPoint this playerPosition (Std.int SPEED))))
(FlxVelocity.moveTowardsPoint this playerPosition (Std.int SPEED))))

View File

@@ -1,7 +1,7 @@
(defprop &mut :Float->Void activeState null)
(prop &mut :Float->Void activeState null)
(defmethod new [:Float->Void initialState]
(method new [:Float->Void initialState]
(set activeState initialState))
(defmethod :Void update [:Float elapsed]
(activeState elapsed))
(method :Void update [:Float elapsed]
(activeState elapsed))

View File

@@ -1,3 +1,3 @@
(defmethod new []
(method new []
(super)
(addChild (new FlxGame 320 240 MenuState)))
(addChild (new FlxGame 320 240 MenuState)))

View File

@@ -1,9 +1,9 @@
(defprop &mut :FlxButton playButton null)
(prop &mut :FlxButton playButton null)
(defmethod &override :Void create []
(method &override :Void create []
(set playButton (new FlxButton 0 0 "Play" clickPlay))
(playButton.screenCenter)
(add playButton))
(defun clickPlay []
(FlxG.switchState (new PlayState)))
(function clickPlay []
(FlxG.switchState (new PlayState)))

View File

@@ -1,10 +1,10 @@
(defprop &mut :Player player null)
(defprop &mut :FlxOgmo3Loader map null)
(defprop &mut :FlxTilemap walls null)
(defprop &mut :FlxTypedGroup<Coin> coins null)
(defprop &mut :FlxTypedGroup<Enemy> enemies null)
(prop &mut :Player player null)
(prop &mut :FlxOgmo3Loader map null)
(prop &mut :FlxTilemap walls null)
(prop &mut :FlxTypedGroup<Coin> coins null)
(prop &mut :FlxTypedGroup<Enemy> enemies null)
(defmethod &override :Void create []
(method &override :Void create []
(set map (new FlxOgmo3Loader AssetPaths.turnBasedRPG__ogmo AssetPaths.room_001__json))
(set walls (map.loadTilemap AssetPaths.tiles__png "walls"))
(walls.follow)
@@ -19,7 +19,7 @@
(FlxG.camera.follow player TOPDOWN 1)
(super.create))
(defmethod :Void placeEntities [:EntityData entity]
(method :Void placeEntities [:EntityData entity]
(case entity.name
("player"
(set player (new Player entity.x entity.y))
@@ -31,14 +31,14 @@
("boss"
(enemies.add (new Enemy (+ entity.x 4) entity.y BOSS)))))
(defmethod &override :Void update [:Float elapsed]
(method &override :Void update [:Float elapsed]
(super.update elapsed)
(FlxG.collide player walls)
(FlxG.overlap player coins playerTouchCoin)
(FlxG.collide enemies walls)
(enemies.forEachAlive checkEnemyVision))
(defmethod :Void checkEnemyVision [:Enemy enemy]
(method :Void checkEnemyVision [:Enemy enemy]
(if (walls.ray (enemy.getMidpoint) (player.getMidpoint))
{
(set enemy.seesPlayer true)
@@ -46,6 +46,6 @@
}
(set enemy.seesPlayer false)))
(defmethod playerTouchCoin [:Player player :Coin coin]
(method playerTouchCoin [:Player player :Coin coin]
(when (and player.alive player.exists coin.alive coin.exists)
(coin.kill)))
(coin.kill)))

View File

@@ -1,6 +1,6 @@
(defvar &inline :Float SPEED 200)
(var &inline :Float SPEED 200)
(defmethod new [:Float x :Float y]
(method new [:Float x :Float y]
(super x y)
(loadGraphic AssetPaths.player__png true 16 16)
(setFacingFlip FlxObject.LEFT false false)
@@ -12,7 +12,7 @@
(setSize 8 8)
(offset.set 4 4))
(defmethod :Void updateMovement []
(method :Void updateMovement []
(let [[&mut up &mut down &mut left &mut right]
(map [[UP W] [DOWN S] [LEFT A] [RIGHT D]] FlxG.keys.anyPressed)]
(when (and up down)
@@ -62,6 +62,6 @@
(otherwise
(return))))))
(defmethod &override update [:Float elapsed]
(method &override update [:Float elapsed]
(updateMovement)
(super.update elapsed))
(super.update elapsed))