Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- imagen = {w =15,h = 15}
- imagen[1] = image.create(imagen.w,imagen.h,color.new(255,0,0))
- imagen[2] = image.create(imagen.w,imagen.h,color.new(0,255,0))
- mapa = {x = 0, y = 0,actual = 1}
- mapa[1] = {
- {"1","2","2","2","2","2","2","2","2","2","2","1"},
- {"1","2","2","2","2","2","2","2","2","2","2","1"},
- {"1","2","2","2","2","2","2","2","2","2","2","1"},
- {"1","2","2","2","2","2","2","2","2","2","2","1"},
- {"1","2","2","2","2","2","2","2","2","2","2","1"},
- {"1","2","2","2","2","2","2","2","2","2","2","1"},
- {"1","2","2","2","2","2","2","2","2","2","2","1"},
- {"1","2","2","2","2","2","2","2","2","2","2","1"},
- {"1","1","1","1","1","1","1","1","1","1","1","1"}
- }
- function mapa.blit()
- for y = 1, #mapa[mapa.actual] do
- for x = 1, #mapa[mapa.actual][y] do
- imagen[tonumber(mapa[mapa.actual][y][x])]:blit(mapa.x + (x-1)*imagen.w, mapa.y + (y-1)*imagen.h)
- end
- end
- end
- function mapa.update(w,h)
- imagen.w = w;
- imagen.h = h;
- for i = 1, #imagen do
- imagen[i]:resize(w,h);
- end
- mapa.y = 272-(#mapa[mapa.actual]*imagen.h)
- end
- mapa.update(20,20)
- while true do
- controls.read();
- screen.clip(0,0,480,272)
- if controls.right() then mapa.x = mapa.x +1 end
- if controls.left() then mapa.x = mapa.x -1 end
- if controls.up() then mapa.y = mapa.y -1 end
- if controls.down() then mapa.y = mapa.y +1 end
- if controls.circle() then mapa.update(imagen.w+1,imagen.h); end
- if controls.square() then mapa.update(imagen.w-1,imagen.h); end
- if controls.triangle() then mapa.update(imagen.w,imagen.h+1); end
- if controls.cross() then mapa.update(imagen.w,imagen.h-1); end
- mapa.blit();
- screen.print(5,5,"@"..screen.fps().." x: "..mapa.x.." y: "..mapa.y.." w"..imagen.w.." h: "..imagen.h)
- if controls.select() then broke(); end
- screen.flip();
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement