Jump to content

show menu?


dennis
 Share

Recommended Posts

Hello all,

 

is there a possible way, when I press the escape button it will show up a menu? normally I use

SetBlend(1)
        --code for menu which I need to know.
SetBlend(0)
Flip(0)

 

 

and if it's possible how to make a game menu in lua?

such as game preloader.

 

and my second question is:

 

when I open up my game in full screen (start.Lua File) it always shows command window.

I opened a thread for another language to accomplish that. but how to do that for LUA?

 

sorry for the questions. I'm still learning

 

Cheers!

Link to comment
Share on other sites

Here would be one quick and dirty way

 

showMenu = false

function ShowMenu()
  -- draw your menu here
end

if KeyHit(KEY_ESCAPE) == 1 then
     showMenu = true;
end

SetBlend(1)
ShowMenu()
SetBlend(0)
Flip(0)

 

That's pretty basic. What I do with stuff like this is create states. A simple state could have an Update() and Draw() function. More complex can have transition methods, but in Lua I do something like:

 


function MainMenuUpdate()
  -- example might be looking for the mouse click over a button and set currentState variable to a different state which will route it into that states functions that you create
end

function MainMenuDraw()
end

currentState = "main.menu"

-- create the table and store functions for each state
gameStates = {}
gameStates["main.menu"].onUpdate = MainMenuUpdate
gameStates["main.menu"].onDraw = MainMenuDraw


--  main loop
while(...)
  -- call the update on whatever state we are in. inside these states is where we can change the currentState variable
  gameStates[currentState].onUpdate()

  gameStates[cirrentState].onDraw()
  Flip()
end

 

Then you can get fancy with transitions because this idea above just instantly switches states, but transitions can make for cooler looking transitions between states.

Link to comment
Share on other sites

Here would be one quick and dirty way

 

showMenu = false

function ShowMenu()
  -- draw your menu here
end

if KeyHit(KEY_ESCAPE) == 1 then
     showMenu = true;
end

SetBlend(1)
ShowMenu()
SetBlend(0)
Flip(0)

 

That's pretty basic. What I do with stuff like this is create states. A simple state could have an Update() and Draw() function. More complex can have transition methods, but in Lua I do something like:

 


function MainMenuUpdate()
  -- example might be looking for the mouse click over a button and set currentState variable to a different state which will route it into that states functions that you create
end

function MainMenuDraw()
end

currentState = "main.menu"

-- create the table and store functions for each state
gameStates = {}
gameStates["main.menu"].onUpdate = MainMenuUpdate
gameStates["main.menu"].onDraw = MainMenuDraw


--  main loop
while(...)
  -- call the update on whatever state we are in. inside these states is where we can change the currentState variable
  gameStates[currentState].onUpdate()

  gameStates[cirrentState].onDraw()
  Flip()
end

 

Then you can get fancy with transitions because this idea above just instantly switches states, but transitions can make for cooler looking transitions between states.

 

awesome, and whats the best? to use images or the DrawRect variable?

and how can I add those?

 

the easier thing for you would be telling me where I can find A manual for this kind of things instead :) if you like to offcourse

Link to comment
Share on other sites

I'm going to say just use images based on what little I know about you (I assume you don't have much programming exp and getting into drawing buttons and such might be a pain for you).

 

 

I would say buy some game programming book and read it cover to cover. Most will handle things like this. I can't think of one off the top of my head but I'm sure some others will help or just do an Amazon search and read the reviews.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...