소스 검색

multi layer iso shit idfk i'm really high fam

master
Isabelle L. 5 년 전
부모
커밋
c7e2b20ebd
2개의 변경된 파일36개의 추가작업 그리고 21개의 파일을 삭제
  1. +7
    -3
      main.lua
  2. +29
    -18
      world.lua

+ 7
- 3
main.lua 파일 보기

@@ -5,12 +5,12 @@ local world = require("world")
function love.load()
-- set the overall map offset
offset = {
x = 0,
y = 0
x = 304,
y = 48
}
-- generate the world and load the files
world.new(20, 20)
world.new(20, 20, 3)
world.loadTiles()
end

@@ -37,6 +37,10 @@ function love.keypressed(key, scanCode, isRepeat)
if key == "down" then
offset.y = offset.y - 16
end

if key == "escape" then
love.event.quit(0)
end
end

-- love's draw function


+ 29
- 18
world.lua 파일 보기

@@ -3,21 +3,30 @@ local util = require("util")

-- world stuffs
local world = {}
-- create a new world with given height and width
function world.new(width, height)
-- create a new world with given depth and width
function world.new(width, depth, height)
world.width = width
world.depth = depth
world.height = height
world.hover = nil
world.select = love.graphics.newImage("img/tiles/select.png")
world.select = love.graphics.newImage("img/tiles/select.png")

for x = 1, world.width do
world[x] = {}
for y = 1, world.height do
world[x][y] = "nothing"
for y = 1, world.depth do
world[x][y] = {}
for z = 1, world.height do
world[x][y][z] = "nothing"
end
end
end
end

-- generates a world, should be called after world.new()
function world.generate()

end

-- load the tile files
function world.loadTiles()
world.tiles = {}
@@ -30,21 +39,23 @@ local world = {}
-- render the world
function world.render(offset)
for x = 1, world.width do
for y = 1, world.height do
local tile = world[x][y]
local loc = util.cartToIso({x = x, y = y})
for y = 1, world.depth do
for z = 1, world.height do
local tile = world[x][y][z]
local loc = util.cartToIso({x = x, y = y})
if tile == "grass" then
image = world.tiles.grass
elseif tile == "dirt" then
image = world.tiles.dirt
elseif tile == "water" then
image = world.tiles.water
else
image = world.tiles.nothing
end
if tile == "grass" then
image = world.tiles.grass
elseif tile == "dirt" then
image = world.tiles.dirt
elseif tile == "water" then
image = world.tiles.water
else
image = world.tiles.nothing
end
love.graphics.draw(image, loc.x * 16 + offset.x, loc.y * 16 + offset.y)
love.graphics.draw(image, loc.x * 16 + offset.x, loc.y * 16 + offset.y - z * 16)
end
end
end



불러오는 중...
취소
저장