Canvas color problem
Posted: Sun May 03, 2015 7:34 pm
Hello everyone,
I'm having some trouble rendering a canvas in the correct colors. It works fine the first time (when the canvas is generated in love.load()), that version is rendered in a random alternating green and blue as expected. Pressing 'R' once will regenerate the canvas using the same code that's called in love.load(), pressing 'R' again will swap the old canvas with the one generated in the previous step. When the new canvas is rendered it's either green on black or blue on black.
The larger square that's rendered after somehow becomes blue too. I'm sure I'm doing something dumb, it's been a while since I messed around with Love and probably missing something very obvious.
- edit
Added the ZIP file, didn't realise the attachment upload is separate from the post submit
Love version: 0.9.2
The functions involved:
modules/tilemapGenerator.lua
tilemapGenerator:generateWater(bFillAll)
Generates a new random map
modules/tilemapRenderer.lua
tilemapRenderer:drawMap(map)
Renders the map table to a canvas
main.lua
love.load()
Generates the map for the first time (this one renders OK)
love.update(dt)
The first time 'R' is pressed, a new map is generated, the second time 'R' is pressed, the canvas for the new map is rendered
load.draw()
Draws the canvas and the 'player tile'
love.keypressed()
Increments 'iMapRefresh' which is used in love.update() to refresh the map.
I'm having some trouble rendering a canvas in the correct colors. It works fine the first time (when the canvas is generated in love.load()), that version is rendered in a random alternating green and blue as expected. Pressing 'R' once will regenerate the canvas using the same code that's called in love.load(), pressing 'R' again will swap the old canvas with the one generated in the previous step. When the new canvas is rendered it's either green on black or blue on black.
The larger square that's rendered after somehow becomes blue too. I'm sure I'm doing something dumb, it's been a while since I messed around with Love and probably missing something very obvious.
- edit
Added the ZIP file, didn't realise the attachment upload is separate from the post submit
Love version: 0.9.2
The functions involved:
modules/tilemapGenerator.lua
tilemapGenerator:generateWater(bFillAll)
Generates a new random map
modules/tilemapRenderer.lua
tilemapRenderer:drawMap(map)
Renders the map table to a canvas
main.lua
love.load()
Generates the map for the first time (this one renders OK)
love.update(dt)
The first time 'R' is pressed, a new map is generated, the second time 'R' is pressed, the canvas for the new map is rendered
load.draw()
Draws the canvas and the 'player tile'
love.keypressed()
Increments 'iMapRefresh' which is used in love.update() to refresh the map.