mirror of
https://github.com/blondie7575/GSCats.git
synced 2024-11-21 15:33:11 +00:00
Restarting game now resets data properly
This commit is contained in:
parent
c2dde9a4b7
commit
f0a53d6964
@ -7,6 +7,18 @@
|
||||
|
||||
NUMPLAYERS = 2
|
||||
|
||||
initGameplay:
|
||||
; Create players
|
||||
lda #56
|
||||
ldy #0
|
||||
jsr playerCreate
|
||||
|
||||
lda #568
|
||||
ldy #1
|
||||
jsr playerCreate
|
||||
|
||||
jsr deleteAllProjectiles
|
||||
rts
|
||||
|
||||
beginGameplay:
|
||||
; Initialize random numbers
|
||||
@ -19,18 +31,14 @@ beginGameplay:
|
||||
jsr colorFill
|
||||
|
||||
; Generate, compile, and clip terrain
|
||||
stz mapScrollPos
|
||||
stz leftScreenEdge
|
||||
lda #160-GAMEOBJECTWIDTH/4-2
|
||||
sta rightScreenEdge
|
||||
jsr generateTerrain
|
||||
|
||||
; Create players
|
||||
lda #56
|
||||
ldy #0
|
||||
jsr playerCreate
|
||||
|
||||
lda #568
|
||||
ldy #1
|
||||
jsr playerCreate
|
||||
|
||||
jsr initGameplay
|
||||
|
||||
jsr syncPlayerHeader
|
||||
ldy #0
|
||||
jsr renderPlayerHeader
|
||||
@ -125,6 +133,8 @@ gameplayLoopPower:
|
||||
lda powerDeltaRequested
|
||||
beq gameplayLoopFire
|
||||
jsr changePower
|
||||
jsr unrenderCrosshair
|
||||
jsr renderCrosshair
|
||||
|
||||
gameplayLoopFire:
|
||||
lda fireRequested
|
||||
@ -489,9 +499,9 @@ turnRequested:
|
||||
playerMoveRequested:
|
||||
.word $0000
|
||||
terrainDirty:
|
||||
.word 1
|
||||
.word 0
|
||||
playersDirty:
|
||||
.word 1
|
||||
.word 0
|
||||
projectilesDirty:
|
||||
.word 1
|
||||
inventoryDirty:
|
||||
|
52
player.s
52
player.s
@ -6,6 +6,8 @@
|
||||
;
|
||||
|
||||
MAX_ANGER = 100
|
||||
START_POWER = 2
|
||||
START_TREATS = 7
|
||||
|
||||
playerData:
|
||||
;;;;;;;;;;;; PLAYER 1 ;;;;;;;;;;;;;;
|
||||
@ -17,14 +19,14 @@ playerData:
|
||||
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
|
||||
.word 24 ; Angle in degrees from +X
|
||||
.word 2 ; Power
|
||||
.word MAX_ANGER ; Anger
|
||||
.word 0 ; Angle in degrees from +X
|
||||
.word 0 ; Power
|
||||
.word 0 ; Anger
|
||||
.byte 8,"SPROCKET " ; Name
|
||||
.word 29 ; Base Sprite
|
||||
.word 0,5,7,0,0,0,0,0 ; Prices
|
||||
.word 0 ; Current weapon
|
||||
.word 7 ; Treats
|
||||
.word 0 ; Treats
|
||||
.repeat 86
|
||||
.byte 0 ; Padding to 256-byte boundary
|
||||
.endrepeat
|
||||
@ -38,14 +40,14 @@ playerData:
|
||||
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
|
||||
.word 154 ; Angle in degrees from +X
|
||||
.word 2 ; Power
|
||||
.word MAX_ANGER ; Anger
|
||||
.word 0 ; Angle in degrees from +X
|
||||
.word 0 ; Power
|
||||
.word 0 ; Anger
|
||||
.byte 8,"TINKER " ; Name
|
||||
.word 20 ; Base Sprite
|
||||
.word 0,5,7,0,0,0,0,0 ; Prices
|
||||
.word 0 ; Current weapon
|
||||
.word 7 ; Treats
|
||||
.word 0 ; Treats
|
||||
|
||||
.repeat 86
|
||||
.byte 0 ; Padding to 256-byte boundary
|
||||
@ -105,6 +107,7 @@ playerCreate:
|
||||
sty SCRATCHL
|
||||
pla
|
||||
|
||||
; Starting position
|
||||
sta playerData+GO_POSX,y
|
||||
lda #playerData
|
||||
clc
|
||||
@ -112,6 +115,39 @@ playerCreate:
|
||||
sta PARAML0
|
||||
jsr placeGameObjectOnTerrainDefault
|
||||
|
||||
; Starting aim
|
||||
lda playerData+GO_POSX,y
|
||||
cmp #TERRAINWIDTH/2
|
||||
bcc playerCreateLeft
|
||||
lda #154
|
||||
bra playerCreateInit
|
||||
playerCreateLeft:
|
||||
lda #24
|
||||
|
||||
playerCreateInit:
|
||||
sta playerData+PD_ANGLE,y
|
||||
|
||||
; Initialize standard values
|
||||
lda #START_POWER
|
||||
sta playerData+PD_POWER,y
|
||||
lda #START_TREATS
|
||||
sta playerData+PD_TREATS,y
|
||||
lda #MAX_ANGER
|
||||
sta playerData+PD_ANGER,y
|
||||
lda #0
|
||||
sta playerData+PD_CURRWEAPON,y
|
||||
lda #1
|
||||
sta playersDirty
|
||||
sta terrainDirty
|
||||
sta projectilesDirty
|
||||
sta inventoryDirty
|
||||
|
||||
lda #-1
|
||||
sta gameOver
|
||||
sta projectileActive
|
||||
|
||||
stz currentPlayer
|
||||
|
||||
jsr createProgressBar
|
||||
rts
|
||||
|
||||
|
22
projectile.s
22
projectile.s
@ -630,6 +630,9 @@ endProjectile:
|
||||
; Trashes A
|
||||
;
|
||||
deleteProjectile:
|
||||
lda projectileData+GO_POSX,y
|
||||
bmi deleteProjectileDone ; Already deleted
|
||||
|
||||
lda #-1
|
||||
sta projectileData+GO_POSX,y
|
||||
|
||||
@ -646,6 +649,25 @@ deleteProjectileDone:
|
||||
rts
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; deleteAllProjectiles
|
||||
;
|
||||
deleteAllProjectiles:
|
||||
SAVE_AXY
|
||||
|
||||
ldx #0
|
||||
deleteAllProjectilesLoop:
|
||||
txy
|
||||
PROJECTILEPTR_Y
|
||||
jsr deleteProjectile
|
||||
inx
|
||||
cpx #4
|
||||
bne deleteAllProjectilesLoop
|
||||
|
||||
RESTORE_AXY
|
||||
rts
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; protectProjectiles
|
||||
;
|
||||
|
Loading…
Reference in New Issue
Block a user