From 08b1c0011222ca0b4dd1945ac660721e38594ee8 Mon Sep 17 00:00:00 2001 From: fanta Date: Sun, 5 Jan 2025 20:40:21 +0100 Subject: [PATCH] juego de prueba --- juego/README.md | 3 ++ juego/conf.lua | 5 +++ juego/main.lua | 21 +++++++++ juego/room1.png | Bin 0 -> 65856 bytes juego/rooms.lua | 9 ++++ juego/tiles.lua | 114 ++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 152 insertions(+) create mode 100644 juego/README.md create mode 100644 juego/conf.lua create mode 100644 juego/main.lua create mode 100644 juego/room1.png create mode 100644 juego/rooms.lua create mode 100644 juego/tiles.lua 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 0000000000000000000000000000000000000000..43885d873ad55f0bc49edba3c448b7014d780759 GIT binary patch literal 65856 zcmeHQKZsmK7@w0Pgka$87E##Z2^Lozp2%6KiEN06$DxwKAc&^1vpoeN7p>H0CD@8p z#6n4N2Nov@#4ZXJhgd9Vc@}me>CXLvAAC&SdpGmu&Cc(8`QDMtpZ(^&@Aqexg_)iG z^tJ7aXU{x-#yNL(^OeaP^KzH|ojx`H|IUl=-klexuDp72;*RO>>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lva2GFR@)g+F;Y*bWa^mwH9j>4zC+vy*>V;j3qUc~a~JsC@?A zYkGTH`&vk+9Ud^M+^QWOV220LOzLut$K(4yld?71>N4ET=x_crD<#K6eIDqvS0R0*!Aut0Z(Wif~89={=NeIjUN%ZL-YzEM;VG;r}KoWiW2b%%(YnX(< z43I>h{=sGd{Te1AFaspfr+=^+K);4b2<-3xz{3N+{p`8<^5ocUPR?HnRkx4B1Clq2 z*tr3AZh%W!TQB{+`Ow+c6ldoKG%*v=&->xphVWiFDk+}ZZDX{&RuVtN2f|n}*#uey zJ}J+V_#q6y1cl55j*TUa$03&`@WU8@-`1N*ko~fbENDz_rSQWTfM+z9K6$cV*8MoG zZN|ibsd4K%Zv4W^4xNl}>#( zGXv<;tk;aq0KL+w?`CEIeVX-}v7H-G;M{<_Z@+(GuHu*ST!22l_fIRMT`zk6e51(m a@fVN1^xci?*Y41bHZN>XzJK|hkN*RVMRoQ7 literal 0 HcmV?d00001 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