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.

DarkBASIC Professional Discussion / Sprite based game menus

Author
Message
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 11th May 2010 03:55 Edited at: 11th May 2010 04:19
Something I am going to need for my R/C flight sim is some sort of in game menu system. I had an idea, using a single image to store multiple instances of the buttons in different states : Normal, mouse hover, and mouse click. I know about animated sprites and frames, but, that will make just one sprite, and you just pick which frame you want. I could also make lots of little images, but that gets hard to manage. So, this is what I came up with, and it works pretty well. Still need to work more on the what happens when you click onit, but, I think the basic method is sound. This creates menu buttons and places them vertically wereever you want them, and spaces them however you want then, and responds to mouse over and mouse click.
Attatched file has project and .exe
Let me know if I'm going in the right direction?

screenshots:

Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 11th May 2010 08:54 Edited at: 11th May 2010 08:58
Something I have learned. In the menu_events() function, I can launch an external program, and, at the almost same time, close the menu program. Something else. You can pass a commandline string to the executable you want to launch. Inside that executable, you can compare the value passed in. If it matches, run the program, if it doesn't, just end the program. So, this is some awesome news to me. It means I can write the program with multiple executables you CANNOT launch unless you know the command line to the exe. I don't know how secure this is, and, at the moment, I don't really care, because I'm more interested in making the program MODULAR. If I have a menu of mini games, instead of writing them all into one .exe, I can make multiple .exe's and launch them from the menu program. I just kill the menu program when the player selects the game they want to play. And, of course, when the player quits the minigame, via a menu, I can just relaunch the menu program.
I got it figured out.
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 11th May 2010 09:07 Edited at: 11th May 2010 09:27
to test my theory, here is my latest .exe on my R/C flight sim. If you can launch it (you can't, because I haven't included any media), you should get an error, missing file or something. If you can't launch it, it will start to load, and just quit.
If you can crack it, tell me what my command line parameter is, and how you figured that out.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 11th May 2010 15:49
So I would suggest using:

...to run your executable.

Then use:
Quote: "
CL$
This command will return the string passed in as a command line when the program is run as a standalone executable.

Syntax

Return String=CL$()

Returns

The return value is a string.

Description

When this program is created as an executable file, any additional parameters entered after the executable name are treated as a single command line string. You can use this string to control how your executable behaves based on the contents of the string.
"


To retrieve the data passed as "commandline"...

I haven't tried it but about thirty seconds looking in the help files and in the search bar sure helped!



Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th May 2010 16:31
One really handy feature of sprites is the ability to adjust the UV coordinates, I use this all the time for animated sprites and stuff like that. Usually I use a grid, so I might have 4 of the same button (standard, mouse over, clicked, disabled) on a 2x2 grid - then after making the sprite I resize it and UV map it to suit. It's quite quick to change UV coords as well.

Saves having lots of images loaded, but the main benefit for me is in bitmap fonts, having a whole font set in a single image is great, it can quickly and easily be replaced, I just sprite, resize, then UV map so the appropriate character is shown.


Health, Ammo, and bacon and eggs!
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 11th May 2010 20:48
@baxslash
maybe I wasn't clear enough. This is what I am already doing. The menu exe already uses execute file, and at the very top of rcsim.exe, it uses CL$() to see if the commandline is there, and if it is correct. What I want to know is, is there a way someone can see inside the .exe and discover what the commanline is.
But thanks for the tip on the search bar and the help files, I never knew about those

@Van B,
Thats how I'm doing the menus, just manipulating the UVs and dicing up an image. Except I didn't make a disabled, I just left the fourth slot blank (so I don't have to use .33, .66, etc.)
Now, if I can only get good at making cool looking sprites
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 11th May 2010 22:23
It's easy. Create another exe to replace rsim.exe which takes CL$ and prints it on screen. Then when your menu file executes the main exe, you'll get it's command line. You might be better using the registry, or the clipboard.

My signature is NOT a moderator plaything! Stop changing it!
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 11th May 2010 22:57
heheh, sometimes the answer is right under your nose. Thanks Mobiius. That rules out command line for security. I'll have to do something else, like you suggest. I just want to make it so you have to go thru the menus to launch the other .exe's. I'll look into your suggestions.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 12th May 2010 11:04
Looks like I misunderstood your problem, sorry.

@Mobiius, I would have thought that using the clipboard would be just as easy (if not easier) to check? The registry would be a better option but still not un-hackable.

Personally I'd take it as a huge compliment if someone wanted to hack my software!

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 12th May 2010 14:03
Indeed, nothing is unhackable. Suppose you could encrypt the commandline, then decrypt it at runtime.

My signature is NOT a moderator plaything! Stop changing it!

Login to post a reply

Server time is: 2026-07-26 04:28:08
Your offset time is: 2026-07-26 04:28:08