Lag from too many projectiles? (Platformer Module)

I have been messing around with the platformer module trying to create a metroid style game, and I am really impressed so far.

I only picked up Nesmaker a few days ago and I am surprised at the amount of work I have got done from knowing absolutely nothing.

The specific problem I am having is that I am getting lag.
I can create the projectiles and have them fire the correct direction, from the correct starting point, and have them destruct on touching a solid or edge... but it seems like memory is leaking somewhere.

I can fire less than 10 times before the game starts to run really slowly, whether there are any bullets on the screen or not.
It isn't related to how fast I press the fire button. Even if I wait for the last projectile to disappear before firing again, it builds up and start to lag at about 7 shots.
I am using the slot that starts as the Melee gameobject for the projectile, as I don't plan to have a melee attack in the game.
I have checked and the edge and solid collision drop downs are both set to 'destroy me'

Anyone know why I could be running into lag so quickly?
 

dale_coop

Moderator
Staff member
It lags, because of the numbers of sprite on screens. It's a hardware (NES) limitation.
It will lag when 10-12 sprites (8x8blocs) on screen. And will start no more display when 8 sprites on the same scan line.

For your projectile, you would need to limit the projectile allowed at the same time. I did limit 2 bullets max at the time:
http://nesmakers.com/viewtopic.php?f=3&t=598

PS: since the 4.0.11, you don't need to modify the "SystemVariable.asm" and the "InitLoads.asm" (just add the variable in "Project settings > User variables" with the value of "2" (or whatever limit you want)
 
Just got done making those changes, but I am still having issue.

It seems like the first few shots I take disappear somewhere and never leave memory.

Now what happens is when the player has fired about 7 shots they just cannot fire at all anymore. Its like the full subroutine for getting destroyed is never getting called.

do you have to add the increment var and deactivate object code to both the reaction and collision detection? Or just one of them?
 

dale_coop

Moderator
Staff member
Yes to both. Every time one projectile is destroyed, the limitProjectile needs to be incremented.

Check your projectile has its properties “destroy me (weapon)” (the modified one) for « edge object reaction » and « solid one t reaction »... for when the projectile hits the edge of the screen or a solid tile.
And in the collision script for when it hits a monster.
 
Hmm, I cannot find it in my HandleObjectCollisions_Platform_Simple

Also something else wierd I am noticing:
Sometimes the projectile doesn't actually reach very far from the player.
So sometimes they are disappearing without coming into contact with anything...

EDIT:

The cause for them disappearing early is that the first bullet will disappear the moment I press the fire button again. It then seems that not only does that bullet not get unloaded from memory, it also never increments the counter.
It just disappears...
 
Fixed,

I am not sure which it is, but either having the bullet flagged as player weapon or having action type shootforward was causing it.
Having both unset fixed the issue and it works as intended.

Edit: It was shootforward.
 
Top Bottom