Hi All!
I'm still working on these Nerdy Nights tutorials and I'm almost done : ) I'm having some trouble though working out a feature. Any help would be appreciated. I'm trying to add a timer to the release of the ball. For example, currently when the play screen is loaded the ball immediately begins moving towards a paddle. I instead would like the play screen to load, and the ball NOT appear for a few seconds to allow the players to ready themselves. To achieve this, I came up with a timer that I insert before the ball sprite initialization code. I have separated the code into sections to make this easier to read. Here is the timer. The amount of time the timer waits is controlled by the Constant SETREADYFRAMES
I then try to combine the timer with the subroutine LoadInitialBallstats. This subroutine stores the initial stats that the program needs to update the sprite positions in order to move the ball on screen.
Unfortunately, my timer just isn't doing what I want it to do. When I test the timer in the FCEUX debugger it is counting up the way I want it too, so in theory I think it should work, but in practice it isn't. When I set the timer to a lower framecount using SETREADYFRAMES, like below 200, the ball immediately moves on the screen without the delay I want. When I set the timer at 200 or above, the ball will not appear at all.
Any help with this problem would be very much appreciated : )
Thanks All!
-Hundo
I'm still working on these Nerdy Nights tutorials and I'm almost done : ) I'm having some trouble though working out a feature. Any help would be appreciated. I'm trying to add a timer to the release of the ball. For example, currently when the play screen is loaded the ball immediately begins moving towards a paddle. I instead would like the play screen to load, and the ball NOT appear for a few seconds to allow the players to ready themselves. To achieve this, I came up with a timer that I insert before the ball sprite initialization code. I have separated the code into sections to make this easier to read. Here is the timer. The amount of time the timer waits is controlled by the Constant SETREADYFRAMES
Code:
ReadyTimer:
LDX #$00
ReadyTimerInnerLoop:
LDA #$00
STA ReadyFrameCount
ReadyTimerInc:
INC ReadyFrameCount
LDA ReadyFrameCount
CMP #SETREADYFRAMES ;;Currently Set to 200
BNE ReadyTimerInc
INX
CPX #$0A
BNE ReadyTimerInnerLoop
LDX #$00
ReadyTimerInnerLoop:
LDA #$00
STA ReadyFrameCount
ReadyTimerInc:
INC ReadyFrameCount
LDA ReadyFrameCount
CMP #SETREADYFRAMES ;;Currently Set to 200
BNE ReadyTimerInc
INX
CPX #$0A
BNE ReadyTimerInnerLoop
I then try to combine the timer with the subroutine LoadInitialBallstats. This subroutine stores the initial stats that the program needs to update the sprite positions in order to move the ball on screen.
Code:
LoadInitialBallStats:
ReadyTimer:
LDX #$00
ReadyTimerInnerLoop:
LDA #$00
STA ReadyFrameCount
ReadyTimerInc:
INC ReadyFrameCount
LDA ReadyFrameCount
CMP #SETREADYFRAMES
BNE ReadyTimerInc
INX
CPX #$0A
BNE ReadyTimerInnerLoop
;Timer Done. Now Set The Initial Ball Stats and Starting Paddle Position
LDA #$01
STA balldown
STA ballright
LDA #$00
STA ballup
STA ballleft
LDA #$50
STA bally
LDA #$80
STA ballx
LDA #$01
STA ballspeedx
STA ballspeedy
LoadInitialBallStatsDone:
RTS
ReadyTimer:
LDX #$00
ReadyTimerInnerLoop:
LDA #$00
STA ReadyFrameCount
ReadyTimerInc:
INC ReadyFrameCount
LDA ReadyFrameCount
CMP #SETREADYFRAMES
BNE ReadyTimerInc
INX
CPX #$0A
BNE ReadyTimerInnerLoop
;Timer Done. Now Set The Initial Ball Stats and Starting Paddle Position
LDA #$01
STA balldown
STA ballright
LDA #$00
STA ballup
STA ballleft
LDA #$50
STA bally
LDA #$80
STA ballx
LDA #$01
STA ballspeedx
STA ballspeedy
LoadInitialBallStatsDone:
RTS
Unfortunately, my timer just isn't doing what I want it to do. When I test the timer in the FCEUX debugger it is counting up the way I want it too, so in theory I think it should work, but in practice it isn't. When I set the timer to a lower framecount using SETREADYFRAMES, like below 200, the ball immediately moves on the screen without the delay I want. When I set the timer at 200 or above, the ball will not appear at all.
Any help with this problem would be very much appreciated : )
Thanks All!
-Hundo