![]() |
![]() |
#1 |
Registered User
Join Date: Mar 2012
Location: UK
Posts: 1,908
|
Displayscroll!
So - how do I use Displayscroll to move a section of the screen right or left. I get that it offsets each time but I can't seem to workout how to undo the offset to make the section move as one. Help!
|
![]() |
![]() |
#2 |
Registered User
Join Date: Mar 2012
Location: UK
Posts: 1,908
|
So I worked this out. Basically, when you run your for next loop to change the values for the display scroll, you need to go to the value before the one you changed and subtract whatever you just added. This must reset the Copper to the correct place?
Code:
For loop.q=50 To 100 xpos.q(loop)+ax1 :xpos.q(loop-1)-ax1 Next So to set up three independent scrolling areas for simple non-overlapping parallax, I do this: Code:
For loop.q=50 To 100 xpos.q(loop)+ax1 :xpos.q(loop-1)-ax1 Next For loop.q=101 To 150 xpos.q(loop)+2*ax1 :xpos.q(loop-1)-2*ax1 Next For loop.q=151 To 255 xpos.q(loop)+3*ax1 :xpos.q(loop-1)-3*ax1 Next And then you just run DisplayScroll 0,&xpos.q(0),&xpos.q(0) Changing the numbers in the Displayscroll creates different effects and I have no idea why yet. I'll put together a small demo and upload it later so you can see all the code in action and play with it yourself. Seems fast! |
![]() |
![]() |
#3 |
Registered User
Join Date: Mar 2012
Location: UK
Posts: 1,908
|
P.S. Looks like I'm on my annual game program!
|
![]() |
![]() |
#4 |
Registered User
Join Date: Mar 2012
Location: UK
Posts: 1,908
|
So here is a simple demo - three levels of parallax but using Displayscroll you could probably do 200!!!
Code:
WBStartup ;use a screen high sprite to hide screen corruption LoadShape 1,"Graphics/hide": GetaSprite 0,1 LoadShape 2,"Graphics/backgroundtest" ;set up 32 lores screen 320x200 InitCopList 0,44,200,$5+$400,8,32,-4 ;DisplayControls 0,0,$1c00,$0023 LoadPalette 0,"Palette/pal1.col" Dim xpos.q(200); array for displayscroll BLITZ ;make the image 640 pixels long to be a bit more interesting! BitMap 0,640,200,5 BitMap 1,640,200,5 CreateDisplay 0 DisplayPalette 0,0 ;Two bitmaps for double buffering Use BitMap 0:Block 2,0,0: Use BitMap 1:Block 2,0,0 DisplaySprite 0,0,0,0,0; displays the screen high sprite db=0 While Joyb(0)=0 ax1.q=Joyx(1)*-1; joystick left/right controls scroll If RawStatus(1)=1 Then Stop ;three sections of the screen scrolling at different speeds For loop.q=28 To 89 xpos.q(loop)+ax1 :xpos.q(loop-1)-ax1 Next For loop.q=90 To 112 xpos.q(loop)+2*ax1 :xpos.q(loop-1)-2*ax1 Next For loop.q=113 To 196 xpos.q(loop)+3*ax1 :xpos.q(loop-1)-3*ax1 Next ; note - reset previous copper value in array (loop-1) stops the offset VWait DisplayBitMap db,0,0,0 DisplayScroll 0,&xpos.q(10),&xpos.q(10); this one command scrolls the whole display using the copper. Amazing! db=-db Wend https://eab.abime.net/zone/Displayscrolldemo.lha I hope this is helpful for someone. Any comments,suggestions or errors pointed out are most welcome. |
![]() |
![]() |
#5 |
Registered User
Join Date: Mar 2012
Location: UK
Posts: 1,908
|
Realised that I could use Displayadjust to remove the corruption from the left side (when scrolling).. Just add the following after the InitCopList
Code:
DisplayAdjust CoplistID,0,0,0,32,-32 Narrows the screen by 64 pixels but then allows all 4 16 colour sprites which could be useful? |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Displayscroll | Coagulus | Coders. Language | 20 | 24 December 2020 09:58 |
|
|