Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 A Main Menu Problem
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
- IzAk -




PostPosted: Wed Feb 28, 2007 12:09 pm   Post subject: A Main Menu Problem

Hey there, I'm having trouble with a program im making and the problem is this... i want an opening screen, like one youd use to select a difficulty in a game. although i dont need the selections option, i would like help on setting up an opening screen. Thank You!
Sponsor
Sponsor
Sponsor
sponsor
BigBear




PostPosted: Fri Feb 08, 2008 12:21 pm   Post subject: Re: A Main Menu Problem

To make a menu to select the dfficulty level you can do many things. First just get input from the user getch(ans) then if t is equal to "1" then run ask for another input then if that input (ans2) = "1" elsif ans2 = "2" then change difficulty to whatever. Then immediately run your game.

If you declare a variable for the difficulty like
var difficulty : string := "Easy"
then have your main menu with things like Play, Options, How to Play, Quit etc then in option have a inut to change difficulty 1, 2, or 3 if that input = "1" then difficulty = "Easy"
elsif input = "2" then difficulty = Hard"
elsif input = "3" then difficulty = "Impossible"
end if

Then where you run your game have an if statement like this

if difficulty = "Easy" then depending on your game something like delay1 = "20"
elsif difficulty = "Hard" then delay1 = "10"
elsif difficulty = "Impossible" then delay1 = 0
end if

then in your loop have: delay(delay1)
Euphoracle




PostPosted: Fri Feb 08, 2008 2:57 pm   Post subject: RE:A Main Menu Problem

I find it easier to use multipliers for difficulty in simple games where you're only modifying numbers to achieve the difficulty (eg, hit points, accuracy, ammo, time limit, etc)
Nick




PostPosted: Fri Feb 08, 2008 3:29 pm   Post subject: RE:A Main Menu Problem

Quote:
if that input = "1" then difficulty = "Easy"
elsif input = "2" then difficulty = Hard"
elsif input = "3" then difficulty = "Impossible"
end if

Then where you run your game have an if statement like this

if difficulty = "Easy" then depending on your game something like delay1 = "20"
elsif difficulty = "Hard" then delay1 = "10"
elsif difficulty = "Impossible" then delay1 = 0
end if


is the same as

code:
if input = "1" then
    delay1 = 20
elsif input = "2" then
    delay1 = 10
elsif input = "3" then
    delay1 = 0
end if

%%OR

delay1 := 30 - strint(input)*10
BigBear




PostPosted: Fri Feb 08, 2008 3:34 pm   Post subject: Re: A Main Menu Problem

Yes that is much better coding but what if the input is not right before the main program like if you have to hange it in options then go back to main menu before selecting play.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: