1. The way I am trying to add the units to the grid is by coding them as if they were another tile, but above the first "plane" of tiles. It seemed practical at first. I'm wondering if this is the way I should be doing it, or If I should take a different route.
2. I'm also trying to make the tiles clickable and for the unit to move to the tile that the user clicks.
3. I have the game set up so that if you press the "P" button it will add the human unit to tile [2][2] on the grid, the issue is that when the unit gets added to the field the tile beneath it changes color to the "Highlight tile" that I have created instead of staying the way it was. I already understand WHY it's doing that but I'm not sure how to fix it.
4. If anyone wouldnt mind helping me with making the main unit mobile, and coding the grid to make it clickable I would really appreciate it.
Here is the code for the main plane of tiles and for the units that will spawn above it.
Code: Select all
function love.draw()
-- first drawing the background image since it apparently has to generate before any other graphics otherwise the get overlapped.
love.graphics.draw(background)
-- main plane of tiles
for x = 1,grid_size do
for y = 1,grid_size do
if grid[x][y] == 1 then
love.graphics.draw(ground,
grid_x + ((y-x) * (block_width / 2)),
grid_y + ((x+y) * (block_depth / 2)) - (block_depth * (grid_size/2)))
else -- grid[x][y] == 2 then
love.graphics.draw(highlight,
grid_x + ((y-x) * (block_width / 2)),
grid_y + ((x+y) * (block_depth / 2)) - (block_depth * (grid_size/2)))
end
if grid[x][y] == 3 then
love.graphics.draw(hlgreen,
grid_x + ((y-x) * (block_width / 2)),
grid_y + ((x+y) * (block_depth / 2)) - (block_depth * (grid_size/2)))
end
end
end
-- units on top
for x = 1,math.ceil(grid_size/2) do
for y = 1,math.ceil(grid_size/2) do
if grid[x][y] == 4 then
love.graphics.draw(manfront,
grid_x + ((y-x) * (block_width / 2)),
grid_y + ((x+y) * (block_depth / 2)) - (block_depth * (grid_size / 2)) - block_depth)
end
if grid[x][y] == 5 then
love.graphics.draw(zombiefront,
grid_x + ((y-x) * (block_width / 2)),
grid_y + ((x+y) * (block_depth / 2)) - (block_depth * (grid_size / 2)) - block_depth)
end
end
end
love.graphics.draw(pbutton, 710, 4)
love.graphics.draw(qbutton, 780, 4)
love.graphics.draw(lbutton, 710, 32)
love.graphics.draw(health100, 8, 480)
end
Screenshot 2 is after it is pushed. You can see he spawns perfectly but the tile beneath changes.