Wall Grab

Post Reply
User avatar
Mugi
Posts: 697
Joined: Thu Dec 27, 2018 8:30 pm

Wall Grab

Post by Mugi » Wed Apr 10, 2019 9:31 am

so might aswell try and write a proper forum thread for this since i already shared it out on the thread i made earlier.

so here's a wall grab tile:

Code: Select all

    CPX player1_object
    BNE dontMessWithGravity

    LDA gamepad
    AND #%00010000              ; is up pressed ?
    BEQ dontMessWithGravity
    
    LDA Object_v_speed_hi,x     ; are we falling downwards ?
    BMI dontMessWithGravity
    CLC
    ADC Object_y_hi,x           ; are we in map bounds ?
    CMP #$10
    BCC dontMessWithGravity
    CMP #$D6
    BCS dontMessWithGravity
    
    LDX player1_object          ; fetch facing direction of player 
    LDA Object_movement,x
    AND #%00001111
    CMP #%00000110
    BEQ doLeftCollisionCheck

    LDA collisionPoint1         ; compare top right collision point
    CMP #$03                    ; compare against "wallgrab tile"
    BNE dontMessWithGravity
    JMP doGrab
    
doLeftCollisionCheck:
    LDA collisionPoint0         ; compare top left collision point
    CMP #$03                    ; compare against "wallgrab tile"
    BNE dontMessWithGravity

doGrab:                         ; enable grabbing the wall
    ChangeObjectState #$07, #$03

dontMessWithGravity:
just save it as wallgrabtile.asm and assign it to an unused tiletype. (the script assumes that wall grab tiletype is 03, change in the tile code if necessary.)

This tile assumes that your wall grab action state is #$07
and requires action state 07 to have "ignore gravity" set

this tile requires modifications to be made to the players jump script, to bypass gravity based jumping, since gravity is turned off when you hang on the wall.
to do so, the following will have to be added and adapted to your jump script.

Code: Select all

   GetCurrentActionType player1_object
   CMP #$07
   BEQ doWallClimbJumpThing
   JMP dontDoWallClimbJumpThing

doWallClimbJumpThing:
    ChangeObjectState #$02, #$03
    LDA #$00
    SEC
    SBC #JUMP_SPEED_LO
    STA Object_v_speed_lo,x
    LDA #$00
    SEC
    SBC #JUMP_SPEED_HI
    STA Object_v_speed_hi,x
    RTS
dontDoWallClimbJumpThing:
in addition, extracontrollscript will need the following piece of code in order to disable L/R from the dpad during wall climb.

Code: Select all

    LDX player1_object
    GetCurrentActionType player1_object
    STA temp
    CMP #$07
    BNE +
    LDA gamepad
    AND #%00111111
    STA gamepad
    RTS  
+   
Last edited by Mugi on Wed Apr 10, 2019 12:59 pm, edited 1 time in total.
"what are you up to?" "Oh, not much... just... Parallaxing"
- Raftronaut
User avatar
dale_coop
Posts: 4100
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Wall Grab

Post by dale_coop » Wed Apr 10, 2019 9:47 am

Thanks, Mugi, for that tutorial (I love this feature in your game).
Will be very useful for some of us!
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
User avatar
rimoJO
Posts: 245
Joined: Sat Jan 12, 2019 2:23 am
Location: Planet Earth

Re: Wall Grab

Post by rimoJO » Sun May 05, 2019 1:56 pm

This didn't work for me... of course, i don't know asm at all, so i don't know what's wrong. the character just jumps through the wall. action step 7 is set to ignore gravity, tiletype is 3. jump script:

Code: Select all

; a jumps
 
   LDX player1_object
   ;;; let's check for if we are standing on a jumpthrough platform,
   ;;; for which "down and jump" will jump downwards through
   ;;; comment this out if you do not want that functionality
    LDA screenFlags
    AND #%00100000 ;; does it use gravity?
    BEQ dontJump
    
   LDA Object_physics_byte,x
   AND #%00001000
   BEQ notStandingOnJumpThroughPlatform
   LDA gamepad
   AND #%00100000
   BEQ notStandingOnJumpThroughPlatform
   LDA Object_y_hi,x
   CLC
   ADC #$09
   STA Object_y_hi,x
   JMP dontJump
notStandingOnJumpThroughPlatform:
   
   LDA Object_physics_byte,x
   AND #%00000001
   BNE canJump
   LDA Object_physics_byte,x
   AND #%00000100
   BEQ dontJump
    
canJump:
    ;;; TURN OFF "STANDING ON JUMPTHROUGH PLATFORM" if it is on
    LDA Object_physics_byte,x
    AND #%11110111
    STA Object_physics_byte,x
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    LDA #$00
    SEC
    SBC #JUMP_SPEED_LO
    STA Object_v_speed_lo,x
    LDA #$00
    SEC
    SBC #JUMP_SPEED_HI
    STA Object_v_speed_hi,x
    GetCurrentActionType player1_object
    CMP #$03 ;; attack
    BEQ +
    ChangeObjectState #$02, #$04
   +
   PlaySound #sfx_shoot
dontJump:
    RTS 
    GetCurrentActionType player1_object
    CMP #$07
    BEQ doWallClimbJumpThing
    JMP dontDoWallClimbJumpThing

