please help make an options menu!

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
walia6
Prole
Posts: 5
Joined: Mon Oct 01, 2012 3:15 pm

please help make an options menu!

Post by walia6 »

I'm very new to LOVE. I only started 9/30/12!
But I'm starting a game now and I would like to start with the menu and stuff, Then gameplay.
So first. How do I make An options menu?
For example I would like the user to be able to tell the game "Please change line2 to 220942804920!".
When the player chooses a choice for the screen resolution the game would edit the line screen resolution is defined and edit those numbers to what the use inputted. Thanks in advance! :)
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: please help make an options menu!

Post by Robin »

Welcome!

What do you have so far? Could you upload a .love? Then we can make better suggestions. Right now we can only either say very vague and general things (which won't help you) or do everything for you (which won't help you either).

If you want to help yourself, it's always a good idea to look around on the forums, and read the source of games other people have made.
Help us help you: attach a .love.
User avatar
xelu
Prole
Posts: 9
Joined: Mon Jun 25, 2012 12:27 pm
Location: Romania
Contact:

Re: please help make an options menu!

Post by xelu »

Hey, Well not sure if i'm in the position to answer your question since i'm not a programmer (what the hell am i doing here anyway)

But structure wise, the way i'd do it is tell the game to take it's information from a text file .txt or .ini

like resolution , antialiasing , texture quality , mouselock and whatnot

the text file would look something like this:

Code: Select all

set camfactor 0.6
resolution 960x540
mouselock false
antialiasing 16
That's how it's done with the game i'm working on right now and it works GREAT :D

You'd change the values in that text through the game or through a simple launcher...

And also in case the player sets the game to an un-supported resolution or something , he can easily fix it from the text file manually , without having to dig through the line codes or even worse, reinstall the game :D

Hope this helped
walia6
Prole
Posts: 5
Joined: Mon Oct 01, 2012 3:15 pm

Re: please help make an options menu!

Post by walia6 »

Robin wrote:Welcome!
Thanks!
Robin wrote: What do you have so far? Could you upload a .love? Then we can make better suggestions. Right now we can only either say very vague and general things (which won't help you) or do everything for you (which won't help you either).

If you want to help yourself, it's always a good idea to look around on the forums, and read the source of games other people have made.
I added it as an attachment to this reply. But i know the conf.lua already but i did not impliment it yet. so i dont need an explanation of the conf.lua.
Destroi.love
(6.58 MiB) Downloaded 239 times
walia6
Prole
Posts: 5
Joined: Mon Oct 01, 2012 3:15 pm

Re: please help make an options menu!

Post by walia6 »

xelu wrote:
And also in case the player sets the game to an un-supported resolution or something , he can easily fix it from the text file manually , without having to dig through the line codes or even worse, reinstall the game :D

Hope this helped
Well actually I had an idea just for that. when the user set the option the game wouldn't apply it permenantly. it would apply it and the screen would tell the person that they had 10 seconds to click keep this resolution. if they didnt by 10 seconds the game would then switch to the previous resolution :)
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: please help make an options menu!

Post by T-Bone »

Create buttons in the game (visually, draw something that looks like a button). Then check if the user clicks on that button. If so, do something. If you need for example numerical values (like screen resolution), you can either have a few presets (the most common method, used in almost all games) or you can let the user choose freely (in this case you will have to listen to keypresses from the keyboard and figure out what the user is trying to type). Only your imagination and your programming skills limit you, and both can be improved with reading, training, discussing and thinking.

If you have more specific questions, feel free to ask.
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: please help make an options menu!

Post by Lafolie »

Might be a little off-topic but I would highly recommend making gameplay before menus. Not only does it make more sense from a practical standpoint, but it's also much more fun and rewarding! (at least in my experience :))
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
walia6
Prole
Posts: 5
Joined: Mon Oct 01, 2012 3:15 pm

Re: please help make an options menu!

Post by walia6 »

Lafolie wrote:Might be a little off-topic but I would highly recommend making gameplay before menus. Not only does it make more sense from a practical standpoint, but it's also much more fun and rewarding! (at least in my experience :))
Ok. ill try that
User avatar
paritybit
Citizen
Posts: 53
Joined: Thu Sep 06, 2012 3:52 am

Re: please help make an options menu!

Post by paritybit »

I agree with Lafolie's sentiment; it's much more fun and rewarding to work on the game play rather than the administrative stuff. But I know, at least for me, that it's hard to do that if you don't at least have an idea of how you might do those boring things.

