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.

Code Snippets / Start of a menu, like Final Fantasy

Author
Message
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 15th Oct 2002 05:33
Hey, I have made the very start of a menu. It is like any game that has a menu, a great example is final fantasy. I made this with Dark Basic, so it should work with Dark Basic right? Tell me what you think of it, is it a good start?



Did that work? Hope so,,,, If anyone could tell me how I could make it so if you clicked on one of the words like Items it would make a new screen come up. Or if you could tell me how to select the menu items using the up and down arrows that would be great also, any way that I could navigate this menu I made.
Well just put it in and see if you like it! Tell me here!
Thanks
RPGgamer
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 15th Oct 2002 05:40
Oh ya, one more question. I have my character on a map, how would I make it so if I pressed, M for example, my menu would come up? Wouldn't it be something like

IF (something) Then cls

And then put the menu code in? If anyone could please tell me that would be great (sort of useless having a menu if you cant access it!)
Thanks in advance,
RPGgamer

Final Fantasy, best series ever made.

Mirthin
21
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Land of the Rising Haggis
Posted: 15th Oct 2002 14:57
Nice layout, I understand your final fantasy inspiration. A little more work and you're there. It's quite simple to have a 'hyperlink.'



So, you can take this code, have a look and draw your own conclusions, hope it helps.
Mirthin
21
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Land of the Rising Haggis
Posted: 15th Oct 2002 14:58
Discount the top line, I grabbed that too by mistake.
ChipOne
21
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Canada
Posted: 15th Oct 2002 19:23
couple of things here...I understand from your posts that you're fairly new to games programming, so if you'd like to chat some, email me at mickeymows at hot mail dot com and we'll chat about game development.

first off, you should put your menu code in a function. that function should be called from your game loop when the menu is activated.

secondly, you'll need to decide where you'd like to have your keyboard handler, or if you need multiple ones, etc. you can use the inkey$() command to test for "m". when (inkey$() = "m") then you can set a flag to one (i.e. MagicMenuDisplayed = 1). in your menu function, you check the relevant flags (InventoryMenuDisplayed, MagicMenuDisplayed, etc.) and draw the proper menu.

The other (probably better) way to do this is to have a list of constants:
#constant MAIN_MENU 1
#constant MAGIC_MENU 2
#constant INVENTORY_MENU 3
etc...

and then to use a SELECT statement to figure out which menu is currently drawn. using the CASE statements, you call a function (have a function for each menu). this will keep your code very clean and modular.

any questions, just post here. if you want to email me, feel free.

cheers

-= i only do what my rice krispies tell me to do =-
ChipOne
21
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Canada
Posted: 15th Oct 2002 21:00
here's a base for you to work from. i just spent about 1/2 hour on it, so it's nothing too extravagent, but it might give you some ideas about how to handle things. as usual, i'm open to questions...



good luck in your game dev, RC.

-= i only do what my rice krispies tell me to do =-
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 15th Oct 2002 23:52
WOW! Lots of replies! Thanks everyone! I will try out what you have sent me for code (thank you SOOOO much) and Ill post here if I get it to work. When I finish this (finally) I'll post my results here!
Thanks again everyone,
RPGgamer

Final Fantasy, best series ever made.

John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 16th Oct 2002 01:23
OK I have put in all this code and got great results! I still do have a couple questions though, if anyone would answer I would be truely grateful. I put in Mirthins example then I pasted my menu code in and made it so the text read "Items", and put that were my usual word items was. Then, when I clicked on it a new screen loaded. The only problem is as soon as I let go of the mouse the screen went back to my original. Does anyone know how to change it so if I clicked on the word it would stay on the page? Thanks. Also, ChipOne, do you use DPpro? I am using Dark Basic. When I tried to load your code it came up with an error for your #constant lines. How would I fix this?
Thanks in advance everyone, you've all been such a huge help...
RPGgamer

Final Fantasy, best series ever made

ChipOne
21
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Canada
Posted: 16th Oct 2002 02:43
dude...the enter key is your friend (ours too when we try to read your posts )

yes I'm using DBPro. Out of curiosity, why did you go with DB over DBPro?

My code won't run under DB as I'm using globals and constants.

I'll maybe have a look at it later and see if there's a DB translation of my code, but you should consider DBPro and at least download the demo.

Okay, just to be frank here, there isn't necessarily a problem with the code, but how you're tackling the problem. You need to understand the concept of states and start using flags. You'll also need to develop a game loop (which I'm assuming you understand).

Another good thing to learn is to break down your problems into smaller pieces. At this point you don't know the language, you haven't experience with programming principles and you don't have a game design. These are three things that are going to work against you as hard as you are trying to learn. Until you see those three elements as seperate learning blocks, you're going to have a hard time advancing.

That said, here are some basic ideas you can work off of to learn the 'programming priciples' side of the problem:
1) a flag is your friend. it is used to control state and effectively allow your software to decide what course of action to take at any given time. turn it on when you want certain behaviour to occur. turn it off when you're done.

2) smaller is better. break each element of the game into smaller pieces and into seperate functions. this will keep your code maintainable. don't ever use the excuse that 'I'm the only one using it' because you'll get into habits that won't work for you.

3) walk first. trip. try walking again. once you've mastered that, you'll trip again. figure out how not to hurt yourself when tripping. then walk again. get insurance. THEN try running. In other words, try to master one concept at a time and not ALL concepts at one time. there are several things you'll want to get the hang of:
a) effective code seperation - keeping related code together through the use of functions
b) determining requirements and designing solutions - you'll nee to identify the ACTUAL problems, not the glossed-over version
--- Not good: I want to build a menu
--- Better: I'll need to interrupt my main loop by setting a menu flag to true when a certain key is pressed. I'll keep drawing my menu until the flag is false. During the menu draw sequence, I'll copy an image to the screen, overlay the required text and then watch for keyboard input to control the menu from there. When the user presses a certain key, I'll set the menu flag back to false and return to the game loop.

4) think big, stay relevant. keep your tasks small, but make sure they are focused and in line with the greater good of your game. if you write this brilliant function to display your menu, make sure it fits with the other concepts in your game (as in, do you want your game advancing while a menu is displayed, or does the menu interupt the game?)

Not trying to be hard on you, RPGgamer, just trying to make sure you're heading down the right path. It takes a while to figure this stuff out and there are a lot of concepts to master. Just take it slow and make sure you understand why you are doing the things that you are!

cheers!

-= i only do what my rice krispies tell me to do =-
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 16th Oct 2002 03:30
Thanks, I'll take your steps one at a time and maybe someday ill be good at this
Thanks
RPGgamer

Final Fantasy, best series ever made.
ChipOne
21
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Canada
Posted: 16th Oct 2002 21:19
BTW: the reason I posted a solution in DBPro was because you are in a DBPro forum.

-= i only do what my rice krispies tell me to do =-
Kale
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: United Kingdom
Posted: 16th Oct 2002 23:53
If i remember correctly there was a finalfantasy type clone entirely coded in DarkBasic 1.3, which had a menu system almost identical to FF. infact the project was discontinued and the source for the menu was made public, it was exremely professional looking. I downloaded it and tried it out, very cool! i am trying to remember where from though!

What the flame does not consume, consumes the flame.
----------------------------------------------------------------------
AMD XP2100+, Geforce4Ti 4400, 512Mb DDR, Abit KX7, WinXP Pro
Kale
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: United Kingdom
Posted: 17th Oct 2002 00:11
i found this with a quick search:

http://www.darkbasic.com/c.php?f=dbarchivecd1

theres mention of a 'Graphical RPG Menu System'

What the flame does not consume, consumes the flame.
----------------------------------------------------------------------
AMD XP2100+, Geforce4Ti 4400, 512Mb DDR, Abit KX7, WinXP Pro
Kale
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: United Kingdom
Posted: 17th Oct 2002 00:26
FOUND IT!!!

see http://www.mojomagic.co.uk/equilib.html

see this menu tutorial too: http://www.mojomagic.co.uk/documents/menu.zip