doWallClimbJumpThing:
    ChangeObjectState #$02, #$03
    LDA #$00
    SEC
    SBC #JUMP_SPEED_LO
    STA Object_v_speed_lo,x
    LDA #$00
    SEC
    SBC #JUMP_SPEED_HI
    STA Object_v_speed_hi,x
    RTS
dontDoWallClimbJumpThing:    
Mystery Game status: Currently at least one in development. Stay tuned!
User avatar
Mugi
Posts: 697
Joined: Thu Dec 27, 2018 8:30 pm

Re: Wall Grab

Post by Mugi » Mon May 06, 2019 4:32 am

you need to place the jump code to the beginning of your jumpscript.
the way you placed it now is after the last RTS on the file, meaning it will never run.

also, make sure you add the little code i posted to the extracontrollscript, the grab wont work without it (pressing/holding any button will just make you not grab or instantly fall off.)
"what are you up to?" "Oh, not much... just... Parallaxing"
- Raftronaut
User avatar
rimoJO
Posts: 245
Joined: Sat Jan 12, 2019 2:23 am
Location: Planet Earth

Re: Wall Grab

Post by rimoJO » Mon May 06, 2019 12:22 pm

Okay, thanks! I don't know asm, so yeah. Also, what's extracontrolscript?
Mystery Game status: Currently at least one in development. Stay tuned!
User avatar
Mugi
Posts: 697
Joined: Thu Dec 27, 2018 8:30 pm

Re: Wall Grab

Post by Mugi » Mon May 06, 2019 1:48 pm

it's an assembly file that's assigned to run after controller input assemblies, you should see it assigned to Extra Controll Script
on your game's script settings.
"what are you up to?" "Oh, not much... just... Parallaxing"
- Raftronaut
User avatar
rimoJO
Posts: 245
Joined: Sat Jan 12, 2019 2:23 am
Location: Planet Earth

Re: Wall Grab

Post by rimoJO » Mon May 06, 2019 7:52 pm

Tiles are still walkable. there might be something wrong with the extra cs, maybe i could have put the extra code in the wrong place, idk. anyways, here's the ecs:

Code: Select all

ExtraInputControl:
    LDX player1_object
    GetCurrentActionType player1_object
    STA temp
    CMP #$07
    BNE +
    LDA gamepad
    AND #%00111111
    STA gamepad
    RTS  
+   

    ;;; occasionally, there is input code that may be very specific, and it may be 
    ;;; difficult to implement via the visual interface and accompanying scripts.
    ;;; this is a code that runs after all input checks, and allows for custom ASM.
    LDA gameState
    CMP #GS_MainGame
    BEQ doMainGameUpdates
    JMP skipMainGameExtraInputControl
doMainGameUpdates:  
    LDX player1_object

	GetCurrentActionType player1_object
	STA temp
	LDA Object_physics_byte,x
	AND #%00000010
	BEQ isNotClimbing
    LDA temp
    CMP #$04
    BNE isNotClimbing
	LDA gamepad
	AND #%11000000
	BEQ noDirWhileClimbing
	ChangeObjectState #$02, #$04
noDirWhileClimbing:
    ;;; is climbing.
    ;;; which means don't check to change to idle.
   JMP skipMainGameExtraInputControl
isNotClimbing:
    LDA temp
    CMP #$03 ;; is it shooting (shooting is same anim in air and on ground)
    BNE isNotAttackingAction
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    JMP skipMainGameExtraInputControl
isNotAttackingAction:   

    
    LDA gamepad
    AND #%11000000 ;;; left and right
    BEQ dontskipMainGameExtraInputControl
	JMP skipMainGameExtraInputControl
dontskipMainGameExtraInputControl:
    ;;; if left and right are not pressed
	
	LDA screenFlags
	AND #%00100000 ;; does it use gravity?
					;; if it does not, it would not have jumping or ducking, so
					;; skip state updates for jumping and ducking.
	BEQ notDucking ;; just will change to idle.

    LDA Object_physics_byte,x
    AND #%00000001 ;; if is in air
    BNE notInAir
    GetCurrentActionType player1_object
    CMP #$02 ;; is it already state 2?
    BEQ skipMainGameExtraInputControl

    ChangeObjectState #$02, #$04
    JMP skipMainGameExtraInputControl
notInAir:
    LDA Object_h_speed_lo,x
    ORA Object_h_speed_hi,x
    BNE skipMainGameExtraInputControl
    ;;;; controller is not pressed
    ;;;; horizontal speed is zero.
    ;; check to see if in air, shooting, etc.
	 LDA gamepad
	AND #%00100000 ; if down is pressed
	BEQ notDucking
	 ChangeObjectState #$5, #$04
	 JMP skipMainGameExtraInputControl
notDucking:
    LDA gamepad
	AND #%11110000
	BNE skipMainGameExtraInputControl
    ChangeObjectState #$00, #$04
skipMainGameExtraInputControl:  
    
    RTS  
Last edited by rimoJO on Sun May 19, 2019 1:27 pm, edited 1 time in total.
Mystery Game status: Currently at least one in development. Stay tuned!
User avatar
rimoJO
Posts: 245
Joined: Sat Jan 12, 2019 2:23 am
Location: Planet Earth

Re: Wall Grab

Post by rimoJO » Sun May 19, 2019 1:26 pm

I got it to work by adding

Code: Select all

	LDA #TILE_SOLID
	STA tile_solidity
at the end of the script.
Mystery Game status: Currently at least one in development. Stay tuned!
Post Reply