Okay, here's a rather more advanced-system type question than I usually ask.
Let's say I have a level with a preset number of enemies that don't respawn, like in a Mario game or something. Each enemy has four variables:
Kind of enemy
X & Y position
Status of enemy (live, dead, etc)
The normal thing to do would be to use Types, with something like:
And then update them with a For...Each...Next loop:
In this situation, however, I could also use a bank in the same way, and go through the enemies with a For...Next loop, something like:
Both these solutions could work equally well from a code standpoint.
My question is this: would the Bank method use less or more RAM to store the enemy data than the traditional Type method? And would it be faster or slower?
Let's say I have a level with a preset number of enemies that don't respawn, like in a Mario game or something. Each enemy has four variables:
Kind of enemy
X & Y position
Status of enemy (live, dead, etc)
The normal thing to do would be to use Types, with something like:
Type Enemy Field X,Y Field EnemyType,Status End Type
And then update them with a For...Each...Next loop:
For Enemy.Enemy = Each Enemy If Enemy\Status = Alive ;Draw the correct enemy image from an image strip DrawImage Enemies,Enemy\X,Enemy\Y,Enemy\EnemyType EndIf Next
In this situation, however, I could also use a bank in the same way, and go through the enemies with a For...Next loop, something like:
For CurrentEnemy = 0 To NumOfEnemies - 1 ;Get enemy data Local EnemyStatus = PeekInt(EnemyBank,CurrentEnemy * 16) Local EnemyX = PeekInt(EnemyBank,(CurrentEnemy * 16) + 4) Local EnemyY = PeekInt(EnemyBank,(CurrentEnemy * 16) + 8) Local EnemyType = PeekInt(EnemyBank,(CurrentEnemy * 16) + 12) If EnemyStatus = Alive;Draw the enemy DrawImage Enemies,EnemyX,EnemyY,EnemyType EndIf Next
Both these solutions could work equally well from a code standpoint.
My question is this: would the Bank method use less or more RAM to store the enemy data than the traditional Type method? And would it be faster or slower?