Advertisement
NovaYoshi

angle targetting

Jun 15th, 2016
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   ; simpler movement
  2.   lda keydown,x
  3.   and #15
  4.   tay
  5.   lda TargetAngles,y
  6.   bmi ExitToNotCar   ; not a valid angle to target
  7.   sta target ; target = target
  8.  
  9.   lda PlayerShootAngle,x
  10.   sta current
  11.   sub target
  12.   bpl :+ ; absolute value
  13.   eor #255
  14.   add #1
  15. : sta difference ; difference = the absolute value of the difference
  16.   beq ExitToNotCar  ; difference = target? don't turn
  17.  
  18.   cmp #16 ; turning 180 degrees? just instantly flip
  19.   bne :+
  20.    lda PlayerShootAngle,x
  21.    add #16
  22.    sta PlayerShootAngle,x
  23.    jmp ExitToNotCar
  24. :
  25.  
  26.   cmp #16
  27.   bcs :+
  28.   lda current
  29.   cmp target
  30.   bcc :+
  31.   dec PlayerShootAngle,x
  32.   jmp ExitToNotCar
  33. :
  34.  
  35.   lda difference
  36.   cmp #16
  37.   bcc :+
  38.   lda current
  39.   cmp target
  40.   bcs :+
  41.   dec PlayerShootAngle,x
  42.   jmp ExitToNotCar
  43. :
  44.  
  45.   inc PlayerShootAngle,x
  46. ExitToNotCar:
  47.   lda PlayerShootAngle,x ; restrict to the range of target-31
  48.   and #31
  49.   sta PlayerShootAngle,x
  50.   jmp NotRacecar
  51.  
  52. TargetAngles: ;up, down, left, right
  53. .byt <-1,  0, 16, <-1,  8,  4, 12, <-1
  54. .byt 24, 28, 20, <-1, <-1, <-1, <-1, <-1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement