I imagine that in pseudocode it would be likesomeguy99 wrote:I really dont know how ill do that.
Code: Select all
if variable does not equal nil then draw variable
I imagine that in pseudocode it would be likesomeguy99 wrote:I really dont know how ill do that.
Code: Select all
if variable does not equal nil then draw variable
Code: Select all
function load()
font = love.graphics.newFont(love.default_font, 12)
love.graphics.setFont(font)
message = "Error:Some files are missing.Press Escape to exit."
music = love.audio.newMusic("menu.ogg")
love.audio.play(music,0)
wallpaper = love.graphics.newImage("menu.png")
play = love.graphics.newImage("play.png")
options = love.graphics.newImage("options.png")
about = love.graphics.newImage("about.png")
exit = love.graphics.newImage("exit.png")
play_selected = love.graphics.newImage("play_selected.png")
options_selected = love.graphics.newImage("options_selected.png")
about_selected = love.graphics.newImage("about_selected.png")
exit_selected = love.graphics.newImage("exit_selected.png")
end
function draw()
if love.keyboard.isDown(love.key_escape) then
love.system.exit( )
end
if love.mouse.isDown(love.mouse_left) and x>60 and x<340 and y>660 and y<740 then
love.system.exit( )
end
if wallpaper ~= nil then
love.graphics.draw(wallpaper,512,384)
end
x = love.mouse.getX( )
y = love.mouse.getY( )
if play ~= nil and play_selected ~= nil and x>60 and x<340 and y>360 and y<440 then
love.graphics.draw(play_selected,200,400)
else
love.graphics.draw(play,200,400)
end
if options ~= nil and options_selected ~= nil and x>60 and x<340 and y>460 and y<540 then
love.graphics.draw(options_selected,200,500)
else
love.graphics.draw(options,200,500)
end
if about ~= nil and about_selected ~= nil and x>60 and x<340 and y>560 and y<640 then
love.graphics.draw(about_selected,200,600)
else
love.graphics.draw(about,200,600)
end
if exit ~= nil and exit_selected ~= nil and x>60 and x<340 and y>660 and y<740 then
love.graphics.draw(exit_selected,200,700)
else
love.graphics.draw(exit,200,700)
end
if love.mouse.isDown(love.mouse_left) and x>60 and x<340 and y>360 and y<440 then
love.mouse.setVisible(false)
wallpaper = nil
play = nil
options = nil
about = nil
exit = nil
end
end
Code: Select all
something = love.graphics.newImage("something")
something_select = love.graphics.newImage("something_selected")
function draw()
if something and something_select then
love.graphics.draw(something_select)
else
love.graphics.draw(something)
end
end
Code: Select all
something = nil
something_select = love.graphics.newImage("something_selected")
function draw()
if something and something_select then --prevents this from happening, something == nil
love.graphics.draw(something_select)
else --so what do we do when something == nil? we try and draw it?!
love.graphics.draw(something)
end
end
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 0 guests