crazyduckgames
New member
I´m sorry to bother everyone again, but i´m in need of help. I´ve made a Game Over screen and made everything needed for it. All in all it works, but it seems i have made a mistake somewhere.
Now my character dies instantly instead of loosing energy first. Either that or maybe he takes damage continously until he dies. I can´t pinpoint where i made a mistake,
though. Maybe someone with more experience might see it? I´ve tried to make screenshots and copys of every place that might be responsible.
I hope those are the right things to look into.
Now my character dies instantly instead of loosing energy first. Either that or maybe he takes damage continously until he dies. I can´t pinpoint where i made a mistake,
though. Maybe someone with more experience might see it? I´ve tried to make screenshots and copys of every place that might be responsible.
;;;;;;;;;;;;;;;;;; Presumes there is a variable called myLives defined in user variables.
;;;;;;;;;;;;;;;;;; You could also create your own variable for this.
LDA gameHandler
AND #%10000000
BEQ +canHurtPlayer
JMP +skipHurt
+canHurtPlayer:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;; is the monster below our feet?
;;;;;;;;;; and are we moving downward?
+doHurtPlayer
TXA
STA temp
GetActionStep temp
CMP #$06
BNE +canHurtPlayer
JMP +skipHurt
+canHurtPlayer
;;; will presume there is a variable myHealth
;;; and that player hurt state is action state 7.
GetActionStep player1_object
CMP #$07 ;; hurt state.
BEQ +notAlreadyInHurtState
DEC myHealth
BMI +healthBelowZero
BEQ +healthBelowZero
JMP +notDeadYet
+healthBelowZero:
;; player is dead, we play the death state:
ChangeActionStep player1_object, #$06
;; stop the scrolling :
LDA scrollByte
AND #%00111110
ORA #%00000010
STA scrollByte
;; and disables the inputs:
LDA #$FF
STA gameState
JMP +continue
+notDeadYet:
;; player is hurt, we play the hurt state:
ChangeActionStep player1_object, #$07
+continue:
;; recoil
LDA #$00
STA Object_h_speed_hi,x
STA Object_h_speed_lo,x
STA Object_v_speed_hi,x
STA Object_v_speed_lo,x
LDA xPrev
STA Object_x_hi,x
LDA yPrev
STA Object_y_hi,x
+notAlreadyInHurtState
LDA Object_x_hi,x
CLC
ADC self_center_x
STA tempA
LDA Object_y_hi,x
CLC
ADC self_center_y
STA tempB
TXA
PHA
LDX otherObject
LDA Object_x_hi,x
CLC
ADC other_center_x
STA tempC
LDA Object_y_hi,x
CLC
ADC other_center_y
STA tempD
PLA
TAX
;;; RECOIL L/R
;+recoilHor
LDA tempA
CMP tempC
BCS +recoilRight
LDA Object_direction,x
AND #%00001111
ORA #%10000000
STA Object_direction,x
JMP +skipHurt
+recoilRight
LDA Object_direction,x
AND #%00001111
ORA #%11000000
STA Object_direction,x
JMP +skipHurt
+playerHealthIsZero:
+skipHurt
;;;;;;;;;;;;;;;;;; You could also create your own variable for this.
LDA gameHandler
AND #%10000000
BEQ +canHurtPlayer
JMP +skipHurt
+canHurtPlayer:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;; is the monster below our feet?
;;;;;;;;;; and are we moving downward?
+doHurtPlayer
TXA
STA temp
GetActionStep temp
CMP #$06
BNE +canHurtPlayer
JMP +skipHurt
+canHurtPlayer
;;; will presume there is a variable myHealth
;;; and that player hurt state is action state 7.
GetActionStep player1_object
CMP #$07 ;; hurt state.
BEQ +notAlreadyInHurtState
DEC myHealth
BMI +healthBelowZero
BEQ +healthBelowZero
JMP +notDeadYet
+healthBelowZero:
;; player is dead, we play the death state:
ChangeActionStep player1_object, #$06
;; stop the scrolling :
LDA scrollByte
AND #%00111110
ORA #%00000010
STA scrollByte
;; and disables the inputs:
LDA #$FF
STA gameState
JMP +continue
+notDeadYet:
;; player is hurt, we play the hurt state:
ChangeActionStep player1_object, #$07
+continue:
;; recoil
LDA #$00
STA Object_h_speed_hi,x
STA Object_h_speed_lo,x
STA Object_v_speed_hi,x
STA Object_v_speed_lo,x
LDA xPrev
STA Object_x_hi,x
LDA yPrev
STA Object_y_hi,x
+notAlreadyInHurtState
LDA Object_x_hi,x
CLC
ADC self_center_x
STA tempA
LDA Object_y_hi,x
CLC
ADC self_center_y
STA tempB
TXA
PHA
LDX otherObject
LDA Object_x_hi,x
CLC
ADC other_center_x
STA tempC
LDA Object_y_hi,x
CLC
ADC other_center_y
STA tempD
PLA
TAX
;;; RECOIL L/R
;+recoilHor
LDA tempA
CMP tempC
BCS +recoilRight
LDA Object_direction,x
AND #%00001111
ORA #%10000000
STA Object_direction,x
JMP +skipHurt
+recoilRight
LDA Object_direction,x
AND #%00001111
ORA #%11000000
STA Object_direction,x
JMP +skipHurt
+playerHealthIsZero:
+skipHurt
;;; This script can be used as a start game input script.
;;; It will take you to the first screen and set up new continue points based on
;;; that screen's info.
LDA screenUpdateByte
ORA #%00000100
STA screenUpdateByte
LDA warpToMap
STA warpMap
LDA warpToScreen
STA currentNametable
LDX player1_object
STA Object_screen,x
LDA #$01
STA screenTransitionType ;; is of warp type
LDA gameHandler
ORA #%10000000
STA gameHandler ;; this will set the next game loop to update the screen.
RTS
;;; It will take you to the first screen and set up new continue points based on
;;; that screen's info.
LDA screenUpdateByte
ORA #%00000100
STA screenUpdateByte
LDA warpToMap
STA warpMap
LDA warpToScreen
STA currentNametable
LDX player1_object
STA Object_screen,x
LDA #$01
STA screenTransitionType ;; is of warp type
LDA gameHandler
ORA #%10000000
STA gameHandler ;; this will set the next game loop to update the screen.
RTS
;;; 00 = Loop
end_loop_action:
RTS
;;; 01 = Advance
advance_action:
LDA Object_frame,x
LSR
LSR
LSR
AND #%00000111
CLC
ADC #$01
AND #%00000111
STA tempB
;STA tempD ;; the action frame that was assigned during create macro.
;;;; object behavior tables are with the lut table.
;;;; the lut table is in bank 1C.
; SwitchBank #$1C
; ;;; Then, get the behavior for that object on that frame number.
; LDY Object_type,x
; LDA ObjectBehaviorTableLo,y
; STA pointer
; LDA ObjectBehaviorTableHi,y
; STA pointer+1
; LDY tempD
; LDA (pointer),y
; AND #%00001111
; STA tempB
; ReturnBank
LDA tempB
ASL
ASL
ASL
STA tempC
LDA Object_frame,x
AND #%11000111
ORA tempC
STA Object_frame,x
TXA
STA tempA
DoObjectAction tempA, tempB
; ;arg0 = what object?
;arg1 = what step behavior?
RTS
;;; 02 = Repeat
repeat_action:
LDA Object_frame,x
LSR
LSR
LSR
AND #%00000111
STA tempB
TXA
STA tempA
DoObjectAction tempA, tempB
; ;arg0 = what object?
;arg1 = what step behavior?
RTS
;;; 03 = Go To First
goToFirst_action:
LDA #$00
STA tempB
;;;; HURT END
LDA Object_frame,x
AND #%00111000
CMP #%00111000
BNE +notHurtFrame
LDA #$00
STA Object_h_speed_hi,x
STA Object_h_speed_lo,x
STA Object_v_speed_hi,x
STA Object_v_speed_lo,x
LDA Object_direction,x
AND #%00001111
STA Object_direction,x
;;;;;;;;;;;;;;;;;;;;
+notHurtFrame
LDA Object_frame,x
AND #%11000111
STA Object_frame,x
TXA
STA tempA
DoObjectAction tempA, tempB
; ;arg0 = what object?
;arg1 = what step behavior?
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; turn off move towards point if current action is 7.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
RTS
;;; 04 = Go To Last
goToLast_action:
LDA #$07
STA tempB
LDA Object_frame,x
ora #%00111000
STA Object_frame,x
TXA
STA tempA
DoObjectAction tempA, tempB
; ;arg0 = what object?
;arg1 = what step behavior?
RTS
;;; 05 = Go To Previous
goToPrev_action:
LDA Object_frame,x
LDA Object_frame,x
LSR
LSR
LSR
AND #%00000111
SEC
SBC #$01
AND #%00000111
STA tempB ;; the action frame that was assigned during create macro.
;;;; object behavior tables are with the lut table.
;;;; the lut table is in bank 1C.
ASL
ASL
ASL
STA tempC
LDA Object_frame,x
AND #%11000111
ORA tempC
STA Object_frame,x
TXA
STA tempA
DoObjectAction tempA, tempB
; ;arg0 = what object?
;arg1 = what step behavior?
RTS
;;; 06 = Destroy Me
destroyMe_action:
DestroyObject
RTS
;;; 07 = Go To Warp
goToWarp_action:
WarpToScreen warpToMap, warpToScreen, #$01
RTS
;;; 08 = Show Message (1)
show_message_action
RTS
;;; 09 = Go To Continue
goToContinue_action:
;; if no more lives, warp to GAME OVER:
LDA myLives
BEQ +notMoreLives
DEC myLives
BEQ +notMoreLives
BMI +notMoreLives
;; player still have lives, warp to last checkpoint:
LDA continueMap
STA warpToMap
LDA continueScreen
STA warpToScreen
LDA #$02
STA screenTransitionType
JMP +doWarpToContinue
+notMoreLives:
;; no more lives:
LDA #$00 ;; 00: Overworld, 01: Underworld
STA warpToMap
LDA #$01 ;; screen Y:01, X:00 (our GAME OVER screen)
STA warpToScreen
LDA #$01
STA screenTransitionType
+doWarpToContinue:
LDA myMaxHealth
STA myHealth
WarpToScreen warpToMap, warpToScreen, screenTransitionType
ChangeActionStep player1_object, #$00
LDX player1_object
LDA #$00000000
STA Object_direction,x
;;; 10 = Restart Screen
restartScreen_action:
LDA #$02
STA screenTransitionType
LDA gameHandler
ORA #%10000000
STA gameHandler ;; this will set the next game loop to update the screen.
ChangeActionStep player1_object, #$00
LDX player1_object
LDA #$00000000
STA Object_direction,x
RTS
;;; 11 = Restart Game
restartGame_action:
JMP RESET
RTS
;;; 12 = User 0
userEnd0_action:
RTS
;;; 13 = User 1
userEnd1_action:
RTS
EndAnimAndActions_Lo:
.db #<end_loop_action, #<advance_action, #<repeat_action, #<goToFirst_action, #<goToLast_action, #<goToPrev_action, #<destroyMe_action, #<goToWarp_action
.db #<show_message_action, #<goToContinue_action, #<restartScreen_action, #<restartGame_action, #<userEnd0_action, #<userEnd1_action
EndAnimAndActions_Hi:
.db #>end_loop_action, #>advance_action, #>repeat_action, #>goToFirst_action, #>goToLast_action, #>goToPrev_action, #>destroyMe_action, #>goToWarp_action
.db #>show_message_action, #>goToContinue_action, #>restartScreen_action, #>restartGame_action, #>userEnd0_action, #>userEnd1_action
end_loop_action:
RTS
;;; 01 = Advance
advance_action:
LDA Object_frame,x
LSR
LSR
LSR
AND #%00000111
CLC
ADC #$01
AND #%00000111
STA tempB
;STA tempD ;; the action frame that was assigned during create macro.
;;;; object behavior tables are with the lut table.
;;;; the lut table is in bank 1C.
; SwitchBank #$1C
; ;;; Then, get the behavior for that object on that frame number.
; LDY Object_type,x
; LDA ObjectBehaviorTableLo,y
; STA pointer
; LDA ObjectBehaviorTableHi,y
; STA pointer+1
; LDY tempD
; LDA (pointer),y
; AND #%00001111
; STA tempB
; ReturnBank
LDA tempB
ASL
ASL
ASL
STA tempC
LDA Object_frame,x
AND #%11000111
ORA tempC
STA Object_frame,x
TXA
STA tempA
DoObjectAction tempA, tempB
; ;arg0 = what object?
;arg1 = what step behavior?
RTS
;;; 02 = Repeat
repeat_action:
LDA Object_frame,x
LSR
LSR
LSR
AND #%00000111
STA tempB
TXA
STA tempA
DoObjectAction tempA, tempB
; ;arg0 = what object?
;arg1 = what step behavior?
RTS
;;; 03 = Go To First
goToFirst_action:
LDA #$00
STA tempB
;;;; HURT END
LDA Object_frame,x
AND #%00111000
CMP #%00111000
BNE +notHurtFrame
LDA #$00
STA Object_h_speed_hi,x
STA Object_h_speed_lo,x
STA Object_v_speed_hi,x
STA Object_v_speed_lo,x
LDA Object_direction,x
AND #%00001111
STA Object_direction,x
;;;;;;;;;;;;;;;;;;;;
+notHurtFrame
LDA Object_frame,x
AND #%11000111
STA Object_frame,x
TXA
STA tempA
DoObjectAction tempA, tempB
; ;arg0 = what object?
;arg1 = what step behavior?
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; turn off move towards point if current action is 7.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
RTS
;;; 04 = Go To Last
goToLast_action:
LDA #$07
STA tempB
LDA Object_frame,x
ora #%00111000
STA Object_frame,x
TXA
STA tempA
DoObjectAction tempA, tempB
; ;arg0 = what object?
;arg1 = what step behavior?
RTS
;;; 05 = Go To Previous
goToPrev_action:
LDA Object_frame,x
LDA Object_frame,x
LSR
LSR
LSR
AND #%00000111
SEC
SBC #$01
AND #%00000111
STA tempB ;; the action frame that was assigned during create macro.
;;;; object behavior tables are with the lut table.
;;;; the lut table is in bank 1C.
ASL
ASL
ASL
STA tempC
LDA Object_frame,x
AND #%11000111
ORA tempC
STA Object_frame,x
TXA
STA tempA
DoObjectAction tempA, tempB
; ;arg0 = what object?
;arg1 = what step behavior?
RTS
;;; 06 = Destroy Me
destroyMe_action:
DestroyObject
RTS
;;; 07 = Go To Warp
goToWarp_action:
WarpToScreen warpToMap, warpToScreen, #$01
RTS
;;; 08 = Show Message (1)
show_message_action
RTS
;;; 09 = Go To Continue
goToContinue_action:
;; if no more lives, warp to GAME OVER:
LDA myLives
BEQ +notMoreLives
DEC myLives
BEQ +notMoreLives
BMI +notMoreLives
;; player still have lives, warp to last checkpoint:
LDA continueMap
STA warpToMap
LDA continueScreen
STA warpToScreen
LDA #$02
STA screenTransitionType
JMP +doWarpToContinue
+notMoreLives:
;; no more lives:
LDA #$00 ;; 00: Overworld, 01: Underworld
STA warpToMap
LDA #$01 ;; screen Y:01, X:00 (our GAME OVER screen)
STA warpToScreen
LDA #$01
STA screenTransitionType
+doWarpToContinue:
LDA myMaxHealth
STA myHealth
WarpToScreen warpToMap, warpToScreen, screenTransitionType
ChangeActionStep player1_object, #$00
LDX player1_object
LDA #$00000000
STA Object_direction,x
;;; 10 = Restart Screen
restartScreen_action:
LDA #$02
STA screenTransitionType
LDA gameHandler
ORA #%10000000
STA gameHandler ;; this will set the next game loop to update the screen.
ChangeActionStep player1_object, #$00
LDX player1_object
LDA #$00000000
STA Object_direction,x
RTS
;;; 11 = Restart Game
restartGame_action:
JMP RESET
RTS
;;; 12 = User 0
userEnd0_action:
RTS
;;; 13 = User 1
userEnd1_action:
RTS
EndAnimAndActions_Lo:
.db #<end_loop_action, #<advance_action, #<repeat_action, #<goToFirst_action, #<goToLast_action, #<goToPrev_action, #<destroyMe_action, #<goToWarp_action
.db #<show_message_action, #<goToContinue_action, #<restartScreen_action, #<restartGame_action, #<userEnd0_action, #<userEnd1_action
EndAnimAndActions_Hi:
.db #>end_loop_action, #>advance_action, #>repeat_action, #>goToFirst_action, #>goToLast_action, #>goToPrev_action, #>destroyMe_action, #>goToWarp_action
.db #>show_message_action, #>goToContinue_action, #>restartScreen_action, #>restartGame_action, #>userEnd0_action, #>userEnd1_action
I hope those are the right things to look into.