Advertisement
xerpi

Scroll 100%

Jun 5th, 2011
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. stuff = image.loadsprite("stuff.png",16,16)
  2. dofile("mapa.txt")
  3.  
  4. scroll={x=0,y=0,w=16,h=16}
  5.  
  6.  
  7. function blit_map(x,y,w,h)
  8. x,y,w,h = x or 0, y or 0, w or 16, h or 16
  9. for a = math.max(1,-math.ceil(y/h)), math.min(#mapa,272/h-y/h+1) do
  10.  for b = math.max(1,-math.ceil(x/w)), math.min(#mapa[a],480/w-x/w+1) do
  11.     if tonumber(mapa[a][b]) > 0 then stuff:setframe(tonumber(mapa[a][b])) stuff:resize(w,h) stuff:blit(x+(b-1)*w,y+(a-1)*h) end
  12.  end
  13.  screen.print(5,5,screen.fps().."  "..x..":"..y.." -  "..w..":"..h)
  14. end
  15.  
  16.  
  17. end
  18.  
  19.  
  20. while true do
  21. controls.read()
  22.  
  23. blit_map(scroll.x,scroll.y,scroll.w,scroll.h)
  24.  
  25.  
  26. if controls.triangle() then scroll.h = scroll.h -0.5 end
  27. if controls.cross() then scroll.h = scroll.h +0.5 end
  28. if controls.circle() then scroll.w = scroll.w +0.5 end
  29. if controls.square() then scroll.w = scroll.w -0.5 end
  30.  
  31. if controls.start() then scroll={x=0,y=0,w=16,h=16} end
  32.  
  33. if controls.up() then scroll.y = scroll.y -2 end
  34. if controls.down() then scroll.y = scroll.y +2 end
  35. if controls.right() then scroll.x = scroll.x +2 end
  36. if controls.left() then scroll.x = scroll.x -2 end
  37.  
  38.  
  39. if controls.select() then a() end
  40. screen.flip()
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement