Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stuff = image.loadsprite("stuff.png",16,16)
- dofile("mapa.txt")
- scroll={x=0,y=0,w=16,h=16}
- --initx = x-480/w -x*w math.floor((480-x)/w)
- --inity =
- function blit_map(x,y,w,h)
- x,y,w,h = x or 0, y or 0, w or 16, h or 16
- for a = math.max(1,-math.ceil(y/h)), math.min(#mapa,272/h-y/16+1) do
- for b = math.max(1,-math.ceil(x/w)), math.min(#mapa[a],480/w-x/16+1) do
- if tonumber(mapa[a][b]) > 0 then stuff:setframe(tonumber(mapa[a][b])) stuff:resize(w,h) stuff:blit(x+(b-1)*16,y+(a-1)*16) end
- end
- screen.print(5,5,screen.fps().." "..math.min(#mapa,#mapa+math.ceil(y/h)).." "..math.min(#mapa[a],#mapa[a]+math.ceil(x/w)))
- end
- end
- while true do
- controls.read()
- blit_map(scroll.x,scroll.y,scroll.w,scroll.h)
- if controls.up() then scroll.y = scroll.y -2 end
- if controls.down() then scroll.y = scroll.y +2 end
- if controls.right() then scroll.x = scroll.x +2 end
- if controls.left() then scroll.x = scroll.x -2 end
- if controls.select() then a() end
- screen.flip()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement