Hello. I'm trying to make a simple application which, when run, will render a cube as well as a simple text on the top right of the screen. That cube is supposed to have a 1/5 chance of being red(instead of orange). I'm somewhat of a beginner, so sorry if this is kinda obvious.
Here's the piece of code:
Code: Select all
function love.load()
isHungry()
gameFont = love.graphics.newFont(25)
end
function isHungry()
number = love.math.random(5, 5)
if number == 5 then
love.graphics.setColor(1, 0, 0)
else
love.graphics.setColor(1, 0.7, 0)
end
end
-- "rectangle" will never be red related to love.draw() running once per frame?
function love.draw()
love.graphics.rectangle("fill", 325, 300, 150, 150)
love.graphics.setColor(1, 0.7, 0)
love.graphics.setFont(gameFont)
love.graphics.print("Level: 25", 650, 35)
end
However, as you can see by comment, "rectangle" will never be red if it's followed by love.graphics.setColor. I've come to understand this happens due to isHungry() only running once in love.load(), while love.draw() runs at 60 FPS(ideally), making isHungry() kinda useless. I want to print text with a separate color(orange), but I don't know how to do so without making the cube change it's color. Help?