What the flame does not consume, consumes the flame.
----------------------------------------------------------------------
AMD XP2100+, Geforce4Ti 4400, 512Mb DDR, Abit KX7, WinXP Pro
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 18th Oct 2002 01:44
Hey everyone, I have ALMOST finished my menu, its great (In my humble opinion ) Ill post the excessivly long code when Im done. My edited versions will be much shorter, more usage of the gosub command, so great
Back when Im done (later today)
RPGgamer

Final Fantasy, best series ever made.
ChipOne
21
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Canada
Posted: 18th Oct 2002 02:38
nooooo! hehehe...stay away from gosub if you can. functions are the way to go...you can pass parameters and get return values, infinately more powerful.

also...you didn't respond to my question as to why you took DB over DBPro?

-= i only do what my rice krispies tell me to do =-
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 18th Oct 2002 04:52
Well, I have finished my menu with gosubs, and I guess later when I learn more I will change it around.

When I bought DarkBASIC, DarkBASIC Pro. wasn't out yet. I also had the demo for DarkBASIC and I thought PRO. was a completley different set of commands. Is it? I didnt want to go through learning a whole new set of commands at the time. If they are basicly the same with commands, I will probably get Pro.

When I get better at programming I will venture away from gosubs, but as of now it was the only light at the end of the tunnel in my journey to complete my menu.

Thanks-
RPGgamer

Final Fantasy, best series ever made.
Mirthin
21
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Land of the Rising Haggis
Posted: 18th Oct 2002 16:06
What's wrong with gosubs? Want a monkey knife fight to settle it?
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 18th Oct 2002 23:45
Lol ya! Gosubs saved me in my process of making a menu! They are so great! Im just a beginner so I may not see certain things, but they work fine for me!
RPGgamer

Final Fantasy, best series ever made.
Mirthin
21
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Land of the Rising Haggis
Posted: 19th Oct 2002 01:05
I was only joking. Unfortunately, monkeys are under protection in Scotland.
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 19th Oct 2002 01:11
Lol I was JK too!

Final Fantasy, best series ever made.
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 21st Oct 2002 01:42
i thought monkeys were under the protections of LucasArts
even have thier own island ... hehee

RPG you'll want to veiw some code i release tommorrow, it'll definatly help you with setting up menu graphics and such

Anata aru kowagaru no watashi!
TheCyborg
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 21st Oct 2002 14:22
Try using Functions instead of GoSubs. Then you will be able to parse settings into them.

"It's good to be bad..."
Dungeon Keeper
The One Ring
21
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 23rd Oct 2002 16:47
There is nothing wrong with GOSUB or GOTO. When its compiled to machine code, its ALL converted to jumps and compare statements...

DB:
IF test = 1 THEN GOTO testLabel

ASM:
MOV AX,1
CMP AX,1
JE testLabel:

Its all a matter of style... (yes, functions and OOP concepts offer more style... they have since the 70s)

AMD Athlon 900 768MB DDR
ATI Radeon 64MB DDR All-In-Wonder 7500, ATI XPert 128 16MB
Sound Blaster Audigy Gamer w/FireWire Support
ChipOne
21
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Canada
Posted: 23rd Oct 2002 21:28
It's not just a matter of style, it is also a matter of functionality, for the reasons i've already mentioned:
1) you can pass parameters
2) you can have return values

furthermore, it is far more readable to do things like:
if ObjectOutOfBounds(CurrentObjectNumber, LevelNumber)
` do my code here
endif


instead of a mess of global variables mashed together with gosubs and labels.

i haven't ever said that gosub or goto is worse to use. if you want to sacrifice the extra functionality of functions, that would your (arguably, silly) choice to make.

-= i only do what my rice krispies tell me to do =-
The One Ring
21
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 24th Oct 2002 06:02
Oh, I agree. Functions offer the greatest readability and structure... much more than global vars and gosubs... just replying for the sake of basic argument

AMD Athlon 900 768MB DDR
ATI Radeon 64MB DDR All-In-Wonder 7500, ATI XPert 128 16MB
Sound Blaster Audigy Gamer w/FireWire Support

Login to post a reply

Server time is: 2024-03-29 13:41:03
Your offset time is: 2024-03-29 13:41:03