Movement while crouching

red moon

Member
Hello,
I can currently slide move in my demo while crouching. Can this be halted by disabling the diagonal input Left and Right?
I can put up a video if need be, thank you!
 

Mugi

Member
is your crouch an action state ?
if it is, you should be able to prevent movement simply by terminating the left/right input scripts when that action state is active.

something like
Code:
GetCurrentActionType player1_object
CMP #$00 ; crouch action state here
BNE +
RTS
+
 

red moon

Member
They are indeed,
thanks Mugi, I will give that a go!

Here's my start and stop scripts.

Code:
	LDX player1_object

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;;;; this is for platform game.
	GetCurrentActionType player1_object
	CMP #$03 ;; attack
	BEQ +
	CMP #$01
	BEQ +
	LDA Object_physics_byte,x
	AND #%00000001 ;; is it on the ground?
	BEQ +
	ChangeObjectState #$01, #$04
	JMP +
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;;;;;;;;;;; END PLATFORM TYPE GAME
+
	LDA Object_movement,x
	AND #%00000111
	CMP #%00000110	;; is the player curenlty facing left ?
	BNE ++
	;; player was facing left:
	FaceDirection player1_object, FACE_DOWN_LEFT
	JMP +
	++
	CMP #%00000010	;; is the player curenlty facing right ?
	BNE + 
	;; player was facing right:
	FaceDirection player1_object, FACE_DOWN_RIGHT
	
+
    RTS


Code:
;;;; STOP PLAYER FROM MOVING LEFT
;;; Here, we will stop the player from moving,  
	StopMoving player1_object, STOP_LEFT
	GetCurrentActionType player1_object
	CMP #$02 ;; if the state is invincible
	BEQ + 
	CMP #$03
	BEQ + ; skip if we are casting spell
	LDX player1_object

;;; and we will change the object state to idle.
	ChangeObjectState #$00, #$04  

	LDA Object_movement,x
	AND #%00000111
	CMP #%00000111	;; is the player was down left ?
	BNE ++
	;; player was facing left:
	FaceDirection player1_object, FACE_LEFT
	JMP +
	++
	CMP #%00000001	;; is the player was down right ?
	BNE +	
	;; player was facing right:
	FaceDirection player1_object, FACE_RIGHT
	
+ 
    RTS
 

dale_coop

Moderator
Staff member
Or you could try checking if the Down button is pressed:

Code:
    LDA gamepad
    AND #%00100000
    BEQ +
    RTS
    +
 

red moon

Member
I added it at the beginning and it does prevent you from sliding which is great, but "attack while crouching" now causes you to stand and attack, rather than attacking from a crouching position.
 

dale_coop

Moderator
Staff member
Strange...
if you added the code only in the StartMovingPlayerLeft and StartMovingPlayerRight scripts (also in StopMovingPlayerLeft/StopMovingPlayerRight) only, it should not impact the attack state.
...I think.
 

red moon

Member
That makes sense to me, I had previously added it to start crouch and stop crouch. rather that start/stop move left/right.
I will add tonight and let you know!
 
Top Bottom