Hi, I wasn't able to work on my competition game for the past few months but now I'm back, and I still don't know what am I going to do in respect to object management.
What I'm programming right now basically goes like that: there's a list of objects (255 for null) and each object has few bytes for attributes (X, Y, Metasprite, Animation Timer) and some spare bytes for whatever the object's internal logic wants to do. It is defined as follows:
The Object ID serves as an index to access their respective AI subroutine in the table. Same with Animations, and the Metasprite table.
The gist of it is that the update loop runs through the whole first row of the table, scanning for valid objects, then jumps to its respective logic subroutine (using the pointers from the Logic table). The "AI" subroutine then does whatever it has to do internally (update timers, update metasprite, move, collide, etc.). I was wondering two things:
1. How do you handle collisions in this case? Actually run a collision detection routine in a separate function to set a flag in the object's internal variables, so it can decide by itself?
2. Is this whole indirection thing too wasteful? Are there better ways to do it without having to copy pointers to ZP to do indirect access?
Everything I wrote ultimately boils down to:
tl;dr: How do you guys do object management in your games?
What I'm programming right now basically goes like that: there's a list of objects (255 for null) and each object has few bytes for attributes (X, Y, Metasprite, Animation Timer) and some spare bytes for whatever the object's internal logic wants to do. It is defined as follows:
Code:
OBJ_MAX = 16
OBJ_LIST .ds OBJ_MAX
OBJ_XPOS .ds OBJ_MAX
OBJ_YPOS .ds OBJ_MAX
(...)
OBJ_LIST .ds OBJ_MAX
OBJ_XPOS .ds OBJ_MAX
OBJ_YPOS .ds OBJ_MAX
(...)
The Object ID serves as an index to access their respective AI subroutine in the table. Same with Animations, and the Metasprite table.
Code:
;Must load slot # into X first
ObjectLogic_Table:
.dw _OBJ_Player
.dw _OBJ_Player2
(...)
Metasprite_Table:
.dw _MS_Projectile_Default
.dw _MS_Umbrella_Up
.dw _MS_Umbrella_Down
.dw _MS_Chara_Up
(...)
ObjectLogic_Table:
.dw _OBJ_Player
.dw _OBJ_Player2
(...)
Metasprite_Table:
.dw _MS_Projectile_Default
.dw _MS_Umbrella_Up
.dw _MS_Umbrella_Down
.dw _MS_Chara_Up
(...)
The gist of it is that the update loop runs through the whole first row of the table, scanning for valid objects, then jumps to its respective logic subroutine (using the pointers from the Logic table). The "AI" subroutine then does whatever it has to do internally (update timers, update metasprite, move, collide, etc.). I was wondering two things:
1. How do you handle collisions in this case? Actually run a collision detection routine in a separate function to set a flag in the object's internal variables, so it can decide by itself?
2. Is this whole indirection thing too wasteful? Are there better ways to do it without having to copy pointers to ZP to do indirect access?
Everything I wrote ultimately boils down to:
tl;dr: How do you guys do object management in your games?