http://www.youtube.com/watch?v=r_GeVKAZT4I
(it was an old demo for dos, called "Mario and Luigi")
Parallax scrolling in the second level is made by color cycling: the same effect can be achieved in freebasic:
Code: Select all
dim shared as integer p(255, 2)
sub Scroll()
dim as ubyte ptr target, source
screenLock
target = screenPtr
source = target + 1
for i as integer = 0 to 800*600-2
*target = *source
target +=1: source +=1
next i
screenUnlock
end sub
sub cycle (lowest as integer, highest as integer)
dim as integer a, b, c
a = p(highest, 0)
b = p(highest, 1)
c = p(highest, 2)
for i as integer = highest to lowest +1 step -1
p(i, 0) = p(i-1, 0)
p(i, 1) = p(i-1, 1)
p(i, 2) = p(i-1, 2)
palette i, p(i, 0), p(i, 1), p(i, 2)
next i
p(lowest, 0) = a
p(lowest, 1) = b
p(lowest, 2) = c
palette lowest, a, b, c
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)