0
\$\begingroup\$

I just got started programming games and decided to try out love2d since I'm learning lua.

I was wondering if anyone knows how I can create just a simple 2-3 button menu when you start up the game.

All I want to do is make a start up menu.

I have 2 files and nothing else:

  • main.lua, in which I have the game code and the level design
  • conf.lua, in which I have the title screen code and the icon of the game

I couldn't find any wiki page to help me for coding for the first time a splash screen and a overall game screen !!

now i have only one screen the game screen and i want to have 3 screens : 1 splash screen in wich i want to draw a image background and 3 buttons PLAY,EXIT,TITLE with coding mousepress! 2 game screen! 3 game over screen with an other background image!

\$\endgroup\$
  • 1
    \$\begingroup\$ Please use the edit button to add more information to your question - do not use answers as replies. The more information you can include about how you've implemented the feature so far, and the more precisely you can describe your problem, the better the answers you'll tend to get. \$\endgroup\$ – DMGregory Mar 12 '18 at 12:25
  • \$\begingroup\$ I've converted your answer into an edit. I'll reiterate: please use the "edit" button to add information to your question. Do not post an answer unless you are sharing a solution. Now, help break down for us where you're running into trouble implementing this menu screen. Presumably this is a background image, some text, a button to start the game and a button to quit? Which parts have you successfully built so far? Which parts aren't working, or you need help figuring out how to build them? \$\endgroup\$ – DMGregory Mar 13 '18 at 12:05
2
\$\begingroup\$

There isn't a built-in menu system for love2d. The developers take a 'do-it-yourself' approach to a lot of such things. Here's an example of how I ended up rigging my menu for my first time:

function love.load()
    currentScreen = 'menu'
end

function love.update(dt)
    if currentScreen == 'menu' then
        menuUpdate(dt)
    else
        gameUpdate(dt)
    end
end

function love.draw()
    if currentScreen == 'menu' then
        menuDraw(dt)
    else
        gameDraw(dt)
    end
end

function menuUpdate(dt)
    if love.mouse.isDown(1) then
        local x, y = love.mouse.getX(), love.mouse.getY()
        --check to see if the mouse is within the option box. If it is, set currentScreen to 'game'
    end
end

--all the other stuff(gameUpdate,gameDraw,menuDraw)
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.