[4.5.6] Player Moves Automatically After Warp

offparkway

Active member
I warp into a special screen (16x16) and then into level 1, and everything is fine. Then when I warp to another special screen (still 16x16) which leads to level 2, my player automatically runs to the right until I press a button. The special screens are identical as far as settings go.

This also happened in 4.5.2 when I was making an adventure game, and never figured out a solution. The player sometimes starts the screen while walking, and sometimes the player is standing still. Any idea why that happens?
 

TolerantX

Active member
You could fix this easily with a tile if you don't mind using one:
Basically you might think of it this way. you want the player to be in standing step (action step 0)

Code:
ChangeActionStep player1_object, #$00
        ;arg0 = what object?
        ;arg1 = what behavior?

    RTS

that's one way if no enemies or objects will mess with that tile... then there's this:

Code:
	CPX player1_object
	BEQ +doActionZero
			JMP +skip
+doActionZero
	ChangeActionStep player1_object, #$00
        ;arg0 = what object?
        ;arg1 = what behavior?

+skip
    RTS

The difference here is a check if it's the player and if not, do nothing.

I prefer the method below the most... Make a checkpoint that turns to a null tile afterward.
This creates a point for warp in and also puts you in action 0 and only once per screen load, and only the player triggers it.

Warp in to a checkpoint:

Code:
;;; sets a new player continue checkpoint. ;;;

	CPX player1_object
	BEQ +doCheckpoint
			JMP +skip
+doCheckpoint
	TXA
	STA temp ;; assumes the object we want to move is in x.
	ChangeActionStep temp, #$00
	StopMoving temp, #$FF, #$00
	LDA currentNametable
	STA continueScreen
	LDA Object_x_hi,x
	STA continueX
	LDA Object_y_hi,x
	STA continueY
;;;; BELOW WILL CHANGE TILE AT COLLISION. ;;;;
	ChangeTileAtCollision #$00, #$00
		
+skip
 

offparkway

Active member
Thanks for this! I'll see if I can get it to solve my issue. My question still: why does the auto-walking only happen sometimes? For at least half my game, the warps function just fine and I have no need for this code. On a few occasions, the player automatically starts walking. There is no difference in types of warps, or types of screens really. Just screen locations.

So for example: warping from the start screen to 0,2 works just fine. Then I warp from 7,2 to 0,3 and that works just fine as well. Then I warp from 7,3 to 10,4 and suddenly the player won't stop walking on his own unless I press something.
 

offparkway

Active member
If anyone else had this issue, I figured out that I needed to set input scripts for special screens that stopped all motion and animation when Left or Right buttons are released. Once I added those input scripts to (in my case) the start screen type, issue was solved.

The reason it worked before on some screens is because the player was already stopped when warping to the next screen.
 

foovax

New member
Code:
    LDA continueMap
    STA warpMap
    
    LDA continueX
    STA newX
    LDA continueY
    STA newY
    
    LDA continueScreen
    STA warpToScreen
    STA camScreen

    LDA scrollByte
    AND #%00001111
    STA scrollByte
    
    StopMoving player1_object, #$FF, #$00

    ChangeActionStep player1_object, #$00

    WarpToScreen warpToMap, warpToScreen, #$02

This thread helped me with my warping back into game from continue screen. Above is my input script that is called when pressing a button to continue after the player dies.

The fix was adding the scrollByte, StopMoving & ChangeActionStep prior to WarpToScreen.
 
Top Bottom