I realized that the edge xE,yE and zE might be making the game draw cubes on the border of the map so I decided to scrap and change the function. Now it still draws around 800+ at 100%, but only 400+ at 200%. One significant change though ( for the worse ), is that the game runs way slower now. Here is the new code :
Code: Select all
t.cubeIsVisible = function(x,y,z) -- checks if a cube is visible ( in this case covered up by other cubes )
local screenX, screenY = cam:cameraCoords(gridFuncs.normalToIsoX(x,y),gridFuncs.normalToIsoY(x,y,z,3))
if not (((screenX < -150) or (screenX > wW + 150)) and ((screenY < -150) or (screenY > wH + 150))) then
local n = 0
if gridFuncs.gridCheck(x+1,y,z,0,false) then n = n + 1 end
if gridFuncs.gridCheck(x,y+1,z,0,false) then n = n + 1 end
if gridFuncs.gridCheck(x,y,z+1,0,false) then n = n + 1 end
if n == 3 then return false else return true end
else return false end
end
And here is gridCheck()
Code: Select all
t.gridCheck = function(x,y,z,v,t) -- checks the grid for something, if search is outside the grid then it produces an error
return pcall(function()
if t then
if grid[x][y][z] == v then else print(haha + ahah) end
elseif not t then
if grid[x][y][z] ~= v then else print(haha + ahah) end
end end)
end
These two functions get called in another function that loops through the grid called gridDraw(), and gridDraw() in term gets called in love.draw. Also, in love.update I have this :
Code: Select all
if camCycle >= 0.1 then
-- zoom
clientFuncs.camZoom()
cam:zoomTo(zoom)
-- get cam pos
local x,y = cam:position()
-- get the diff between the target pos and current pos
local xDiff,yDiff = math.abs(isoX - x), math.abs(isoY - y)
-- slow down if jumping or falling
local m = 1
if player.data.jumping or
gridFuncs.gridCheck(player.entity.pos.x,
player.entity.pos.y,
player.entity.pos.z - 1,0,true) then m = 0.3 end
if xDiff < 5 then xDiff = 0 else xDiff = xDiff / (20 / (settings.camSpeed/10*player.entity.stats.speed*m)) end
if yDiff < 5 then yDiff = 0 else yDiff = yDiff / (20 / (settings.camSpeed/10*player.entity.stats.speed*m)) end
camCycle = 0
-- move cam x pos
if isoX > x then
cam:lookAt(x + xDiff,y)
else
cam:lookAt(x - xDiff,y)
end
-- update cam pos
local x,y = cam:position()
-- move cam y pos
if isoY > y then
cam:lookAt(x,y + yDiff)
else
cam:lookAt(x,y - yDiff)
end
end
And this :
Code: Select all
camCycle = camCycle + 1*dt*settings.camSpeed
And I think I created some sort of feedback loop, and that in turn slows down the game.
KSP has thaught me that if you aim for the Mun and miss, you'll crash violently into the ground.