This is what I get. Seems to work how I imagine it on ubuntu, but not on windows. I changed the minimap background to white to see if I got the right colors, but it doesn't.
Here is the code for creating the canvas
Code: Select all
function hud:buildminimap()
-- create a minimap
self.minimap = love.graphics.newCanvas(self.worldlink.dimensions.y,self.worldlink.dimensions.x)
self.minimap:setFilter('nearest','nearest')
oldcolor = { love.graphics.getColor() }
local colorz = {
{ 0, 0,0 },
{ 0,230,0 },
{ 0,180,0 },
{ 255,0,0 },
{ 0,0,230 }
}
-- makes the background rectangle
love.graphics.setColor(0,0,0)
self.minimap:renderTo(function() love.graphics.rectangle('fill',0,0,self.worldlink.dimensions.y,self.worldlink.dimensions.x) end)
-- draws the points on the background, this are a 1:1 with the map grid
for ix = 1, self.worldlink.dimensions.x do
for iy = 1, self.worldlink.dimensions.y do
love.graphics.setColor(colorz[self.worldlink.map[ix][iy]])
self.minimap:renderTo(function() love.graphics.point(iy,ix) end)
end
end
-- scales the minimap
local angledwidth = self.minimap:getWidth()*math.cos(configuration.hud.minimap.rotationangle) +
self.minimap:getHeight()*math.cos(configuration.hud.minimap.rotationangle)
local angledheight = self.minimap:getWidth()*math.sin(configuration.hud.minimap.rotationangle) +
self.minimap:getHeight()*math.sin(configuration.hud.minimap.rotationangle)
local scalefactors = { configuration.hud.minimap.size.width / angledwidth,
configuration.hud.minimap.size.height / angledheight }
-- this section rotates and scales the big pixel map to the right height and width based on the minimap size in the window
local tempcanvas = love.graphics.newCanvas(configuration.hud.minimap.size.width,configuration.hud.minimap.size.height)
love.graphics.setColor(0,0,0)
tempcanvas:renderTo( function()
love.graphics.rectangle('fill',0,0,configuration.hud.minimap.size.width,configuration.hud.minimap.size.height)
end)
love.graphics.setColor(255,255,255,255)
-- this rotates the map 45 degrees and scales it
tempcanvas:renderTo( function()
love.graphics.draw( self.minimap,
0,
0 + configuration.hud.minimap.size.width*math.cos(configuration.hud.minimap.rotationangle)/2,
-configuration.hud.minimap.rotationangle,
math.min(unpack(scalefactors)),
math.min(unpack(scalefactors))
)
end)
self.minimap = tempcanvas
Code: Select all
-- drawing the minimap (the bottom one)
love.graphics.setColor(255,255,255,255)
love.graphics.draw(self.minimap,
0 + configuration.hud.minimap.padding.left,
self.minimapdrawpos.y ,
0,
1,
1/2
)
-- the top one
love.graphics.draw(self.minimap,0,0)
Thanks for the help. I am hoping I am just using the code wrong and it isn't a problem with love.