Player spawn code on screen warp ?

Mugi

Member
....I can't seem to locate this.

What im doing here is that i created a trigger system that allows me to identify if i am on a specific screen in my game, and im trying to change the way the player spawns when a specific screen is warped into,
but i cant see to find where the code involving this actually happens.

there's the warptoscreen.asm which is the code for the warp tiles.
there's GotoScreen macro
there's the loadscreen macro

but none of the above seem to hold any clear explanations of how it is decided that how the player spawns into a new screen. (maybe i was just expecting it to be too easy and just find a CreateObject from one of those, lol)

any ideas ?
 
Mugi said:
....I can't seem to locate this.

What im doing here is that i created a trigger system that allows me to identify if i am on a specific screen in my game, and im trying to change the way the player spawns when a specific screen is warped into,
but i cant see to find where the code involving this actually happens.

there's the warptoscreen.asm which is the code for the warp tiles.
there's GotoScreen macro
there's the loadscreen macro

but none of the above seem to hold any clear explanations of how it is decided that how the player spawns into a new screen. (maybe i was just expecting it to be too easy and just find a CreateObject from one of those, lol)

any ideas ?

What do you mean "change how the player spawns" what are you planning on doing? (If you don't mind me asking)
 

Mugi

Member
nevermind, i figured it out. (same thing everytime.... look for something for 3 hours, and when you finally ask for help, you find it 2 seconds later -_-)

just for the sake of clarification, here's what i created.

1) i made a new variable called "stageSelectTrigger"
2) i added a code to warp tiles, that toggles this everytime a warp tile is used.
-- you warp, it gets set to 1, you warp again, it gets set to 0. repeat on each warp

since in my game, only warps you will be doing are either from stage to stage select, or from stage select to stage, that means that this variable will now always be 01 when you are in stage selection screen.

so what i did was this.

went to HandleScreenLoads.asm in Routines/basic/system

and changed this code:

Code:
;;;;;;;;;;;; SET SCREENS RELATIVE TO THE SCREEN TO BE LOADED

	LDA newGameState
	STA gameSubState
	
	LDA loadObjectFlag
	BEQ +
	LDA #$00
	STA loadObjectFlag
	LDA playerToSpawn
	CreateObject newX, newY, playerToSpawn, #$00, currentNametable
	TXA
	STA player1_object
+

to this code:

Code:
;;;;;;;;;;;; SET SCREENS RELATIVE TO THE SCREEN TO BE LOADED
checkStageSelectTrigger:
	LDA stageSelectTrigger
	CMP #$01
	BEQ createHiddenplayer
	JMP createplayer

createHiddenplayer:
	LDA playerToSpawn
	CreateObject newX, newY, playerToSpawn, #$04, currentNametable
	JMP proceedloadingscreen

whooploop:
	LDA newGameState
	STA gameSubState
	LDA loadObjectFlag
	BEQ +
	LDA #$00
	STA loadObjectFlag
	JMP checkStageSelectTrigger
createplayer:
	LDA playerToSpawn
	CreateObject newX, newY, playerToSpawn, #$00, currentNametable
proceedloadingscreen:
	TXA
	STA player1_object

+

(nevermind the "whooploop", it's just used as a JMP from the above code to not mess things up.)

what happens here is that if stageSelectTrigger is set to 01, my player will spawn in the new location starting from action state 04 instead of 00

i then created really specific conditions and input checks to prevent controller to ever bringing player out of action state 04.
action state 04 itself is set to a single empty sprite, so now whenever im in stage selection, the player is effectively gone.

this works, but i will eventually refine this into something that doesnt require me to spend an action state on it, such as creating a healthobject instead of player and setting it to an unused (empty) action state.
we'll see what i come up with it. For now, this works.


it be working:

https://youtu.be/RWskRWhMEkE
 
Top Bottom