Hi, i'm working on an isometric game engine and i have stumbled upon some issues,
especially with the height map. I wanted to make a height map such as these
So, ive been dealing with a progamming problem, which is that i know how to draw the tiles
according to a for loop, but i want to draw them multiple times according to a value.
[solved]issues with an isometric map
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
[solved]issues with an isometric map
- Attachments
-
- isometric_heightmap.love
- (16.67 KiB) Downloaded 91 times
Last edited by Pospos on Wed Jun 20, 2018 8:52 pm, edited 1 time in total.
Re: issues with an isometric map
You just have a typo (I guess) as, in Map:draw you use the height instead of height_size to calculate the yoffset and color gradient of your tiles.
Re: issues with an isometric map
this doesn't work because it creates a block where everything is the same size like this
https://imgsafe.org/image/7973d22185
i want everything to match the height listed here
https://imgsafe.org/image/7973d22185
i want everything to match the height listed here
Re: issues with an isometric map
Ah yeah, I just guessed the solution as that was the obvious problem with regards to the height.
Here's a kind of "fixed" version that does remotely what you aim for (only quick fixed in terms of, a hacky version to show off how it's basically down, it's not a version to keep building upon, does just use a single tile etc.)
I highly recommend you start doing some simpler stuff first though.
Here's a kind of "fixed" version that does remotely what you aim for (only quick fixed in terms of, a hacky version to show off how it's basically down, it's not a version to keep building upon, does just use a single tile etc.)
I highly recommend you start doing some simpler stuff first though.
Code: Select all
local Map = {} -- Map object
Map.MAP = {}
Map.heightmap = {}
Map.Img_Tiles = {} -- Tiles name
Map.Img_Tiles[1] = love.graphics.newImage("assets/tile1.png")
Map.Img_Tiles[2] = love.graphics.newImage("assets/tile2.png")
Map.Img_Tiles[3] = love.graphics.newImage("assets/tile3.png")
local MAX_HEIGHT = 8
function Map:set()
self.mapWidth = 30
self.mapHeight = 30
self.MAP = {}
for y = 1, self.mapHeight do
self.MAP[y] = {}
local row = self.MAP[y]
for x = 1, self.mapWidth do
local h = math.min( love.math.noise(1.13+x*0.056, 1.76 + y*0.047)*MAX_HEIGHT+1, MAX_HEIGHT )
row[x] = math.floor(h)
end
end
end
function Map:draw(camera, tile_size)
local num, edge
edge = tile_size[2]/2
local num = 1
for line =1, self.mapHeight do
for column =1, self.mapWidth do
local height = Map.MAP[line][column]
if height >= 0 then
local x = (column - line)* tile_size[1]/2
local y = (column+1 + line+1)* tile_size[2]/2
-- draws the map according to the tiles and camera position
for tileZ = 0, height do -- draws a the height according to the height map
local col = 100 + tileZ * 30
love.graphics.setColor( col, col, col ) -- sets a color according to height
love.graphics.draw(Map.Img_Tiles[num], x + camera.x, (y - tileZ * edge) + camera.y, 0, 1/camera.scale)
love.graphics.setColor(255, 255, 255)
end
end
end
end
end
return Map
Re: issues with an isometric map
Thank you!
Who is online
Users browsing this forum: No registered users and 94 guests