just working on a new game, or more so working on just something to get back into LÖVE. but have been playing with grid based creation of maps. but having trouble getting the player to interact with my borders, or more so, my images for walls.
did use this lovely piece of info for doing grid based maps [ viewtopic.php?f=4&t=12639&p=75275&hilit ... els#p75275 ]. have been able to make borders, but only on the edges of the screen. but want the wallBlocks to have those borders
rather than post the love file, since it does spit out errors due to me working on it. ill just post the code that needs looking at, see if anyone can help me on it
thanks
main.lua
Code: Select all
require 'code/playerClass'
-- require 'code/blockCollide'
require 'code/mapClass'
function love.load()
mapLoad()
map = level1_map
end
function love.update(dt)
require('lurker/lurker').update()
playerUpdate(dt)
mapUpdate()
end
function love.draw()
mapDraw()
playerDraw()
end
Code: Select all
block = {}
blockFloor = love.graphics.newImage('asset/blockFloor.png')
blockWall = love.graphics.newImage('asset/blockWall.png')
function mapLoad()
level1_map = {
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
{ 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1 },
{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
{ 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1 },
{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
{ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1 },
{ 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 },
{ 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 },
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
}
end
function mapUpdate()
if player.x < 0 then
player.x = 0
end
if player.y < 0 then
player.y = 0
end
if player.x + player.draw:getWidth() > blockWall then
player.x = blockWall - player.draw:getWidth()
end
if player.y + player.draw:getHeight() > blockWall then
player.y = blockWall - player.draw:getHeight()
end
end
function mapDraw()
for y=1, #map do
for x=1, #map[y] do
if map[y][x] == 1 then
love.graphics.draw(blockWall, x*32, y*32)
end
if map[y][x] == 0 then
love.graphics.draw(blockFloor, x*32, y*32)
end
end
end
end