mirror of
https://github.com/blondie7575/GSCats.git
synced 2025-04-04 00:29:46 +00:00
Added multiple player support
This commit is contained in:
parent
22ebc76c61
commit
fb11e3dbd0
@ -5,6 +5,8 @@
|
||||
; Created by Quinn Dunki on 8/15/17
|
||||
;
|
||||
|
||||
NUMPLAYERS = 2
|
||||
|
||||
|
||||
beginGameplay:
|
||||
|
||||
@ -24,7 +26,12 @@ beginGameplay:
|
||||
jsr clipTerrain
|
||||
|
||||
; Create players
|
||||
lda #600
|
||||
lda #40
|
||||
ldy #0
|
||||
jsr playerCreate
|
||||
|
||||
lda #190
|
||||
ldy #1
|
||||
jsr playerCreate
|
||||
|
||||
ldy #0
|
||||
@ -72,13 +79,39 @@ gameplayLoopProjectiles:
|
||||
jsr updateProjectiles
|
||||
jsr renderProjectiles
|
||||
|
||||
gameplayLoopEndFrame:
|
||||
lda turnRequested
|
||||
beq gameplayLoopEndFrame
|
||||
jsr endTurn
|
||||
|
||||
gameplayLoopEndFrame:
|
||||
lda quitRequested
|
||||
beq gameplayLoop
|
||||
jmp quitGame
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; endTurn
|
||||
;
|
||||
; Handles changing the active player
|
||||
;
|
||||
endTurn:
|
||||
lda currentPlayer
|
||||
inc
|
||||
cmp #NUMPLAYERS
|
||||
beq endTurnWrap
|
||||
sta currentPlayer
|
||||
|
||||
endTurnRefresh:
|
||||
ldy currentPlayer
|
||||
jsr renderPlayerHeader
|
||||
stz turnRequested
|
||||
rts
|
||||
|
||||
endTurnWrap:
|
||||
stz currentPlayer
|
||||
bra endTurnRefresh
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; scrollMap
|
||||
;
|
||||
@ -110,11 +143,11 @@ scrollMap:
|
||||
; Handles changing a player's aim
|
||||
;
|
||||
changeAngle:
|
||||
ldy #0
|
||||
ldy currentPlayer
|
||||
tax
|
||||
jsr playerDeltaAngle
|
||||
|
||||
ldy #0
|
||||
ldy currentPlayer
|
||||
jsr renderPlayerHeader
|
||||
|
||||
stz angleDeltaRequested
|
||||
@ -128,7 +161,7 @@ changeAngle:
|
||||
;
|
||||
fire:
|
||||
stz fireRequested
|
||||
ldy #0
|
||||
ldy currentPlayer
|
||||
jsr playerFire
|
||||
rts
|
||||
|
||||
@ -143,10 +176,15 @@ angleDeltaRequested:
|
||||
.word $0000
|
||||
fireRequested:
|
||||
.word $0000
|
||||
turnRequested:
|
||||
.word $0000
|
||||
terrainDirty:
|
||||
.word 1
|
||||
activePlayer:
|
||||
.word 0
|
||||
currentPlayer:
|
||||
.word 0
|
||||
|
||||
|
||||
; Position of map viewing window. Can be visualized in two ways:
|
||||
; a) Word-distance from right edge of terrain data (which is in memory right-to-left) to left edge of visible screen
|
||||
|
BIN
gscats.2mg
BIN
gscats.2mg
Binary file not shown.
43
player.s
43
player.s
@ -14,15 +14,32 @@ playerData:
|
||||
|
||||
.word 45 ; Angle in degrees from +X
|
||||
.word 50 ; Power
|
||||
.byte 8,"SPROCKET " ; Name
|
||||
.word 0,0,0,0,0,0,0 ;Padding
|
||||
|
||||
; gameobject data
|
||||
.word 0 ; X pos in pixels (from left terrain edge)
|
||||
.word 0 ; Y pos in pixels (from bottom terrain edge)
|
||||
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Saved background
|
||||
|
||||
.word 45 ; Angle in degrees from +X
|
||||
.word 50 ; Power
|
||||
.byte 8,"TINKER " ; Name
|
||||
.word 0,0,0,0,0,0,0 ;Padding
|
||||
|
||||
PD_ANGLE = 36
|
||||
PD_POWER = 38
|
||||
PD_NAME = 40
|
||||
PD_SIZE = 64
|
||||
|
||||
.macro PLAYERPTR_Y
|
||||
tya ; Pointer to player structure from index
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
tay
|
||||
.endmacro
|
||||
|
||||
@ -31,14 +48,24 @@ PD_POWER = 38
|
||||
; playerCreate
|
||||
;
|
||||
; A = Player X pos
|
||||
; Y = Index
|
||||
; Trashes SCRATCHL
|
||||
;
|
||||
playerCreate:
|
||||
sta playerData+GO_POSX
|
||||
pha
|
||||
PLAYERPTR_Y
|
||||
sty SCRATCHL
|
||||
pla
|
||||
|
||||
sta playerData+GO_POSX,y
|
||||
lda #playerData
|
||||
clc
|
||||
adc SCRATCHL
|
||||
sta PARAML0
|
||||
jsr placeGameObjectOnTerrain
|
||||
rts
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; playerDeltaAngle
|
||||
;
|
||||
@ -101,6 +128,7 @@ playerFire:
|
||||
;
|
||||
renderPlayers:
|
||||
RENDER_GAMEOBJECT playerData
|
||||
RENDER_GAMEOBJECT playerData+PD_SIZE
|
||||
rts
|
||||
|
||||
|
||||
@ -114,19 +142,26 @@ renderPlayerHeader:
|
||||
PLAYERPTR_Y
|
||||
|
||||
ldx #0
|
||||
tya
|
||||
clc
|
||||
adc #playerData
|
||||
adc #PD_NAME
|
||||
jsr DrawString
|
||||
|
||||
ldx #48
|
||||
lda #angleStr
|
||||
jsr DrawString
|
||||
|
||||
lda playerData+PD_ANGLE,y
|
||||
ldx #24
|
||||
ldx #72
|
||||
jsr drawNumber
|
||||
|
||||
ldx #48
|
||||
ldx #96
|
||||
lda #powerStr
|
||||
jsr DrawString
|
||||
|
||||
lda playerData+PD_POWER,y
|
||||
ldx #72
|
||||
ldx #120
|
||||
jsr drawNumber
|
||||
|
||||
RESTORE_AXY
|
||||
|
@ -178,6 +178,8 @@ updateProjectilesDone:
|
||||
updateProjectilesDelete:
|
||||
ldy #0
|
||||
jsr deleteProjectile
|
||||
lda #1
|
||||
sta turnRequested
|
||||
bra updateProjectilesDone
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user