Advertisement
xerpi

Mapass sambpel

Dec 9th, 2011
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1. imagen = {w = 15,h=15}
  2.     imagen[1] = image.create(imagen.w,imagen.h,color.new(255,0,0))
  3.     imagen[2] = image.create(imagen.w,imagen.h,color.new(0,255,0))
  4.  
  5.  
  6. mapa = {x = 0,actual = 1}
  7.     mapa[1] = {
  8.                 {"1","2","2","2","2","2","2","2","2","2","2","1"},
  9.                 {"1","2","2","2","2","2","2","2","2","2","2","1"},
  10.                 {"1","2","2","2","2","2","2","2","2","2","2","1"},
  11.                 {"1","2","2","2","2","2","2","2","2","2","2","1"},
  12.                 {"1","2","2","2","2","2","2","2","2","2","2","1"},
  13.                 {"1","2","2","2","2","2","2","2","2","2","2","1"},
  14.                 {"1","2","2","2","2","2","2","2","2","2","2","1"},
  15.                 {"1","2","2","2","2","2","2","2","2","2","2","1"},
  16.                 {"1","1","1","1","1","1","1","1","1","1","1","1"}
  17.             }
  18.     mapa.y = 272-(#mapa[mapa.actual]*imagen.h)
  19.  
  20.  
  21. function mapa.blit()
  22.     for y = 1, #mapa[mapa.actual] do
  23.         for x = 1, #mapa[mapa.actual][y] do
  24.             imagen[tonumber(mapa[mapa.actual][y][x])]:blit(mapa.x + (x-1)*imagen.w, mapa.y + (y-1)*imagen.h)
  25.         end
  26.     end
  27. end
  28.  
  29. while true do
  30.     controls.read();
  31.    
  32.     if controls.right() then mapa.x = mapa.x +1 end
  33.     if controls.left() then mapa.x = mapa.x -1 end
  34.    
  35.     mapa.blit();
  36.    
  37.     if controls.select() then broke(); end
  38.     screen.flip();
  39. end
  40.  
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement