pierski
New member
I am attempting to attach additional sprites to the player. I have it attaching correctly on load, but as the player moves there is some lag.
Here is a video example of what is happening. I recorded the video at 25% speed to make it easier to see. You might want to watch the video on YouTube to see it at a larger resolution.
Here is the code. I am including it right after the sprite pre draw (I apologize for my novice code. Never had a need to learn Assembly prior to this).
Any help is greatly appreciated.
Here is a video example of what is happening. I recorded the video at 25% speed to make it easier to see. You might want to watch the video on YouTube to see it at a larger resolution.
Here is the code. I am including it right after the sprite pre draw (I apologize for my novice code. Never had a need to learn Assembly prior to this).
Code:
CPX player1_object
GetActionStep player1_object
CMP #$00 ;;; is player idle
BEQ +isPlayerIdle
JMP playerNotIdle
+isPlayerIdle:
LDX player1_object ;;; get player object
TXA
STA temp
LDA Object_y_hi,x ;;; player y for both sides
CLC
SBC #$07
STA tempy
LDA Object_x_hi,x ;;; player x for left side
CLC
ADC #$00
STA tempx
LDA Object_x_hi,x ;;; player x for right side
CLC
ADC #$08
STA tempA
GetObjectDirection temp ;;check player direction
AND #%00000111
CMP #%00000100 ;; 4 and above is face left, 3 and less is face right
BCS +faceLeft
;;; left side of hat
DrawSprite tempx,tempy, #$0c, #%00000001
;;; right side of hat
DrawSprite tempA,tempy, #$0d, #%00000010
JMP spriteDone
+faceLeft
;;; left side of hat
DrawSprite tempx,tempy, #$0d, #%01000010
;;; right side of hat
DrawSprite tempA,tempy, #$0c, #%01000001
JMP spriteDone
playerNotIdle
CMP #$01
BEQ +isPlayerWalking ;;; is player walking
JMP playerNotWalking
+isPlayerWalking:
LDX player1_object ;;; get player object
TXA
STA temp
LDA Object_y_hi,x ;;; player y for both sides
CLC
SBC #$07
STA tempy
LDA Object_x_hi,x ;;; player x for left side
CLC
ADC #$00
STA tempx
LDA Object_x_hi,x ;;; player x for right side
CLC
ADC #$08
STA tempA
GetObjectDirection temp ;;check player direction
AND #%00000111
CMP #%00000100 ;; 4 and above is face left, 3 and less is face right
BCS +faceLeft
LDA tempA
SEC
ADC Object_h_speed_hi,x
STA tempA
LDA tempx
SEC
ADC Object_h_speed_hi,x
STA tempx
;;; left side of hat
DrawSprite tempx,tempy, #$0c, #%00000001
;;; right side of hat
DrawSprite tempA,tempy, #$0d, #%00000010
JMP spriteDone
+faceLeft
LDA tempA
SEC
SBC Object_h_speed_hi,x
STA tempA
LDA tempx
SEC
SBC Object_h_speed_hi,x
STA tempx
;;; left side of hat
DrawSprite tempx,tempy, #$0d, #%01000010
;;; right side of hat
DrawSprite tempA,tempy, #$0c, #%01000001
JMP spriteDone
playerNotWalking
spriteDone:
Any help is greatly appreciated.