## [solved]issues with an isometric map

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Pospos
Citizen
Posts: 68
Joined: Sun Jun 18, 2017 11:10 am

### [solved]issues with an isometric map

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.
Attachments
isometric_heightmap.love
Last edited by Pospos on Wed Jun 20, 2018 8:52 pm, edited 1 time in total.
ⵜⴰⵎⴰⵣⵉⵖⵜ(https://en.wikipedia.org/wiki/Berbers)

Nelvin
Prole
Posts: 40
Joined: Mon Sep 12, 2016 7:52 am

### 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.

Pospos
Citizen
Posts: 68
Joined: Sun Jun 18, 2017 11:10 am

### 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://en.wikipedia.org/wiki/Berbers)

Nelvin
Prole
Posts: 40
Joined: Mon Sep 12, 2016 7:52 am

### 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.

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

Pospos
Citizen
Posts: 68
Joined: Sun Jun 18, 2017 11:10 am