2 Player Game Tutorial For Version (4.5.9)

dale_coop

Moderator
Staff member
That script (below) should work for any player (if you assign that input script to controller 1 and controller 2):
Code:
;;; Create a Projectile.
;;; Assumes that the projectile you want to create is in GameObject Slot 01.

CountObjects #%00000100
CMP #1
BNE +canShoot
       JMP +canNotShoot
+canShoot:


TXA
PHA
TYA
PHA

    LDA Object_screen,x
    STA tempD
    LDA Object_x_hi,x
    CLC
    ADC #$04
    STA tempA
    LDA Object_y_hi,x
    CLC
    ADC #$04
    STA tempB
    LDA Object_direction,x
    AND #%00000111
    STA tempC
    CreateObjectOnScreen tempA, tempB, #$09, #$00, tempD
    ;;; x, y, object, starting action.
    ;;; and now with that object, copy the player's
    ;;; direction and start it moving that way.
    LDA tempC
    STA Object_direction,x
    TAY
    LDA DirectionTableOrdered,y
    STA temp1
    TXA
    STA temp
    StartMoving temp, temp1
  
PLA
TAY
PLA
TAX


+canNotShoot:
RTS
 

Gator83

Member
That script (below) should work for any player (if you assign that input script to controller 1 and controller 2):
Code:
;;; Create a Projectile.
;;; Assumes that the projectile you want to create is in GameObject Slot 01.

CountObjects #%00000100
CMP #1
BNE +canShoot
       JMP +canNotShoot
+canShoot:


TXA
PHA
TYA
PHA

    LDA Object_screen,x
    STA tempD
    LDA Object_x_hi,x
    CLC
    ADC #$04
    STA tempA
    LDA Object_y_hi,x
    CLC
    ADC #$04
    STA tempB
    LDA Object_direction,x
    AND #%00000111
    STA tempC
    CreateObjectOnScreen tempA, tempB, #$09, #$00, tempD
    ;;; x, y, object, starting action.
    ;;; and now with that object, copy the player's
    ;;; direction and start it moving that way.
    LDA tempC
    STA Object_direction,x
    TAY
    LDA DirectionTableOrdered,y
    STA temp1
    TXA
    STA temp
    StartMoving temp, temp1
 
PLA
TAY
PLA
TAX


+canNotShoot:
RTS
I got the two player shoot to work with different ammo variables. P2 is set as a monster becauses I wanted to do PVP for the 2 player mode. Anyway, There are a some weird issues (when p2 shoots p1-p1 duplicates the projectile shot, next when p2 uses his grenades on p1-the first one does damage/after that no damage, last I'm trying to implement health display for p2-but not updating & really not sure where to put it). Also looking to hide p2 part of the hud unless in 2 player mode. This is adventure module.
I'll share all my projectile scripts & I altered object collisions for 2p mode only. But, otherwise I have this working as intended. I have considered doing a coop 2p instead though.
 

Attachments

  • MonsterHurt-Eradicator.txt
    15.8 KB · Views: 0
  • myP2Grenades.txt
    1.5 KB · Views: 0
  • p1ammo.txt
    1.2 KB · Views: 0
  • p1grenades.txt
    1.2 KB · Views: 0
  • p2ammo.txt
    1.6 KB · Views: 0
  • Eradicator-HandleObjectCollisions.txt
    14.6 KB · Views: 0
  • PlayerHurt-Eradicator.txt
    8.1 KB · Views: 0
Top Bottom