LDX player1_object
; get horizontal offset of Player
LDA Object_x_hi,x
; get vertical offset of Player
LDA Object_y_hi,x
; get horizontal offset of Player
LDA Object_x_hi,x ; load x offset of X (player1 is loaded in X above)
SEC ; set carry
SBC #$10 ; substract 16 pixels (substract for moving up, add for moving down)
STA Object_x_hi,x ; store the new value in player1's position
jcramer said:thanks for your help. I got it working for the most part. The up and left works perfectly, but the down and right gets off track. #$09 is too little and #$10 is too much. :|
I tried this and my character just jumps all over the place. Here is my sample code.you can read the players position by doing
Code:LDX player1_object ; get horizontal offset of Player LDA Object_x_hi,x ; get vertical offset of Player LDA Object_y_hi,x
on which after, if you wish for a button press for example, move the player up 16 pixels (one metatile)
you can simply do something like
Code:; get horizontal offset of Player LDA Object_x_hi,x ; load x offset of X (player1 is loaded in X above) SEC ; set carry SBC #$10 ; substract 16 pixels (substract for moving up, add for moving down) STA Object_x_hi,x ; store the new value in player1's position
;;;;
TXA
STA temp ;; assumes the object we want to move is in x.
GetActionStep temp
CMP #$07
BNE +notHurt
RTS
+notHurt
StartMoving temp, #RIGHT
TXA
STA temp ;; assumes the object we want to move is in x.
ChangeFacingDirection temp, #FACE_RIGHT
;; Snap to Grid by Mugi
LDX player1_object
; get horiz. offset of player1_object
LDA Object_x_hi,x
SEC
ADC #$10
STA Object_x_hi,x
; get vert. offset of player1_object
LDA Object_y_hi,x
SEC
ADC #$10
STA Object_y_hi,x
RTS