Basic camera shot tracking working

This commit is contained in:
blondie7575 2017-10-22 13:37:06 -07:00
parent 7ba22eadda
commit bfec5c2234
3 changed files with 68 additions and 8 deletions

View File

@ -36,7 +36,7 @@ beginGameplay:
ldy #0 ldy #0
jsr playerCreate jsr playerCreate
lda #196 lda #600
ldy #1 ldy #1
jsr playerCreate jsr playerCreate
@ -59,8 +59,8 @@ gameplayLoop:
jsr renderPlayers jsr renderPlayers
gameplayLoopKbd: gameplayLoopKbd:
; lda projectileActive lda projectileActive
; bpl gameplayLoopProjectiles ; Skip input during shots bpl gameplayLoopShotTracking ; Skip input during shots
; Check for keys down ; Check for keys down
jsr kbdScan jsr kbdScan
@ -69,6 +69,8 @@ gameplayLoopKbd:
lda paused lda paused
bne gameplayLoopEndFrame bne gameplayLoopEndFrame
gameplayLoopScroll:
; Scroll map if needed ; Scroll map if needed
lda mapScrollRequested lda mapScrollRequested
bmi gameplayLoopAngle bmi gameplayLoopAngle
@ -112,6 +114,64 @@ gameplayLoopEndFrame:
beq gameplayLoop beq gameplayLoop
jmp quitGame jmp quitGame
gameplayLoopShotTracking:
jsr trackActiveShot
bra gameplayLoopScroll
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; trackActiveShot
;
; Handles tracking the projectile with the camera
;
; Trashes SCRATCHL
;
trackActiveShot:
lda projectileData+JD_PRECISEX
lsr ; Convert to integer and divide by two for byte distance
lsr
lsr
lsr
lsr
sta SCRATCHL ; Save this for later
lda projectileData+JD_VX
bmi trackActiveShotNeg
; Left-to-right
lda mapScrollPos
cmp #VISIBLETERRAINWIDTH-VISIBLETERRAINWINDOW
beq trackActiveShotDone ; Logical-right edge clamp
lda SCRATCHL
sec
sbc #80 ; Check for moving past center
cmp leftScreenEdge
bpl trackActiveShotCameraMove
bra trackActiveShotDone
trackActiveShotNeg:
; Right-to-left
lda mapScrollPos
beq trackActiveShotDone ; Logical-left edge clamp
lda SCRATCHL
clc
adc #80 ; Check for moving past center
cmp rightScreenEdge
bpl trackActiveShotDone
trackActiveShotCameraMove:
lda SCRATCHL
sbc #80
lsr
and #$fffe ; Force even
sta mapScrollRequested
trackActiveShotDone:
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; endTurn ; endTurn

Binary file not shown.

View File

@ -15,8 +15,8 @@ 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 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 45 ; Angle in degrees from +X .word 25 ; Angle in degrees from +X
.word 1 ; Power .word 2 ; Power
.word 100 ; Anger .word 100 ; Anger
.byte 8,"SPROCKET " ; Name .byte 8,"SPROCKET " ; Name
@ -32,8 +32,8 @@ 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 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 135 ; Angle in degrees from +X .word 155 ; Angle in degrees from +X
.word 1 ; Power .word 2 ; Power
.word 100 ; Anger .word 100 ; Anger
.byte 8,"TINKER " ; Name .byte 8,"TINKER " ; Name