FrankenGraphics
New member
If you're doing an action game, this modification is for you. There are even better ways, but this way is quick and simple.
Projectiles and medusa heads are just popular examples of enemy actors that could benefit from this mod. ANYTHING that doesn't benefit from tile collision should really go on this list. It is also beneficial to include stationary enemies on the list (and they wouldn't even need to update positions .. they can actually skip a lot of code in another routine (HandleUpdateObjects.asm) this tutorial doesn't cover, but let's start here).
What objects should go on the exception list is something you need to decide game-for-game and may change as your design is worked on. In the example, we're only making an exception for the single projectile type.
1) Identify what game object(s) you're using as projectiles. In my case, i've set the object that is called "projectile" by default in the adventure module as my monster projectile, whereas it was originally set to 1 (which would be the one named "melee" in the gui). So, counting from the player object, which is object type 0, my monster projectile is in other words id #3.
2) Search and open HandleTileCollison.asm
3) Right after line 1 (the label), press enter and copy the following:
note that you have to edit that #3 if you have another or several objects you wish to be excempt from tile collisions.
3) Save a copy. In project settings, under the script settings link to the new copy.
4) Done. No more slowdowns... up to a limit of bullets, of course. I just tested 4 bullet generators in my quick test and that worked just fine.
Some precautions and notes:
-The projectile types included in the exception will no longer be able to react against solids. If this is important to your game design, you can insert a custom 1-point collision subroutine into the exception which would be loads leaner than the "do everything" 6-point collision that is currently used for all objects and still be accurate enough for small projectiles and the like. That's for another day. Usually you want player bullets to be wall blockable...
-If you swap around your objects, be sure to swap around the cmp arguments too to match.
-Even better would be to remove all the reduntant JSR / RTS calls done by HandleUpdateObjects and its various subroutines. Those add up to quite a bit of unnecessary overhead, especially since they're repeated once for every active object. This would increase the speed of collision checks for all objects a bit. JSR / RTS pairs are something you want a minimum of in any often-repeated code.
EDIT:
In case anyone is wondering, i was able to get from 4-5 objects (player included) without slowdown to 7-8 objects (player included) without slowdown on average. Both cases including a portion of aimed physics. So it's a significant improvement, but could still be better. Your mileage will vary depending on your constellations of objects that need/doesn't need tile collisions.
Projectiles and medusa heads are just popular examples of enemy actors that could benefit from this mod. ANYTHING that doesn't benefit from tile collision should really go on this list. It is also beneficial to include stationary enemies on the list (and they wouldn't even need to update positions .. they can actually skip a lot of code in another routine (HandleUpdateObjects.asm) this tutorial doesn't cover, but let's start here).
What objects should go on the exception list is something you need to decide game-for-game and may change as your design is worked on. In the example, we're only making an exception for the single projectile type.
1) Identify what game object(s) you're using as projectiles. In my case, i've set the object that is called "projectile" by default in the adventure module as my monster projectile, whereas it was originally set to 1 (which would be the one named "melee" in the gui). So, counting from the player object, which is object type 0, my monster projectile is in other words id #3.
2) Search and open HandleTileCollison.asm
3) Right after line 1 (the label), press enter and copy the following:
Code:
lda Object_type,x
cmp #3
bne +
jsr updateHorizontalPosition
jsr updateVerticalPosition
rts
+
note that you have to edit that #3 if you have another or several objects you wish to be excempt from tile collisions.
3) Save a copy. In project settings, under the script settings link to the new copy.
4) Done. No more slowdowns... up to a limit of bullets, of course. I just tested 4 bullet generators in my quick test and that worked just fine.
Some precautions and notes:
-The projectile types included in the exception will no longer be able to react against solids. If this is important to your game design, you can insert a custom 1-point collision subroutine into the exception which would be loads leaner than the "do everything" 6-point collision that is currently used for all objects and still be accurate enough for small projectiles and the like. That's for another day. Usually you want player bullets to be wall blockable...
-If you swap around your objects, be sure to swap around the cmp arguments too to match.
-Even better would be to remove all the reduntant JSR / RTS calls done by HandleUpdateObjects and its various subroutines. Those add up to quite a bit of unnecessary overhead, especially since they're repeated once for every active object. This would increase the speed of collision checks for all objects a bit. JSR / RTS pairs are something you want a minimum of in any often-repeated code.
EDIT:
In case anyone is wondering, i was able to get from 4-5 objects (player included) without slowdown to 7-8 objects (player included) without slowdown on average. Both cases including a portion of aimed physics. So it's a significant improvement, but could still be better. Your mileage will vary depending on your constellations of objects that need/doesn't need tile collisions.