8 Direction in 2 Player Module?

crazygrouptrio

Active member
I can't get 8 direction movement to work with both players. Assuming its addressed in code I can't find because it works if I specify "player1_object" instead, but trying to use it for just player 2 or both players gets nothing.

Here's the code I'm using that's not working:
Code:
; load the playerX_object (current inputs):
JSR PlayerXobjectInputs

    ;; if on a cutscene:
    LDA screenFlags
    AND #%00000010
    BEQ +
    RTS
    +
    LDA isPaused
    BEQ +
    RTS
    +
 

;;;; Start moving Down+Left ;;;;
    ;LDX player1_object
    GetCurrentActionType playerX_object
    CMP #$02 ;; if the state is invincible
    BEQ ++ ; skip movement if attacking 
    CMP #$03
    BEQ ++ ;skip if we are casting spell
    CMP #$01
    BEQ + ;; if the action type already equals 1, jump forward
    ChangeObjectState #$01, #$04
+
;;;;;; Then, we will begin moving.
    StartMoving playerX_object, MOVE_LEFT_DOWN

;;;;;; Lastly, we will change the facing direction.
    FaceDirection playerX_object, #%00000111
	++
    RTS
 

dale_coop

Moderator
Staff member
have you assigned that script to target "Player 1" in the Input Editor? (and not to "NULL")... and also to target "Player 2" (if you have a 2nd player)
 

crazygrouptrio

Active member
Yes each direction is assigned to player 1 and 2 in the input editor. Up, down, left, and right work correctly, its only diagonals that aren't responding.
 

crazygrouptrio

Active member
tDmw8A6.png
 

dale_coop

Moderator
Staff member
Ok... I see.
You should try to place all the DIAGONALES... AFTER the main directions. Because the engine executes every script that matches to the condition, but only:
- the user is holding the LEFT UP button? -> YES -> we executes the StartMoving LEFT UP
- the user is holding the LEFT button? -> YES again -> we executes the StartMoving LEFT (it overrides the previous startmoving)
etc...
So at the end, the player will move LEFT... because when you press LEFT and UP... you are pressing LEFT.

But if you put all diagonals at the end...
- the user is holding the LEFT button? -> YES -> we executes the StartMoving LEFT
- the user is holding the LEFT UP button? -> YES again -> we executes the StartMoving LEFT UP (it overrides the previous startmoving)
So at the end, the player will move LEFT UP.
 
Top Bottom