View Single Post
Old 19 June 2019, 22:30   #4
mcgeezer
Registered User

 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 1,507
Quote:
Originally Posted by BippyM View Post
How can you move in fractions though? Like 1 quarter pixel scrolling or moving half a pixel.. Surely it'll only show full pixel movement?
What you do is simply increase the resolution of the screen canvas.

So if you think of a typical 320x200 screen, if you zoomed out by a multiple of 16 the screen size would be 5120x3200.

This then allows you to move objects in fractions (1/16th).

If you have a sprite that has coordinates of 100x100 and you want to move it an entire 1 pixel to the right you'd do something like this....

(rough example...)

Code:
  move .w SPRITE_XPOS,d0        ; 100 xpos
  move .w SPRITE_YPOS,d1        ; 100 ypos
  lsl.w #4,d0        
  lsl.w #4,d1
  add.w #16,d0                   ; Speed 1-16 - 1=slowest, 16=fast (1 pixel).
  lsr.w #4,d0
  lsr.w #4,d1
  move.w d0,SPRITE_XPOS        ; 101 xpos
  move.w d1,SPRITE_YPOS        ; 100 ypos
Geezer
mcgeezer is offline  
 
Page generated in 0.04162 seconds with 11 queries