I added diagonal directions to my game, but I am not satisfied with the result...
I made scripts for diagonals. Here, for example, the Press_upright.asm script:
Then, I inspired myself from a post by MistSonata, and made a unique Press_AnyDirection.asm script, that calls all the direction movements subroutines of the Press_xxx.asm scripts:
Then in the "Input manager", I assigned my "Press_AnyDirection.asm" script to the Top, Right, Bottom and Left Press inputs.
It works, but the control is quite sloppy. For example, when I keep pressing UpRight, my player is going UpRight... but I need to not move my thumb.
Else if I move my thumb to the Right (without release anything) the player goes more to the right.
It's not strictly 8 way directions, in fact it's like playing with an analog stick.
Does someone know how to fix my code to have 8 ways?
If you try my game, you will understand what I try to explain :
https://drive.google.com/open?id=1VNXbPdlqQxPf0-STbzGAcJFDhUB-otgp
Maybe it's not possible, and finally, the controls of my game are quite good (not perfect) but I have a lot of fun with it... as it, it's the more important.
I made scripts for diagonals. Here, for example, the Press_upright.asm script:
Code:
MoveUpRight_Direct:
LDX player1_object
LDA #%11100011
STA Object_movement,x
ChangeObjectState #$01
RTS
Then, I inspired myself from a post by MistSonata, and made a unique Press_AnyDirection.asm script, that calls all the direction movements subroutines of the Press_xxx.asm scripts:
Code:
MoveAny_Direct:
;;; Object_movement
;; 0 0 0 0 0 0 0 0
;; x x x
; 0 0 0 = down
; 0 0 1 = down right
; 0 1 0 = right
; 0 1 1 = up right
; 1 0 0 = up
; 1 0 1 = up left
; 1 1 0 = left
; 1 1 1 = down left
LDA gamepad
AND #%11110000
BNE moveDirection
RTS
moveDirection:
;LDA gamepad
;+---------- is it moving horizontal? 0 = no, 1 = yes
; + left or right? 0= left, 1= right
; +-------- is it moving vertical? 0 = no, 1 = yes
; + up or down? 0= up, 1= down
CMP #%10010000 ;; check if upright is pressed
BEQ moveUpRightDirect
CMP #%10100000 ;;check if downright is pressed
BEQ moveDownRightDirect
CMP #%01010000 ;;check if upleft is pressed
BEQ moveUpLeftDirect
CMP #%01100000 ;;check if downleft is pressed
BEQ moveDownLeftDirect
CMP #%00010000 ;; check if up is pressed
BEQ moveUpDirect
CMP #%00100000 ;;check if down is pressed
BEQ moveDownDirect
CMP #%01000000 ;;check if left is pressed
BEQ moveLeftDirect
CMP #%10000000 ;;check if right is pressed
BEQ moveRightDirect
RTS
moveUpRightDirect:
JMP MoveUpRight_Direct
RTS
moveDownRightDirect:
JMP MoveDownRight_Direct
RTS
moveUpLeftDirect:
JMP MoveUpLeft_Direct
RTS
moveDownLeftDirect:
JMP MoveDownLeft_Direct
moveUpDirect:
JMP MoveUp_Direct
RTS
moveDownDirect:
JMP MoveDown_Direct
RTS
moveLeftDirect:
JMP MoveLeft_Direct
RTS
moveRightDirect:
JMP MoveRight_Direct
RTS
Then in the "Input manager", I assigned my "Press_AnyDirection.asm" script to the Top, Right, Bottom and Left Press inputs.
It works, but the control is quite sloppy. For example, when I keep pressing UpRight, my player is going UpRight... but I need to not move my thumb.
Else if I move my thumb to the Right (without release anything) the player goes more to the right.
It's not strictly 8 way directions, in fact it's like playing with an analog stick.
Does someone know how to fix my code to have 8 ways?
If you try my game, you will understand what I try to explain :
https://drive.google.com/open?id=1VNXbPdlqQxPf0-STbzGAcJFDhUB-otgp
Maybe it's not possible, and finally, the controls of my game are quite good (not perfect) but I have a lot of fun with it... as it, it's the more important.