SciNEStist
Well-known member
For anyone with an autoscroll in their game, and want a solid method of preventing the player from disappearing off-camera, this is for you! Not only does it push your player along with the camera, It will be able to help you "squish" the player if they get stuck between a wall and the edge
This is designed to work well with the Improved Camera Scrolling script, but if you have your own autoscroller, this should probably work just as well with some minor tweaks
Step 0: back your stufff up first!
Step 1: set your edge reaction of your player to something that will just stop the player from moving horizontally. This script doesnt use those bounds, so no need for anything fancy. For example
Save that and name it something like "stopatedge.asm" somewhere inside your Base_4_5 folder, then you can point to that file in project settings >script settings, scroll down to one of the "Edge Reaction #" and point it to your new file. then go to the "Project Lablels" tab and make sure you name the corrosponding reaction # to "stop at edge"
Step 2: click Scripts >Defined Scripts >Subroutines > Handle Physics (should be the top one)
In there, look for "doHandlePhysics:" and immediatly under that, paste this code:
Step 3: search way down further, and you will see a commented out line: ";doMoveLeft:", uncomment it by changing it to "doMoveLeft:" save your changes!
Step 4: there are designated parts where you can put anything you want to happen when a player gets squished. (a screen warp for example) be careful not to pack too much in there. Make a subroutine if you want to get fancy with it
Done!
This is designed to work well with the Improved Camera Scrolling script, but if you have your own autoscroller, this should probably work just as well with some minor tweaks
Step 0: back your stufff up first!
Step 1: set your edge reaction of your player to something that will just stop the player from moving horizontally. This script doesnt use those bounds, so no need for anything fancy. For example
Code:
LDA #$00
STA Object_h_speed_lo,x
STA Object_h_speed_hi,x
RTS
Save that and name it something like "stopatedge.asm" somewhere inside your Base_4_5 folder, then you can point to that file in project settings >script settings, scroll down to one of the "Edge Reaction #" and point it to your new file. then go to the "Project Lablels" tab and make sure you name the corrosponding reaction # to "stop at edge"
Step 2: click Scripts >Defined Scripts >Subroutines > Handle Physics (should be the top one)
In there, look for "doHandlePhysics:" and immediatly under that, paste this code:
Code:
LDA ScreenFlags00
AND #%00000010 ; is autoscroll checked?? remove this and the 3 lines below if you arent using this flag to autoscroll
BNE +
JMP +skippush
+
CPX player1_object ; is it player 1?
BEQ +
CPX player2_object ; is it player 2?
BEQ +
JMP +skippush
+
LDA Object_x_hi,x
SBC camX
CMP #$03 ; if the player is within 3 pixels of the left edge, we squish
BCS +skipsquishR
;PUT WHAT YOU WANT TO HAPPPEN WHEN A PLAYER IS SQUISHED HERE
+skipsquishR
CMP #$08 ; if the player is within 8 pixels of the left edge, we push right
BCS +skippushR
LDA #$01
STA tempA
STA tempB
JMP doMoveRight
+skippushR
CMP #$F4 ; if the player is too far off the right side, we squish (if your player is fatter, decrease this number)
BCC +skipsquishL
;PUT WHAT YOU WANT TO HAPPPEN WHEN A PLAYER IS SQUISHED HERE
+skipsquishL
CMP #$F0 ; if the player is close to the right side, we push left (if your player is fatter, decrease this number)
BCC +skippushL
LDA #$01
STA tempA
STA tempB
JMP doMoveLeft
+skippushL
+skippush
Step 3: search way down further, and you will see a commented out line: ";doMoveLeft:", uncomment it by changing it to "doMoveLeft:" save your changes!
Step 4: there are designated parts where you can put anything you want to happen when a player gets squished. (a screen warp for example) be careful not to pack too much in there. Make a subroutine if you want to get fancy with it
Done!