I don't know if this helps you much or not, but I've been working on a menu system for myself. I was building a game and realized I needed some way to configure it (much like you) so I started this project. It's probably not the optimal solution, but it will give you an idea of what's necessary. Here's a screenshot:
menu.png
menu.png (22.72 KiB) Viewed 6012 times
Attached is a demo with a video and audio menu (very basic) and an exit function. I've used kikito's middleclass as a means of making it more object oriented. The code is fairly well documented (at least functions and their parameters). It's also got a basic input system and a 'class' that made dealing with colors easier for me. The main.lua contains the code that creates the menu.

Here is a snippet of code that sets up the video portion of the menu:

Code: Select all

	menu = MinimalMenu()

	-- set up an options menu.
	local options = menu:addItem(nil, 'Options', nil, nil)
	
	-- set up a video menu with fullscreen (on, off), vsync (on, off) and available resolutions
	local video = menu:addItem(options, 'Video', 'Contains options about video parameters', nil)
	local fullscreen = menu:addItem(video, 'Fullscreen', 'Sets the application to fullscreen', nil)
	menu:addItem(fullscreen, 'On', '', function() game.mode.fullscreen = true; updateMode() end)
	menu:addItem(fullscreen, 'Off', '', function() game.mode.fullscreen = false; updateMode() end)
	if game.mode.fullscreen == false then fullscreen.selectedChild = 2 end
	local vsync = menu:addItem(video, 'Vsync', 'Sets the vertical sync', nil)
	menu:addItem(vsync, 'On', '', function() game.mode.vsync = true; updateMode() end)
	menu:addItem(vsync, 'Off', '', function() game.mode.vsync = false; updateMode() end)
	if game.mode.vsync == false then vsync.selectedChild = 2 end
	local resolutions = menu:addItem(video, 'Resolutions', 'Select a resolution.', nil)
	
	local modes = love.graphics.getModes()
	table.sort(modes, function(a, b) return a.width*a.height < b.width*b.height end)
	
	for _, mode in pairs(modes) do
		menu:addItem(resolutions, mode.width .. 'x' .. mode.height, 'no hint',
			function() game.mode.width = mode.width; game.mode.height = mode.height; updateMode()  end)
	end
It's not enough to have a menu, you'll need some kind of game state library to make it work. If you are starting from nothing I'd suggest having a look at hump which has a good set of basic functionality (including game states). There are tons of other libraries to peruse as well. And don't be like me and totally miss the snippets section of the wiki!

The demo does not save any settings, it starts with the defaults every time you load it up.

Note: it's not quite done, but it's close enough.
Attachments
minimalmenu.love
(10.38 KiB) Downloaded 231 times
Last edited by paritybit on Fri Oct 05, 2012 4:28 pm, edited 1 time in total.
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: please help make an options menu!

Post by Roland_Yonaba »

paritybit wrote: Note: it's not quite done, but it's close enough.
I really like this one. Good job!
paritybit wrote:Note2: I couldn't get the fullscreen option to work right; maybe somebody can give me a hint?
Well, just change line 33 in main.lua:

Code: Select all

love.graphics.setMode(game.mode.width, game.mode.height, game.fullscreen, game.vsync)
to this:

Code: Select all

love.graphics.setMode(game.mode.width, game.mode.height, game.mode.fullscreen, game.mode.vsync)
Some suggestion:
First, consider finding another way to highlight the selected entry. Fact is using different colors (green, white) don't make it obvious enough (to me). Maybe you can draw some glow effect, on just use some sort of alpha fading for that.

Second, maybe the of values for Audio should be more flexible.
You can locally set some vars for lower, higher values and a step value:

Code: Select all

local volume_range = {lower = 0, step = 0.5, high = 1}
Then generate all the relevant menu entries using a numberic for loop:

Code: Select all

for vol = volume_range.lower, volume_range.high, volume_range.step do
  local vol_string_percentile = (vol*100)..'%'
  menu:addItem(volume,
                          vol_string_percentile,
                          (Sets the volume to %s'):format(vol_string_percentile), 
                          function() love.audio.setVolume(vol) end)
end
Third, why not implementing a kind of linear sliding to navigate between menu entries (left/right/up/down direction) ? You can even use easing functions, and add a public interface method to set the type of ease.
That would be cool.

Okay, think I'm done with my silly suggestions. Keep up the good job.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 3 guests