9Panzer
Well-known member
Another Scrolling gremlin... I feel like I am close but I'm missing something simple.
So in my game there is an input that will allow the player to switch characters. It uses a variable to determine if the player has "unlocked" the character. For this I just have them all unlocked.
When I use the input on the first screen everything works perfectly. But when the player leaves the first screen the input just destroys the player object and doesn't create the new one.
This is my Uber complicated code. 99% sure its got something to do with the scrolling screen data. Can anyone see what I'm missing?
So in my game there is an input that will allow the player to switch characters. It uses a variable to determine if the player has "unlocked" the character. For this I just have them all unlocked.
When I use the input on the first screen everything works perfectly. But when the player leaves the first screen the input just destroys the player object and doesn't create the new one.
This is my Uber complicated code. 99% sure its got something to do with the scrolling screen data. Can anyone see what I'm missing?
LDX player1_object
canSwitchPlayer:
INC character
LDA character
CMP #04 ;; one more than the max
BNE +dontNormalizeValue
LDA #00 ;; normalize the value to 7 if it got bigger than 7
STA character
+dontNormalizeValue
STA character
TXA
PHA
;;; Setting up the player position
LDX player1_object
LDA Object_x_hi,x ;; the current horizontal position
STA tempA
LDA Object_screen,x
ADC #$00
STA tempD
LDA Object_y_hi,x ;; the current vertical position
STA tempB
LDA Object_direction,x ;; the current facing and movements
STA tempC
continueChangePlayerInto:
;;; Destroy old Player and create new one
DestroyObject
CreateObject tempA, tempB, character, #$00, tempD
TXA
STA player1_object ;; store that new created object in the Player 1 var
STA camObject
LDA tempC ;; set back the player directions
STA Object_direction,x
PLA
TAX
doneSwitchingPlayer:
RTS