here some idea of the code
note: works already, but got still a bug when the value displayed onscreen(upper one hits 500|1000|1500..which are the limits of the images....)... hell WHY?
(only tested on lp-win32)
Code: Select all
--load the images
layer = {
buffer = Image.createEmpty(480, 272)
}
slices = {
Image.load("slice1.png"), --500x272px
Image.load("slice2.png"), --500x272px
Image.load("slice3.png") --500x272px
}
-- 0..1500
shade = {
start=0,
ende=480
}
drawslices = 0
function limited(val)
val = math.ceil(val/500)
if val>table.getn(slices) or val==0 then
return 1
end
return val
end
while not Controls.read():start() do
shade.ende = shade.ende+1
shade.start = shade.start+1
if shade.ende>=1500 then
shade.ende=0
end
if shade.start>=1500 then
shade.start=0
end
--move the background to left
layer.buffer:clear()
drawslices = 500-math.mod(shade.start,500)
layer.buffer:blit(0,0,slices[limited(shade.start)],math.mod(shade.start,500),0,drawslices,272)
layer.buffer:blit(drawslices,0,slices[limited(shade.ende)],0,0,math.mod(shade.ende,500),272)
layer.buffer:print(25, 100,shade.start ,Color.new(255,0,46))
layer.buffer:print(25, 110,shade.ende ,Color.new(255,0,46))
-- update screen
screen:blit(0,0,layer.buffer)
screen.flip()
end
2) would be great if someone can use the code as an base for sidescroller (as i got an idea HOW to use it ;) )
greets
LuMo, who is interested, why this code flickers sometimes