Hi All,
I was hoping you guys could give me an idea on where to go with this. This is what I'm trying to accomplish, and unfortunately, my newbie feeble brain isn't yet to the task of figuring out the logic on its own.
I'm trying to develop my first animated character. Right now my game consists of a static sprite(s) and when moved on the screen, the sprite moves position but doesn't animate. I'm trying to implement the animation.
The animation is a simple two frame animation, when the character moves right.
Frame one of the animation is the standing position. Frame 2 of the animation is the right leg extended out in a walking position. Then Repeat.
My logic to accomplish this is:
1. Prior To Reading The Controller, Set Sprite in Frame1
2. When Controller is read and right button is pressed, update sprite to Frame 2.
Unfortunately, I do not know how to update the sprite back to Frame 1 while the right button is still pressed.
Basically, when I do a read on the controller, I update all the sprites to the new vertical position and horizontal position on the screen. I also change the tile to Frame 2. In my forever loop I set the sprite to Frame1. Under this logic, Frame 1 basically overrides frame 2 so I don't see the animation. If I take the Frame 1 out of the forever loop, the character stays stuck on frame 2 while the right button is pressed rather than alternating between frame 1 and 2.
So I guess what I'm saying is, can you give me some ideas on how to get frame 1 and 2 to alternate between each other while I'm holding down the right button?
Here is my code. The first portion of it just updates the horizontal position of the sprites which compose the character. The code that changes the sprites of the character to frame 2 are the writes to 0221 and 0225.
Thanks for any help. It is always highly appreciated.
I was hoping you guys could give me an idea on where to go with this. This is what I'm trying to accomplish, and unfortunately, my newbie feeble brain isn't yet to the task of figuring out the logic on its own.
I'm trying to develop my first animated character. Right now my game consists of a static sprite(s) and when moved on the screen, the sprite moves position but doesn't animate. I'm trying to implement the animation.
The animation is a simple two frame animation, when the character moves right.
Frame one of the animation is the standing position. Frame 2 of the animation is the right leg extended out in a walking position. Then Repeat.
My logic to accomplish this is:
1. Prior To Reading The Controller, Set Sprite in Frame1
2. When Controller is read and right button is pressed, update sprite to Frame 2.
Unfortunately, I do not know how to update the sprite back to Frame 1 while the right button is still pressed.
Basically, when I do a read on the controller, I update all the sprites to the new vertical position and horizontal position on the screen. I also change the tile to Frame 2. In my forever loop I set the sprite to Frame1. Under this logic, Frame 1 basically overrides frame 2 so I don't see the animation. If I take the Frame 1 out of the forever loop, the character stays stuck on frame 2 while the right button is pressed rather than alternating between frame 1 and 2.
So I guess what I'm saying is, can you give me some ideas on how to get frame 1 and 2 to alternate between each other while I'm holding down the right button?
Here is my code. The first portion of it just updates the horizontal position of the sprites which compose the character. The code that changes the sprites of the character to frame 2 are the writes to 0221 and 0225.
Thanks for any help. It is always highly appreciated.
Code:
;;Read Right;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
lda buttons1 ;load the current button state for controller1
and #%00000001 ;isolate the bit representing "right", by clearing all the other bits
BNE UpdateDaveRight
JMP READRIGHTDONE ;if the result was not 0, then the "up" bit was clear (thus not pressed), so skip the following code
UpdateDaveRight: ;code for moving paddle position up here
LDA $0207 ; load dave paddle sprite X position
CLC ; make sure the carry flag is clear
ADC #$04 ; A = A + 4
STA $0207 ; save sprite X position
LDA $020B ; load dave paddle sprite y position
CLC ; make sure the carry flag is clear
ADC #$04 ; A = A + 4
STA $020B ; save sprite X position
LDA $020F ; load dave paddle sprite y position
CLC ; make sure the carry flag is clear
ADC #$04 ; A = A + 4
STA $020F ; save sprite X position
LDA $0213 ; load dave paddle sprite X position
CLC ; make sure the carry flag is clear
ADC #$04 ; A = A + 4
STA $0213 ; save sprite X position
LDA $0217 ; load dave paddle sprite X position
CLC ; make sure the carry flag is clear
ADC #$04 ; A = A + 4
STA $0217 ; save sprite Y position
LDA $021B ; load dave paddle sprite X position
CLC ; make sure the carry flag is clear
ADC #$04 ; A = A + 4
STA $021B ; save sprite Y position
LDA $021F ; load dave paddle sprite X position
CLC ; make sure the carry flag is clear
ADC #$04 ; A = A + 4
STA $021F ; save sprite Y position
LDA $0223 ; load dave paddle sprite X position
CLC ; make sure the carry flag is clear
ADC #$04 ; A = A + 4
STA $0223 ; save sprite Y position
;;Update Leg Tile For 0223
LDA #$F4
STA $0221
;;;;;;;;;;;;;;;;
LDA $0227 ; load dave paddle sprite X position
CLC ; make sure the carry flag is clear
ADC #$04 ; A = A + 4
STA $0227 ; save sprite Y position
;;Update Leg Tile For $0227
LDA #$F5
STA $0225
;;;;;;;;;;;;;;;;;;;;;;;
LDA $022B ; load dave paddle sprite X position
CLC ; make sure the carry flag is clear
ADC #$04 ; A = A + 4
STA $022B ; save sprite X position
lda buttons1 ;load the current button state for controller1
and #%00000001 ;isolate the bit representing "right", by clearing all the other bits
BNE UpdateDaveRight
JMP READRIGHTDONE ;if the result was not 0, then the "up" bit was clear (thus not pressed), so skip the following code
UpdateDaveRight: ;code for moving paddle position up here
LDA $0207 ; load dave paddle sprite X position
CLC ; make sure the carry flag is clear
ADC #$04 ; A = A + 4
STA $0207 ; save sprite X position
LDA $020B ; load dave paddle sprite y position
CLC ; make sure the carry flag is clear
ADC #$04 ; A = A + 4
STA $020B ; save sprite X position
LDA $020F ; load dave paddle sprite y position
CLC ; make sure the carry flag is clear
ADC #$04 ; A = A + 4
STA $020F ; save sprite X position
LDA $0213 ; load dave paddle sprite X position
CLC ; make sure the carry flag is clear
ADC #$04 ; A = A + 4
STA $0213 ; save sprite X position
LDA $0217 ; load dave paddle sprite X position
CLC ; make sure the carry flag is clear
ADC #$04 ; A = A + 4
STA $0217 ; save sprite Y position
LDA $021B ; load dave paddle sprite X position
CLC ; make sure the carry flag is clear
ADC #$04 ; A = A + 4
STA $021B ; save sprite Y position
LDA $021F ; load dave paddle sprite X position
CLC ; make sure the carry flag is clear
ADC #$04 ; A = A + 4
STA $021F ; save sprite Y position
LDA $0223 ; load dave paddle sprite X position
CLC ; make sure the carry flag is clear
ADC #$04 ; A = A + 4
STA $0223 ; save sprite Y position
;;Update Leg Tile For 0223
LDA #$F4
STA $0221
;;;;;;;;;;;;;;;;
LDA $0227 ; load dave paddle sprite X position
CLC ; make sure the carry flag is clear
ADC #$04 ; A = A + 4
STA $0227 ; save sprite Y position
;;Update Leg Tile For $0227
LDA #$F5
STA $0225
;;;;;;;;;;;;;;;;;;;;;;;
LDA $022B ; load dave paddle sprite X position
CLC ; make sure the carry flag is clear
ADC #$04 ; A = A + 4
STA $022B ; save sprite X position