Parallax scrolling
Один из способов сделать скроллинг в игре.
Платформа: Windows , Linux
Автор: angros47, fxm
Dim Shared As Integer p(255, 2) Sub Scroll() Dim As Ubyte Ptr target = Screenptr Screenlock For i As Integer = 0 To 800*600-2 *(target + i) = *(target + i + 1) Next i Screenunlock End Sub Sub cycle (lowest As Integer, highest As Integer) For i As Integer = highest To lowest +1 Step -1 swap p(i, 0), p(i-1, 0) swap p(i, 1), p(i-1, 1) swap p(i, 2), p(i-1, 2) Palette i, p(i, 0), p(i, 1), p(i, 2) Next i Palette lowest, p(lowest, 0), p(lowest, 1), p(lowest, 2) End Sub Screenres 800,600, 8 'Prepare a tile Dim image As Any Ptr = Imagecreate( 64, 64, 0,8) Line image,(1,1)-(63,63),6,bf Line image,(1,1)-(63,3),15,bf Line image,(1,1)-(3,63),15,bf Line image,(60,3)-(63,63),4,bf Line image,(3,60)-(63,63),4,bf 'prepare palette For i As Integer = 129 To 144 p(i, 0) = 128 p(i, 1) = 64 p(i, 2) = 64 Palette i, p(i, 0), p(i, 1), p(i, 2) Next i p(130, 0) = 64 p(130, 1) = 0 p(130, 2) = 0 Palette 130, p(130, 0), p(130, 1), p(130, 2) 'main cycle Dim As Integer i, y Do i+=1 'background Line (799,0)-(799,600),129+(i Mod 16),,254 Line (799,0)-(799,600),129+((i+8) Mod 16),,254*256 Line (799,0)-(799,600),128,,257 'tile If (i Mod 64)=0 Then y=rnd(1)*8 Put (799,y*64),image, (i Mod 64,0)-step(2,64),Pset Scroll If i Mod 2 Then cycle 130,144 Sleep 5 Loop Until Multikey(1)