HELP!

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
Kasperelo
Party member
Posts: 343
Joined: Fri Apr 13, 2012 1:47 pm
Location: The Milky Way

HELP!

Post by Kasperelo »

I'm working on a game, really really reaaaaally simple. It's called "Followers"
and you control a mouse and every third second a new red dot appear on the
screen. If you touch a red dot, you lose. Every second counts as one point,
but my problem is, I don't know how to make a start menu, cause if I write:

function love.load()
screenMenu = love.graphics.newImage("graphics/screens/menu.png")
screenPlay = love.graphics.newImage("graphics/screens/play.png")
buttonStart = love.graphics.newImage("graphics/buttons/start.png")
screen = menu
end

function love.update()
end

function love.draw()
if screen == menu then
love.graphics.draw(screenMenu, 0, 0)
else love.graphics.clear(screenMenu)
end
if screen == play then
love.graphics.draw(screenPlay, 0, 0)
else love.graphics.clear(screenPlay)
end
if screen == menu then
love.graphics.draw(buttonStart, 400, 300)
else love.graphics.clear(buttonStart)
end
end

my game screen is white (because screenPlay is white) and whatever I do, it remains
white! HELP!
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: HELP!

Post by Nixola »

Probably you suffer of the PO2 Syndrome, like me :cry:
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
Adamantos
Prole
Posts: 27
Joined: Sun May 16, 2010 10:47 pm

Re: HELP!

Post by Adamantos »

Hey,

actually you don't need the love.graphics.clear()-function. The screen is cleared automaticly on every cycle just before your love.draw(...) is called.
So just simple draw your stuff and you're fine...

So something like that:

Code: Select all

function love.draw()
  if screen == menu then
    love.graphics.draw(screenMenu, 0, 0)
  elseif screen == play then
    love.graphics.draw(screenPlay, 0, 0)
  elseif screen == menu then
    love.graphics.draw(buttonStart, 400, 300)
  end
end
After all you need some code in the love.update() section to change the status of the screen-variable.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: HELP!

Post by Nixola »

And, just noticed, you shouldn't write 'if screen == menu' 'cause menu and play are nil; you should write 'if screen == "menu' or something like that
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: HELP!

Post by bartbes »

Also, menu and play are both nil, you probably want "menu" and "play" respectively.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: HELP!

Post by Jasoco »

Nixola wrote:Probably you suffer of the PO2 Syndrome, like me :cry:
Isn't PO2 supposed to be dead now that 0.8.0 is out?
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: HELP!

Post by TechnoCat »

Jasoco wrote:
Nixola wrote:Probably you suffer of the PO2 Syndrome, like me :cry:
Isn't PO2 supposed to be dead now that 0.8.0 is out?
Yes, I believe so.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: HELP!

Post by Nixola »

Yeah, it should... But how can we know he's not using 0.7.2? Wait... Adamantos, what OVE version are you using?
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests