Using a Different Player Object? [4.56]

crazygrouptrio

Active member
Trying to use a different player object depending on the screen/gamestate. I tried adding these lines in Initialization.asm where the player object is created:
Code:
LDA gameState
		CMP #$03
		BEQ otherPlayer
		CreateObject #START_POSITION_PIX_X, #START_POSITION_PIX_Y, #$00, #$00
		JMP +
		otherPlayer:
		CreateObject #START_POSITION_PIX_X, #START_POSITION_PIX_Y, #$01, #$00
		+
Also tried checking the screenflag to no effect. I'm probably just checking gameState incorrectly.
 

mouse spirit

Well-known member
Heres what i did in 4.1.5....

The key lines here are

LDA whoAmI
STA playerToSpawn

PlayerLoseLife.asm
Code:
;;; do loss of life stuff here
	;DEC myLives
	LDA myLives
	BNE gameNotOver
	;;do gameover stuff here.  Warp to screen?  Show animation?  Just restart?
	;JMP RESET
	LDA #GAME_OVER_SCREEN
	STA continueScreen
	
	LDA #$02
	STA temp1
	JMP isGameOver
gameNotOver:
LDA #$04
	STA temp1
	isGameOver:

;;;;;
;;; do warp to continue screen stuff here.
LDA #$00
STA newGameState
 LDA continueMap
 clc
 ADC #$01
 STA temp
 GoToScreen continueScreen, temp, temp1

 LDA whoAmI ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;this used to say #$00 i think
 STA playerToSpawn
; LDX player1_object
; DeactivateCurrentObject
 LDA #$01
 STA loadObjectFlag
 JSR DeactivateAllObjects
 
LDA continuePositionX
STA newX
LDA continuePositionY
STA newY

;;player restart health
LDA #$03
STA myHealth
I created a variable (whoAmI) and i switch it when i gain my new armor.But it would revert to my non armor
when i die because of this code that simply loaded #$00 object to spawn!
So here in this code i told it to load whoAmI at the player spawn.Maybe this can help you.

You instead would have a script in your start level screens that says now whoAmI equals 0 or 1.
When 0, the level gives you character 1.
When 1, the level gives you character 2.

Then when player spawns, spawn as object whoAmI, whether its 0 or 1.

Or yes maybe even do screentype CMP's here to find what whoAmI equalls before spawning.
 

AllDarnDavey

Active member
mouse spirit said:
I created a variable (whoAmI) and i switch it when i gain my new armor.But it would revert to my non armor
when i die because of this code that simply loaded #$00 object to spawn!
So here in this code i told it to load whoAmI at the player spawn.Maybe this can help you.

You instead would have a script in your start level screens that says now whoAmI equals 0 or 1.
When 0, the level gives you character 1.
When 1, the level gives you character 2.

Then when player spawns, spawn as object whoAmI, whether its 0 or 1.

Or yes maybe even do screentype CMP's here to find what whoAmI equalls before spawning.

All good ideas. Personally I'd tie it to gamestate ID query, we can already setup different input configurations based on gamestate, having different player objects vary by gamestate as well seems like a good match.
 

crazygrouptrio

Active member
Thanks for the tips! Gamestate is definitely what I want to go with. Upon further experimentation I can only guess that that point in Initialization happens too early in the process of loading a screen to detect what the screens gamestate is. Putting the same code in doLoadScreen.asm actually checks the gamestate and creates the correct object. So I'll have to get creative in how I execute the player creation code.
 
Top Bottom