I'll be starting another NES game soon and am trying to come up with a different way to handle objects. In my current game, I just have arrays of variables that are accessed by using X or Y:
I can access individual object's variables like so:
This system works fine for objects as long as they have the same number of variables. But what if I want to have an object that doesn't have any health? I could just use the same system but then I would be wasting a variable for an object that doesn't need it.
How have you guys implemented objects into your project? Does it handle cases such as mine?
Code:
MAX OBJECTS = 6
X .dsb 6
Y .dsb 6
Health .dsb 6
State .dsb 6
Animation .dsb 6
X .dsb 6
Y .dsb 6
Health .dsb 6
State .dsb 6
Animation .dsb 6
I can access individual object's variables like so:
Code:
; Change object 0's health to 5
LDX #$00
LDA #$05
STA Health, x
; Add 8 to object 2's X position
LDY #$02
LDA X, y
CLC
ADC #$08
STA X, y
LDX #$00
LDA #$05
STA Health, x
; Add 8 to object 2's X position
LDY #$02
LDA X, y
CLC
ADC #$08
STA X, y
This system works fine for objects as long as they have the same number of variables. But what if I want to have an object that doesn't have any health? I could just use the same system but then I would be wasting a variable for an object that doesn't need it.
How have you guys implemented objects into your project? Does it handle cases such as mine?