Here's a quick tutorial so add the ability to switch your Player into another player object:
I will share here an input script to do that, but it could be used on a tile script or an AI action script...
1) Make your Other player object, for that I recommend to use one of the Game Objects (for this tutorial I will use the last one, the object #15, I will name it "Deamon").
Set it like you did for the Player object, "player" and "Persistent", reactions, a speed / acceleration, animations, ... and the bounding box:
2) Now, create a new, input script "SwitchPlayerObject.asm" with that:
Note: If you want to use another game object than the #15, you can modify it at line 31 of the script.
3) Now, assign that "SwitchPlayerObject.asm" script to your button (I will use the "release" "SELECT" button, for that tutorial) :
Also, you need to assign (again) all the input scripts to your OTHER object (the "Deamon" object in my case), for moving left/right/... stopMoving.. etc the same scripts than the ones assigned to your Player.
4) my script is made to be used as an ability, you can unlock (from an NPC or a pickup... as you want), but if you want to use it from the start, just set "on" the "weapon 3" check box in the Project Infos ("Initial Data"):
I will share here an input script to do that, but it could be used on a tile script or an AI action script...
1) Make your Other player object, for that I recommend to use one of the Game Objects (for this tutorial I will use the last one, the object #15, I will name it "Deamon").
Set it like you did for the Player object, "player" and "Persistent", reactions, a speed / acceleration, animations, ... and the bounding box:
2) Now, create a new, input script "SwitchPlayerObject.asm" with that:
Code:
;; SCRIPT to Switch between my Player object and my Deamon game object
switchPlayer:
;; if the player has this ability (if you don't want that limitation, comment out those 4 lines):
LDA weaponsUnlocked
AND #%00000100 ;; weapon 3 unlocked
BNE canSwitchPlayer ;; he can switch into another object
JMP doneSwitchingPlayer
canSwitchPlayer:
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
TAX
doneSwitchingPlayer:
RTS
Note: If you want to use another game object than the #15, you can modify it at line 31 of the script.
3) Now, assign that "SwitchPlayerObject.asm" script to your button (I will use the "release" "SELECT" button, for that tutorial) :
Also, you need to assign (again) all the input scripts to your OTHER object (the "Deamon" object in my case), for moving left/right/... stopMoving.. etc the same scripts than the ones assigned to your Player.
4) my script is made to be used as an ability, you can unlock (from an NPC or a pickup... as you want), but if you want to use it from the start, just set "on" the "weapon 3" check box in the Project Infos ("Initial Data"):