Hi guys!
When I get answers to my Time reading questions, I think I am one step away from a simple game. I need a menu.
But how should I do it? When I looked into your source codes, I see you use this "gamestate" thinky. Is this the only way to do a menu and how should I use it? Can someone give me tips?
Thanks (again and again)
How to do a menu?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: How to do a menu?
A very simple way of doing gamestates is just having a variable called gamestate or something, then depending on the value of it draw and update different things. I usually just use a string. here's an simple example:
In the menu you would probably want buttons. You could make it all in löve by using love.graphics.rectangle and love.graphics.print, Or design buttons in photoshop or something. then in love.mousepressed you can check if the mouse is on one of the buttons, and if it is, make something happen. Hope this helped at least a little.
I might make a more complete example actually..check back in a minute. lol
Code: Select all
function love.load()
gamestate = "menu"
end
function love.update(dt)
if gamestate == "menu" then
--Menu stuff here
elseif gamestate == "game" then
--Game stuff here
end
end
function love.draw()
if gamestate == "menu" then
--Menu stuff here
elseif gamestate == "game" then
--Game stuff here
end
end
I might make a more complete example actually..check back in a minute. lol
Re: How to do a menu?
Here's a very basic button and gamestate code. I would recommend using pictures for buttons as that would likely look better. Also, I do believe there are libraries out there for GUI's and menus. Might wanna look into that.
Who is online
Users browsing this forum: Semrush [Bot] and 10 guests