Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Help making menu

Author
Message
gcarlson53
14
Years of Service
User Offline
Joined: 15th Feb 2010
Location: Suitland, MD
Posted: 17th Feb 2010 03:29
Just to let you know I am a beginner. A super beginner. Haha. Well I'm trying to make a keyboard controlled menu for a game and I can't get it to work right so if anyone could help me out that would be awesome. This is what I have so far...


When you first start the game the arrow, or cursor, will be pointing at 'Start' and if you press the right arrow key, the cursor should point to 'Quit' and if you press the right arrow key it should go back to 'Start' and you should be able to keep going back and forth until you press the enter key.

Check out the first game I made with C++. It's just a simple text based fighting game for now.

http://www.filesend.net/download.php?f=e5e59cad87d18b383262f4917b1714f4
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 17th Feb 2010 06:32
Put a dbSync() in your do-while loop.

Success = Determination * Mood;
gcarlson53
14
Years of Service
User Offline
Joined: 15th Feb 2010
Location: Suitland, MD
Posted: 17th Feb 2010 07:07
That somewhat made it better. Now it starts off with a blue screen and if I hit the Enter key the menu background flashes and then it goes back to blue. If I hit the left key the cursor flashes on the left and the same thing happens for the right key. Why doesn't my background appear when the program starts? and how do I get my cursor to stay there instead of only appearing when you hold down the arrow key?

Check out the first game I made with C++. It's just a simple text based fighting game for now.

http://www.filesend.net/download.php?f=e5e59cad87d18b383262f4917b1714f4
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 17th Feb 2010 14:35 Edited at: 17th Feb 2010 14:40
Quote: "Why doesn't my background appear when the program starts?"


Because you don't display it inside the "while" loop. If a picture is displayed with dbPasteImage, then you need to paste it every loop, otherwise the next dbSync will make it disappear.

Quote: "how do I get my cursor to stay there instead of only appearing when you hold down the arrow key?"


Same as above, in this code you don't display the cursor if no key is pressed.

There is also another problem with this program. The code which displays your "title screen" and choices is inside the Dark GDK main loop. That means that after you have made the choice, this part will be executed again and again - well, unless you make other infinite "while" loops in your "play game" and "quit game" sections but that is not a very good design. This can be solved in two ways, either you put the title screen display before the main loop, or you introduce a "game state" variable and make a switch statement on it, to make sure that you execute only that code which is relevant to the current game state. See the Dark Invaders tutorial on how that is done.

The example below shows a code which executes the "title screen" and choice before the main loop. You can see that I used dbSprite to set the position of the pictures instead of dbPasteSprite and I made also the title screen a sprite. The advantage is that you don't need to paste them on the screen in every loop because a sprite defined with dbSprite will stay automatically on the screen and it is not erased by dbSync.

After the choice is done, the sprites and images are erased and you can start the Dark GDK loop, from which you can quit by pressing the ESC key. The "press ESC to exit" text that I put into the main loop is only for testing.

Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 17th Feb 2010 14:46
P.S. If you want to do it with paste instead of dbSprite, it is possible also but a bit more complicated:

gcarlson53
14
Years of Service
User Offline
Joined: 15th Feb 2010
Location: Suitland, MD
Posted: 17th Feb 2010 21:11
Thank you very much! This helps me out a lot.

[url="http://egregiousgames.blogspot.com"]My blog![/url]
[url="http://www.filesend.net/download.php?f=e5e59cad87d18b383262f4917b1714f4"]My Game![/url]

Login to post a reply

Server time is: 2024-11-20 03:28:52
Your offset time is: 2024-11-20 03:28:52