juego de prueba

master
fanta 2 weeks ago
parent 99461223eb
commit 08b1c00112

@ -0,0 +1,3 @@
# juego
esto es un repo de prueba

@ -0,0 +1,5 @@
function love.conf(t)
t.window.width = 800
t.window.height = 640
t.window.title = "nombre juego"
end

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

@ -0,0 +1,9 @@
function intro()
print "la intro"
end
function room1()
roomName="Sotano"
readTile("room1.png")
getBlockPos(3)
end

@ -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
Loading…
Cancel
Save