diff --git a/juego/README.md b/juego/README.md new file mode 100644 index 0000000..1ab2c72 --- /dev/null +++ b/juego/README.md @@ -0,0 +1,3 @@ +# juego + +esto es un repo de prueba \ No newline at end of file diff --git a/juego/conf.lua b/juego/conf.lua new file mode 100644 index 0000000..693d7de --- /dev/null +++ b/juego/conf.lua @@ -0,0 +1,5 @@ +function love.conf(t) + t.window.width = 800 + t.window.height = 640 + t.window.title = "nombre juego" +end diff --git a/juego/main.lua b/juego/main.lua new file mode 100644 index 0000000..8fc6b29 --- /dev/null +++ b/juego/main.lua @@ -0,0 +1,21 @@ +utf8 = require("utf8") +require("conf") +require("tiles") +require("rooms") + +function love.load() + intro() + room1() + x = 0 + y = 0 +end + +function love.update() +end + +function love.draw() + love.graphics.setColor(0, 255, 0) -- set green color + love.graphics.rectangle("fill", x, y, 16, 16) +end + + diff --git a/juego/room1.png b/juego/room1.png new file mode 100644 index 0000000..43885d8 Binary files /dev/null and b/juego/room1.png differ diff --git a/juego/rooms.lua b/juego/rooms.lua new file mode 100644 index 0000000..696bfcc --- /dev/null +++ b/juego/rooms.lua @@ -0,0 +1,9 @@ +function intro() + print "la intro" +end + +function room1() + roomName="Sotano" + readTile("room1.png") + getBlockPos(3) +end diff --git a/juego/tiles.lua b/juego/tiles.lua new file mode 100644 index 0000000..0f53dbf --- /dev/null +++ b/juego/tiles.lua @@ -0,0 +1,114 @@ +function readTile(tileFileName) + tile = {} + tile.img = love.graphics.newImage(tileFileName) + tile.w, tile.h = tile.img:getDimensions() -- get dimensions (width, height) + tile.c = tile.w / 16 -- columns + tile.r = tile.h / 16 -- rows + tile.b = tile.c * tile.r -- total blocks +end + +function getBlockPos(tileBlock) -- Get Block Tile Position + getBlockY(tileBlock) -- y pixel position (block.y) + getBlockX(tileBlock) -- x pixel position (block.x) + print (block.y) + print (block.x) +end + +function getBlockY(tileBlock) -- Get Block Y position + block = {} + count = 0 + for i = 1,tile.r,1 + do + if( tileBlock <= (tile.r * i) ) then + count = (count + 1) + end + end + block.col = (tile.r - count) -- cols 0:7 + block.y = ((block.col) * 16) -- y pixel position +end + +function getBlockX(tileBlock) -- Get Block X position + count = 0 + if( block.col == 0 ) then + for x = 1,8,1 + do + count = (count + 1) + if( tileBlock == x ) then + block.row = (count) + end + end + end + + if( block.col == 1 ) then + for x = 9,16,1 + do + count = (count + 1) + if( tileBlock == x ) then + block.row = (count) + end + end + end + + if( block.col == 2 ) then + for x = 17,24,1 + do + count = (count + 1) + if( tileBlock == x ) then + block.row = (count) + end + end + end + + if( block.col == 3 ) then + for x = 25,32,1 + do + count = (count + 1) + if( tileBlock == x ) then + block.row = (count) + end + end + end + + if( block.col == 4 ) then + for x = 33,40,1 + do + count = (count + 1) + if( tileBlock == x ) then + block.row = (count) + end + end + end + + if( block.col == 5 ) then + for x = 41,48,1 + do + count = (count + 1) + if( tileBlock == x ) then + block.row = (count) + end + end + end + + if( block.col == 6 ) then + for x = 49,56,1 + do + count = (count + 1) + if( tileBlock == x ) then + block.row = (count) + end + end + end + + if( block.col == 7 ) then + for x = 57,64,1 + do + count = (count + 1) + if( tileBlock == x ) then + block.row = (count) + end + end + end + + block.x = (block.row * 16) + +end