Isometric

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
legendman3
Citizen
Posts: 68
Joined: Sun Jan 22, 2012 8:29 pm

Isometric

Post by legendman3 »

I tried using the code from this part of the wiki:
https://love2d.org/wiki/Tutorial:Isometric_Graphics

When i enter it into the lua file i get this:

Code: Select all

function love.load()
	block_width = grass:getWidth()
	block_height = grass:getHeight()
	block_depth = block_height / 2
	
	grid_size = 20
	grid = {}
	for x = 1,grid_size do
		grid[x] = {}
		for y = 1,grid_size do
			grid[x][y] = 1
		end
	end
	
	grid[2][4] = 2
	grid[6][5] = 2
	
	for x = 1,grid_size do
		for y = 1,grid_size do
			if grid[x][y] == 1 then
				love.graphics.draw(grass,
					grid_x + ((y-x) * (block_width / 2)),
					grid_y + ((x+y) * (block_depth / 2)) - (block_depth * (grid_size / 2)))
			else -- grid[x][y] == 2
				love.graphics.draw(dirt,
					grid_x + ((y-x) * (block_width / 2)),
					grid_y + ((x+y) * (block_depth / 2)) - (block_depth * (grid_size / 2)))
			end
		end
	end
end
Then i get a error about grass or something:
VvdGK.png
VvdGK.png (6.69 KiB) Viewed 91 times
So what code am i missing?
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Isometric

Post by tentus »

You need to make an image called grass. It needs to be before line 2, "block_width = grass:getWidth()".

Code: Select all

grass = love.graphics.newImage("filename.png")
Kurosuke needs beta testers
User avatar
legendman3
Citizen
Posts: 68
Joined: Sun Jan 22, 2012 8:29 pm

Re: Isometric

Post by legendman3 »

Hooray i got all the code worked out!
EzAQK.png
EzAQK.png (13.52 KiB) Viewed 90 times
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 51 guests