main.luaError: map.lua:9: bad argument #2 to 'draw' (Quad expected, got nil)
Code: Select all
function love.load()
lg = love.graphics;
lm = love.mouse;
lk = love.keyboard;
-- requaire
require "load"
require "menu"
require "mouseactions"
require "keyboardactions"
require "player"
require "game"
require "settings"
require "map"
-- loading
loadFonts();
loadImages();
loadSettings();
-- initKeys --
keyPressed = {};
-- inicialization
initMenu();
initMouse();
initGame();
initPlayer();
initMap();
showMenu();
updateTime = 0;
end
function love.draw()
if mapShow then
drawMap();
end
if playerSpawned then
drawPlayer();
moveKeyPressed();
end
mouseSwitched = false;
mouseScrollUp = false;
mouseScrollDown = false;
end
(Which is called when selecting a new game in main menu)
Code: Select all
function startGame()
playerSpawned = true;
mapShow = true;
end
Code: Select all
function initMap()
mapShow = false
mapPosX = 140
mapPosY = 120
colorChanged = false;
end
function drawMap()
lg.draw(gameMap, mapPosX, mapPosY); -- This line produces an error
lg.draw(gameMapView, mapPosX, mapPosY); -- And there
end
function moveMap(X,Y)
nextPosX = mapPosX+X; -- There can receive global variable
nextPosY = mapPosY+Y; -- And there
dx = 0;
dy = 0;
r, g, b, a = gameMapData:getPixel(windowWidth/2-nextPosX+dx,windowHeight/2-nextPosY+dy);
if a >= 50 then
mapPosX = nexpPosX;
mapPosY = nextPosY;
else
r, g, b, a = gameMapData:getPixel(windowWidth/2-nextPosX+dx,windowHeight/2-mapPosY+dy)
if a >= 50 then
mapPosX = nextPosX;
end
r, g, b, a = gameMapData:getPixel(windowWidth/2-mapPosX+dx,windowHeight/2-nextPosY+dy)
if a >= 50 then
mapPosY = nextPosY;
end
if a < 50 then
mapPosX = -100
mapPosY = -100
end
end
end