A small fix for the "Ignore Gravity" action step flag. Currently if you set this flag, your object can't move horizontally nor vertically.
Now we can have monsters that fly, bats, birds, ...
Here's how to fix that.
1/ Modify your "UserSubroutines.asm" script (located in your "Routines\Basic\ModuleScripts\" folder), and add those two subroutines:
2/ Modify the "HandleHorisontalInertia.asm" script (located in the "GameEngineData\Routines\Basic\System\Macros\" folder).
At line 154, add those 2 lines :
At line 199 (just after the "STA nt_hold" line), add those 2 lines :
3/ Modify the "HandleVerticalInertia.asm" script (located in the "GameEngineData\Routines\Basic\System\Macros\" folder).
At line 152, add those 2 lines :
At line 177, add those 2 lines :
4/ And in order to have collisions with solid objects, I had to also modify the TileCollisions.asm script (cf. in your "Project Settings > Script Settings", the "Tile Collision" element to know which one is used in your module).
Around line 118, like this...
Before:
After:
Also uncommenting the line 112:
And also uncommenting the line 128:
Voilà, now for your Game Objects, Monsters... just set it's action flag to "Ignore Gravity" and it can move as you want.
Now we can have monsters that fly, bats, birds, ...
Here's how to fix that.
1/ Modify your "UserSubroutines.asm" script (located in your "Routines\Basic\ModuleScripts\" folder), and add those two subroutines:
Code:
;; temporarly put this subroutine here, but would be better into a custom script.
;; fix for the non moving ignore-gravity-objects (like projectiles) in the platform games:
;; (used by the HandleHorizontalInertia macro)
updateXPosForNonPlayerObjects:
CPX player1_object ;; check if it's the player
BEQ doneUpdatingXPosForNonPlayerObjects ;; if it IS, don't need to update
LDA Object_vulnerability,x
AND #%00100000 ;; check if "ignore gravity" is set
BEQ doneUpdatingXPosForNonPlayerObjects ;; if it is NOT, don't need to update
LDA Object_movement,x
AND #%10000000 ;; check if movement horizontal engaged
BEQ doneUpdatingXPosForNonPlayerObjects ;; if it is NOT, don't need to update
LDA xHold_lo
STA Object_x_lo,x
LDA xHold_hi
STA Object_x_hi,x
;LDA nt_hold
;STA Object_scroll,x ;; don't know what to do with this...
doneUpdatingXPosForNonPlayerObjects:
RTS
;; (used by the HandleVerticalInertia macro)
updateYPosForNonPlayerObjects:
CPX player1_object ;; check if it's the player
BEQ doneUpdatingYPosForNonPlayerObjects ;; if it IS, don't need to update
LDA Object_vulnerability,x
AND #%00100000 ;; check if "ignore gravity" is set
BEQ doneUpdatingYPosForNonPlayerObjects ;; if it is NOT, don't need to update
LDA Object_movement,x
AND #%00100000 ;; check if movement vertical engaged
BEQ doneUpdatingYPosForNonPlayerObjects ;; if it is NOT, don't need to update
LDA yHold_lo
STA Object_y_lo,x
LDA yHold_hi
STA Object_y_hi,x
doneUpdatingYPosForNonPlayerObjects:
RTS
2/ Modify the "HandleHorisontalInertia.asm" script (located in the "GameEngineData\Routines\Basic\System\Macros\" folder).
At line 154, add those 2 lines :
Code:
;; small fix for the ignore gravity objects (maybe issues with other objects in some another cases?)
JSR updateXPosForNonPlayerObjects
;;;; here is a macro that handles player guided right scrolling.
;;;; you can disable right scrolling by simply commenting this one macro out.
At line 199 (just after the "STA nt_hold" line), add those 2 lines :
Code:
;; small fix for the ignore gravity objects (maybe issues with other objects in some another cases?)
JSR updateXPosForNonPlayerObjects
;;; this handles player guided left scrolling
;;; to disable left scrolling, simply comment this one macro out.
3/ Modify the "HandleVerticalInertia.asm" script (located in the "GameEngineData\Routines\Basic\System\Macros\" folder).
At line 152, add those 2 lines :
Code:
;; small fix for the ignore gravity objects (maybe issues with other objects in some another cases?)
JSR updateYPosForNonPlayerObjects
;;;; HERE IS WHERE WE MIGHT ADD DOWNWARD SCROLLING.
At line 177, add those 2 lines :
Code:
;; small fix for the ignore gravity objects (maybe issues with other objects in some another cases?)
JSR updateYPosForNonPlayerObjects
;;; this handles player guided left scrolling
4/ And in order to have collisions with solid objects, I had to also modify the TileCollisions.asm script (cf. in your "Project Settings > Script Settings", the "Tile Collision" element to know which one is used in your module).
Around line 118, like this...
Before:
Code:
;;;;; For top down type games, or games that generally have no gravity but have 4 directional movement,
;;;;; we only need to check potential position and jump to the appropriate label.
; CheckPotentialPosition
After:
Code:
;;;;; For top down type games, or games that generally have no gravity but have 4 directional movement,
;;;;; we only need to check potential position and jump to the appropriate label.
CheckPotentialPosition ;; <<-- uncomment this line (for checking vertical collisions)
CheckForHorizontalCollision ;; <<--- checking horizontal solid collisions
Also uncommenting the line 112:
Code:
CheckPlayerCameraPosition
And also uncommenting the line 128:
Code:
JSR updateHorizontalPosition
Voilà, now for your Game Objects, Monsters... just set it's action flag to "Ignore Gravity" and it can move as you want.