English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 14 August 2024, 21:46   #1
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,903
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!
Havie is offline  
Old 14 August 2024, 22:28   #2
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,903
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
Notice how it is loop-1!

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!
Havie is offline  
Old 14 August 2024, 22:29   #3
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,903
P.S. Looks like I'm on my annual game program!
Havie is offline  
Old Yesterday, 23:24   #4
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,903
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
I have also uploaded an LHA file with simple graphics etc. to the Zone if you just want to have a look. UnLHA it and the load into Blitz!

https://eab.abime.net/zone/Displayscrolldemo.lha

I hope this is helpful for someone.

Any comments,suggestions or errors pointed out are most welcome.
Havie is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Displayscroll Coagulus Coders. Language 20 24 December 2020 09:58

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:30.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.07076 seconds with 15 queries