Retrobuster
New member
Hey everyone,
This is the updated and fully working version of the script needed to make a mario style countdown timer in your HUD that ticks once a second (or whatever rate you want it to), spawns the PlayerDeath object instead of simply resetting the game, AND resets inbetween screens. I used this for a single screen maze game so I don't know how it'd work on a scrolling game or an adventure game, but it works perfectly for this purpose.
Firstly, though, I need to shout out to Justin Francoeur, Dale Coop, Kevin Skeen, Mugi, and whoever else may've been involved with the making of this process. I pretty much did nothing but ask for a bunch of help. They all figured this out and I compiled it from a few threads from this forum and from Facebook. So give them a big round of applause for figuring all this out!
Step 1: Create a new HandleGameTimer.asm script from this code and load it into your project through the Script Settings.
Step 2: Go to Project->Info and change the Day/Night Cycle Speed to 60 to make it tick once every second. This is where you can control how often the timer ticks.
Step 3: Modify your HandleScreenLoads.asm script by inserting this code near the beginning just after the ";;;;;;;;;;;; SET SCREENS RELATIVE TO THE SCREEN TO BE LOADED" comment.
That should do it!
This is the updated and fully working version of the script needed to make a mario style countdown timer in your HUD that ticks once a second (or whatever rate you want it to), spawns the PlayerDeath object instead of simply resetting the game, AND resets inbetween screens. I used this for a single screen maze game so I don't know how it'd work on a scrolling game or an adventure game, but it works perfectly for this purpose.
Firstly, though, I need to shout out to Justin Francoeur, Dale Coop, Kevin Skeen, Mugi, and whoever else may've been involved with the making of this process. I pretty much did nothing but ask for a bunch of help. They all figured this out and I compiled it from a few threads from this forum and from Facebook. So give them a big round of applause for figuring all this out!
Step 1: Create a new HandleGameTimer.asm script from this code and load it into your project through the Script Settings.
Code:
;; create a variable in your HUD called myTimer
;; set the initial value for myTimer from your HUD
;; myTimer needs to have a max value of 3
;; this script was used for NESMAKER 4.1.1 and calls the SubtractValue macro
;; make sure that SubtractValue is the *proper* version
;; This script wouldn't be possible without Kevin Skeen's Timer_Tick.asm script
;; Thank you for everything, Kevin Skeen!
HandleGameTimer:
DEC gameTimer ;decrement memory by one
BNE dontUpdateGameTimer ;if gameTimer = 0, don't update
LDA gameTimerLo ;load gameTimerLo into accumulator
CLC ;clear the carry flag
ADC #$01 ;add 01 to acumulator with carry
STA gameTimerLo ;store to the accumlator
LDA gameTimerHi ;load gameTimerHi into accumulator
ADC #$00 ;add 00 to acumulator with carry
STA gameTimerHi ;store to the accumlator
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; DO WHATEVER READS OF THE GAMETIMER YOU MIGHT WANT HERE.
LDA #DayNightSpeed
STA gameTimer
LDX #$02 ;;Checking Hundreds
LDA myTimer,x ;;Load Hundreds Digit
BNE SubtractTime ;;If not 0, we have more than 000
DEX ;;Checking Tens -- Decrease x so x is 1
LDA myTimer,x ;;Load Tens Digit
BNE SubtractTime ;;If not 0, we have more than 000
DEX ;;Checking Tens
LDA myTimer,x ;;Load Ones Digit
BNE SubtractTime
JMP RESET
;;;;;;;;;;;;;;;;;;;;;;;;;;;
dontUpdateGameTimer:
RTS
SubtractTime:
SubtractValue #$03, myTimer, #$01, #$00 ;;Subtract 1 from the Ones digit
;;Update HUD
LDA #$03 ;; your timer can only have max 3 numbers
STA hudElementTilesToLoad
LDA DrawHudBytes
ORA #HUD_myTimer
STA DrawHudBytes
RTS
DoAlarm:
;;; we're going to edge-load monsters one at a time if they are of edge type and are not active.
LDX #$00
doLoadMonsterOnTimerLoop:
LDA edgeLoaderInCue
BEQ noEdgeMonstersInCue
LDA currentBank
STA prevBank
LDY #$1C ;; data bank
JSR bankswitchY
JSR CreateTimedEdgeSpawner
DEC edgeLoaderInCue
LDY prevBank
JSR bankswitchY
noEdgeMonstersInCue
RTS
Step 2: Go to Project->Info and change the Day/Night Cycle Speed to 60 to make it tick once every second. This is where you can control how often the timer ticks.
Step 3: Modify your HandleScreenLoads.asm script by inserting this code near the beginning just after the ";;;;;;;;;;;; SET SCREENS RELATIVE TO THE SCREEN TO BE LOADED" comment.
Code:
;; reset my timer;
LDA #$06
STA myTimer+1
LDA #$00
STA myTimer
That should do it!