From dec9f3e2c8c648e7c541c08954a702b406adbd63 Mon Sep 17 00:00:00 2001 From: blondie7575 Date: Sun, 3 Sep 2017 17:20:24 -0700 Subject: [PATCH] Added player damage and death --- font.s | 26 +++++++++++++------------- gamemanager.s | 23 +++++++++++++++++++---- gscats.2mg | Bin 819264 -> 819264 bytes player.s | 29 +++++++++++++++++++++-------- projectile.s | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 101 insertions(+), 26 deletions(-) diff --git a/font.s b/font.s index 33f034d..01de4f3 100644 --- a/font.s +++ b/font.s @@ -235,24 +235,24 @@ s_OpenParen: qbyte $00FF0000 qbyte $000FF000 -s_CloseParen: - qbyte $000FF000 - qbyte $0000FF00 - qbyte $00000FF0 - qbyte $00000FF0 - qbyte $0000FF00 - qbyte $000FF000 +s_CloseParen: ; Anger symbol + qbyte $0F0000F0 + qbyte $00F00F00 + qbyte $00000000 + qbyte $00FFFF00 + qbyte $0F0000F0 + qbyte $F000000F s_Asterix: - qbyte $00000000 - qbyte $00F0F0F0 - qbyte $000FFF00 + qbyte $00000000 ; Angle symbol + qbyte $00000FF0 + qbyte $0000FF00 + qbyte $000FF000 qbyte $00FFFFF0 - qbyte $000FFF00 - qbyte $00F0F0F0 + qbyte $00000000 -s_Plus: +s_Plus: ; Power symbol qbyte $000F0000 qbyte $000F0000 qbyte $0FFFFF00 diff --git a/gamemanager.s b/gamemanager.s index 941736f..3c00e68 100644 --- a/gamemanager.s +++ b/gamemanager.s @@ -52,7 +52,6 @@ gameplayLoop: jsr renderPlayers gameplayLoopKbd: - ; Check for keys down jsr kbdScan @@ -62,14 +61,12 @@ gameplayLoopKbd: jsr scrollMap gameplayLoopAngle: - ; Update aim angle if needed lda angleDeltaRequested beq gameplayLoopFire jsr changeAngle gameplayLoopFire: - lda fireRequested beq gameplayLoopProjectiles jsr fire @@ -80,9 +77,14 @@ gameplayLoopProjectiles: jsr renderProjectiles lda turnRequested - beq gameplayLoopEndFrame + beq gameplayLoopVictoryCondition jsr endTurn +gameplayLoopVictoryCondition: + lda gameOver + bmi gameplayLoopEndFrame + jsr endGame + gameplayLoopEndFrame: lda quitRequested beq gameplayLoop @@ -112,6 +114,17 @@ endTurnWrap: bra endTurnRefresh +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; endGame +; +; Handles someone winning +; +endGame: + lda #1 + sta quitRequested + rts + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; scrollMap ; @@ -184,6 +197,8 @@ activePlayer: .word 0 currentPlayer: .word 0 +gameOver: + .word -1 ; Player index of winner ; Position of map viewing window. Can be visualized in two ways: diff --git a/gscats.2mg b/gscats.2mg index f69079f474ad212fbf45c8ee13104d4ea6b7ea6c..b8c1dfd0a17f4199dd8be6384e16c04af463f4e5 100644 GIT binary patch delta 1497 zcmZvbe`p(J7{}jB+BD5tn#{VULGax=3!5lsTrswkZtAe@s!Ul^8-^a*=6#c~{{&$Z zbLys2dR^ArAB)7ahJsD;U=VNwtqWBl2M#0dXG?8UNV_hSos|mPKk<3*a$03CJkR@i zpZ9t0z3=-YD|)k{_fojp_2WCJrR5P9LO&oo1B-mf@>BYtZPy1}R313f!Of@TGa^?t zHJEBlH+|Aw#Wx_NAq_lhp6CSU zNv}sQyvPm7?_cY1K83t!2-%PIyn5vD>lkBMy>{Far&v9%*^)60QN$w4B32xIR&+a&qf>5?YDld<1Wi}#RHK7(Q5Hqu6Tjq)&YEvD7Oi3 z#ixm~Kr}0k6J?S03c<@^e3xQ1q%5((AW_y>;=4q-NwjbJj@gwW@u(K0)k{V4b&=q% z!T1sp;zc6ZealL#2?l-7wuDiL=mfus$Bzjw8y%4O*`VHpJ?K-~qI?@v_Cx_C=%v)Wu0iN?d`^(vdkRM0Ez+N;|4%vQI7x&$sewI zIj=mk`dB1RV?nAUXpB-N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ZM^F@tFbVr)_JWx2*{fB7_aX4&i`kfoO$rLbxE@m)h1gy>$8?L*Hj7 diff --git a/player.s b/player.s index ed23201..4e3eaff 100644 --- a/player.s +++ b/player.s @@ -14,8 +14,9 @@ playerData: .word 45 ; Angle in degrees from +X .word 50 ; Power + .word 100 ; Anger .byte 8,"SPROCKET " ; Name - .word 0,0,0,0,0,0,0 ;Padding + .word 0,0,0,0,0,0 ;Padding ; gameobject data .word 0 ; X pos in pixels (from left terrain edge) @@ -24,12 +25,14 @@ playerData: .word 45 ; Angle in degrees from +X .word 50 ; Power + .word 100 ; Anger .byte 8,"TINKER " ; Name - .word 0,0,0,0,0,0,0 ;Padding + .word 0,0,0,0,0,0 ;Padding PD_ANGLE = 36 PD_POWER = 38 -PD_NAME = 40 +PD_ANGER = 40 +PD_NAME = 42 PD_SIZE = 64 .macro PLAYERPTR_Y @@ -176,23 +179,33 @@ renderPlayerHeader: jsr DrawString lda playerData+PD_ANGLE,y - ldx #72 + ldx #56 jsr drawNumber - ldx #96 + ldx #68 lda #powerStr jsr DrawString lda playerData+PD_POWER,y - ldx #120 + ldx #76 + jsr drawNumber + + ldx #88 + lda #angerStr + jsr DrawString + + lda playerData+PD_ANGER,y + ldx #96 jsr drawNumber RESTORE_AXY rts angleStr: - pstring "ANGLE: " + pstring "*: " powerStr: - pstring "POWER: " + pstring "+: " +angerStr: + pstring "): " diff --git a/projectile.s b/projectile.s index feb1e26..33395fc 100644 --- a/projectile.s +++ b/projectile.s @@ -16,14 +16,23 @@ projectileData: .word 0 ; Pos Y (12.4 fixed point) .word 0 ; Velocity X (8.8 fixed point) .word 0 ; Velocity Y (8.8 fixed point) + .word 0 ; Type JD_PRECISEX = 36 ; Byte offsets into projectile data structure JD_PRECISEY = 38 JD_VX = 40 JD_VY = 42 +JD_TYPE = 44 GRAVITY = $ffff ; 8.8 fixed point +projectileTypes: ; Byte offsets into projectile type data structure + .word 50 ; Damage + .word 0,0,0 ; Padding + +PT_DAMAGE = 0 + + .macro PROJECTILEPTR_Y tya ; Pointer to projectile structure from index @@ -34,6 +43,13 @@ GRAVITY = $ffff ; 8.8 fixed point tay .endmacro +.macro PROJECTILETYPEPTR_Y + tya ; Pointer to projectile type structure from index + asl + asl + tay +.endmacro + projectileParams: @@ -213,7 +229,7 @@ updateProjectilesDelete: bra updateProjectilesDone updateProjectilesPlayerHit: - brk + jsr processPlayerImpact bra updateProjectilesDelete updateProjectilesTerrainHit: @@ -267,3 +283,34 @@ unrenderProjectilesDoIt: unrenderProjectilesDone: pla rts + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; processPlayerImpact +; +; Y = Byte offset of player that was hit +; +processPlayerImpact: + tyx + + ldy #0 ; Assume projectile 0 + PROJECTILEPTR_Y + lda projectileData+JD_TYPE,y + tay + PROJECTILETYPEPTR_Y + + ; Apply damage + lda playerData+PD_ANGER,x + sec + sbc projectileTypes+PT_DAMAGE,y + + ; Check for death + beq processPlayerImpactDeath + bmi processPlayerImpactDeath + sta playerData+PD_ANGER,x + rts + +processPlayerImpactDeath: + lda currentPlayer + sta gameOver + rts