I have some sprites I'm trying to control the speed of, or how often they move.
What I have done is place a counter in my NMI,
In my game logic, which is separate from my NMI code, I check if frameCounter is greater than 30 (or roughly half a second) and I move my sprites if that condition is true. I then reset the frame counter back to zero.
Is this a common approach to timing? I figure the NMI will fire roughly 60 times a second so I can piggyback off that?
In Allegro and SDL I would get the current time and compare if the elapsed time between the last movement was greater than some timing variable.
What I have done is place a counter in my NMI,
Code:
; increase frame counter
LDA frameCounter
CLC
ADC #$01
STA frameCounter
LDA frameCounter
CLC
ADC #$01
STA frameCounter
In my game logic, which is separate from my NMI code, I check if frameCounter is greater than 30 (or roughly half a second) and I move my sprites if that condition is true. I then reset the frame counter back to zero.
Is this a common approach to timing? I figure the NMI will fire roughly 60 times a second so I can piggyback off that?
In Allegro and SDL I would get the current time and compare if the elapsed time between the last movement was greater than some timing variable.