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.

Newcomers DBPro Corner / Game menu screen

Author
Message
Unijaw
12
Years of Service
User Offline
Joined: 7th Dec 2011
Location:
Posted: 7th Dec 2011 22:44
Hello I have made a quick menu by using the Darkprinciples tutorial 9 on youtube and have come up with the following code. Although the menu functions well I want to be able to use the menu at any time during the program by pressing the Escape key and i do not know how to do this as I am brand new to darkbasic.
Furthermore It appears I have used a silly method of menu creation using sprites for rollover buttons seem to be much more appropriate but I am unaware of how to do this and I would settle for what I have currently. Thank you for reading


-James
Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 8th Dec 2011 00:58
I remember tackling this problem the first time, it's a tricky one!

I found that once I discovered and learnt about timer based movement, I could literally control time in my program.

Take an RTS with tanks moving around. The speed of those tanks is running off of calculations which are using an output from the Timer_Based_Movement() function mixed with a Tank_Movement() function.

One way to stop all the tanks, in effect pausing your game, is to add flexibility to your TBM() & Tank movement function so that they can handle independent pausing, whilst other things can continue to move.

This way, you hit spacebar to Pause, all the tanks stop, yet you can still move a mouse cursor over a 3D button that continues to spin whilst the rest of your game is paused.

As I said, Timer Based Movement is hard at first, but you'll understand it so long as you start to experiment with it.

Here's how I implement TBM in all my games;

Create a new darkBASIC source file, and call it Timer Based Movement.DBA, and place it in a common directory, so that other projects can use the code, saving you from rewriting it for each project.

Paste this code into it; most of it was originally written by others on these forums, I've done a little work to it, but nothing major.



Now in your main source DBA file, before the main game loop, write;

Gosub Sub_Ini_TBM

and then from within the main game loop, write;

TBM_Update()

Now, test out some simple movement calculation, simply by tacking on the "Factor#" to the movement equation. For example, I've been coding a game of cards, but to make it interesting I've been coding it all in 3D. So to spin some cards over when the user clicks on a card, I use the following;

YRotate Object 1, wrapvalue(object angle Y(1) + (0.5 * Factor_360#) )

If I didn't have the (0.5 * Factor_360#)) in my code, the cards would either spin really slow on an old computer, or super quick on a fast computer, depending on the system frame rate.

But with TBM, not only is it useful for understanding how to pause things, but you can also make sure your game runs the same speed on all computers, no matter what the frame rate is.

Might be a little off topic, but TBM is great, really interesting stuff. If you can get your head around TBM, it will hopefully guide you on how to pause your game, without pausing your game!

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Unijaw
12
Years of Service
User Offline
Joined: 7th Dec 2011
Location:
Posted: 11th Dec 2011 14:54
Thanks for the response but its not something I can really use.

-James
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 11th Dec 2011 19:25 Edited at: 12th Dec 2011 18:51
Try this:

Write a simple menu function that allows you to more or less control the options, header, etc. Do this in a singly function,eg



If you need me to elaborate, I'll try to dig up some old code tomorrow. Hopefully this will help, or at least something to look at, for the mean time.

EDIT: As promised I dug up some old code... But it was filled with dependencies on other things in my program. So I wrote you a very BASIC example. This should give you the gist of it. You can elaborate on this, expand it, whatever. Anyway, here is teh codez:



Login to post a reply

Server time is: 2024-11-23 23:16:22
Your offset time is: 2024-11-23 23:16:22