(RESOLVED) (ver. 4.5.6.) Switching Player Object

Necrozys

Member
Aye everyone need some help. I made a tile that I put in my screens warp in coordinates when I want my player object to switch to another. I used a scipt I found here and tried to modify it for a tile. It works fine after I added ChangeTileAtCollision #$00, #$00 so that you don't keep changing when you pass over it. I want my player to change to a ship object when he goes from a space station to space. But when he comes back to that same screen on the swithcing tile if he is already since he his already a ship I don't want him to change back to his player form. I created a myStatus variable that I update when the tile script is activated. When myStatus is 1 then he is in his spaceship so don't switch him again and when myStatus is 0 he is in player form so then you can switch him to a spaceship. But it doesn't seem to work. Here is the code:

;; SCRIPT to Switch between my Player object and another game object
switchPlayer:
ChangeTileAtCollision #$00, #$00 ;; change tile to walkable
LDA myStatus
CMP #$01 ;; check if myStatus is 1 if so already in spaceship status so don't switch
BNE +doneSwitchingPlayer

canSwitchPlayer:

LDA #$01
STA myStatus ;; change myStatus to 1 the spacehsip status
TXA
PHA
;; first, we will store every placement informations about the player
LDX player1_object
LDA Object_x_hi,x ;; the current horizontal position
; CLC
; ADC #$04
STA tempA
LDA Object_y_hi,x ;; the current vertical position
; CLC
; ADC #$04
STA tempB
LDA Object_direction,x ;; the current facing and movements
; AND #%00000111
STA tempC

;; now, depending of the current object used by the player:
;; we can switch to the new object, or switch back the normal one
LDA Object_type,x
BNE +changeIntoNormal
LDA #15 ;; <-- HERE ! the new player object to transform into
STA tempD
JMP continueChangePlayerInto
changeIntoNormal:
LDA #00 ;; the normal player object
STA tempD

continueChangePlayerInto:
DestroyObject ;; we destroy the current object
CreateObject tempA, tempB, tempD, #$00 ;; and create the new one
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


doneSwitchingPlayer:
RTS

Let me know what I am doing wrong please! My final goal for this tile script is to have three states 0 for player,1 for ship, and 2 for a planet surface rover. And depending on the screentype and the current player status that the tile switches to the right player object for that screen. Thank you!
 
Last edited:

dale_coop

Moderator
Staff member
I think you should use a :
Code:
BEQ +doneSwitchingPlayer
(if myStatus is EQual to 01 then you want to Branch out to +doneSwitchingPlayer)
 
Top Bottom