How can I get better at programming menus, textinput, keypressed, and other ui stuff?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
xThomas
Prole
Posts: 16
Joined: Tue May 02, 2017 2:43 am

How can I get better at programming menus, textinput, keypressed, and other ui stuff?

Post by xThomas »

I started a clone of oregon trail to familiar myself with love. I have not gotten very far. It takes an hour+ for each screen. trail_setup_screen_three took the longest, several hours just adding the switcher between questions. There are unused/redundant variables everywhere, I don't consistently use what I do have, often I'll do things two different ways as I get more familiar with LOVE2d, etc.. At first I thought it'd be best to just finish the game and then figure out what I can do better afterward but i am wasting so much time on menus that I will ask for advice :emo:

Here is the full code so far. 743 lines long

https://pastebin.com/Ap5Vdkxe
User avatar
BruceTheGoose
Citizen
Posts: 76
Joined: Sat Sep 20, 2014 2:54 pm

Re: How can I get better at programming menus, textinput, keypressed, and other ui stuff?

Post by BruceTheGoose »

I would start by separating the contents of that file into different separate files. Very hard to read.

The way I would structure a menu (for example) would look like this:

Code: Select all


-- Menu.lua

Menu = {}

Menu.load = function(self)
 -- Load anything that will be in this menu
end

Menu.update = function(self,dt)
-- Update anything that will be in this menu
end

Menu.draw = function(self)
-- Draw anything that will be in this menu
end

-- main.lua

function love.load()
    require("Menu")
    Menu:load()
end

function love.update(dt)
    Menu:update(dt)
end

function love.draw()
    Menu:draw()
end

"I don't know."
Post Reply

Who is online

Users browsing this forum: No registered users and 30 guests