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 / Game GUI with DarkGDK

Author
Message
Bluethunder
15
Years of Service
User Offline
Joined: 12th Aug 2009
Location:
Posted: 2nd Dec 2009 05:33
Hello,
I'm not sure how to go about creating a game GUI with DarkGDK. It doesn't seem like there's any built in funcionality for a gui. I am making an RPG, so the GUI must be fairly complex. Can I do this with DarkGDK, or is it a waste of time?

I was looking into Gtk+ or Gtkmm (One is in C, the other C++?) but I haven't a clue if I can use that in a game. Does anyone know if I can implement those with DarkGDK?
Marsh0
15
Years of Service
User Offline
Joined: 18th Mar 2009
Location:
Posted: 2nd Dec 2009 09:42
It really depends on what you want, you can easily get some nice health bars with boxes. you can load up a fancy GUI with just images. if you are looking for actual buttons then you may have a problem. Though a GUI made of a graphic will look better anyway.

Not to plug my own project but:



The health bars will move down when hurt and the rest of the buttons are just a image. Then you check to see if your mouse is in a certain position and if the mouse button is pressed down. I think you can still get a nice GUI going without any plugins.


So basically, dbLoadImage should be enough
budokaiman
FPSC Tool Maker
15
Years of Service
User Offline
Joined: 24th Jun 2009
Playing: Hard to get
Posted: 2nd Dec 2009 15:48
You can also easily impliment slide bars. For slide bars, check if the mouse is over the image, if the mouse has been clicked. If the mouse button is held, adjust the x position of the image to the x position of the cursor. Then use the x position to create a percentage of what you need.

This signature is legen-wait for it... dary };]
Paynterboi TicTacToe
16
Years of Service
User Offline
Joined: 23rd Dec 2007
Location: That one place
Posted: 2nd Dec 2009 20:06
My favorite method for creating guis is to create images, load them via dbLoadImage use sprite commands to paste them to the screen, replace the cursor with a sprite, and test for collision.

Proud member of: DarkGDK.us
Marsh0
15
Years of Service
User Offline
Joined: 18th Mar 2009
Location:
Posted: 2nd Dec 2009 21:30
Quote: "My favorite method for creating guis is to create images, load them via dbLoadImage use sprite commands to paste them to the screen, replace the cursor with a sprite, and test for collision."


Ok, that is freaken brilliant. So much less time taken then my method.
MACRO
21
Years of Service
User Offline
Joined: 10th Jun 2003
Location:
Posted: 2nd Dec 2009 22:29
Hey,

I am currently working on a flexible GUI framework for my own game use using sprites and OOP techniques to enable easy extension for custom controls.

At the moment its component functionality is lacking because I am working on the underlying management and base classes but once the base and simple controls are production ready I will compile it into a library and think about releasing it on here for anybody that wants to use it.

MACRO
Bluethunder
15
Years of Service
User Offline
Joined: 12th Aug 2009
Location:
Posted: 2nd Dec 2009 23:54
Wow thanks for all the very quick responses!

So basically, I can use regular image loading, and then just test for collision? How would I go about the testing for collision part of that? Would that be dbSpriteCollision?

Also, could someone briefly explain the difference between images and sprites to me?

Thanks a million, everyone!
-Bluethunder
TechLord
21
Years of Service
User Offline
Joined: 19th Dec 2002
Location: TheGameDevStore.com
Posted: 3rd Dec 2009 01:42 Edited at: 6th Dec 2009 06:10
Hi Bluethunder,

I wrote a GUI in DBPro and plan to rewrite it DGDK. When I designed it, I realized that Input Device State and Collision Detection are primary and display is actually secondary. You can use any visual media to display a `Gizmo` whether it be 2D image, 3D Sprites, or even 3D meshes. So for all intense purposes a Gizmo is a Collision Object with a Display Object.

I would encourage you to get the `Event System` (collision object + input device state) worked out before you determine what media will be used to display Gizmos. For example, the `pointer` is the collision object controlled by any input device whether it be a mouse, joystick, keyboard. A Gizmo would be collision object that executes a action dependent on the collision event with the pointer.

Once you figure out how you will detect collision between pointer vs gizmo (or even gizmo vs gizmo), then you can add a timing mechanism and presto!! You have a EVENT System to detect when a:
* Pointer MOVEs
* Pointer ENTERs and HOVERs inside a Gizmo
* Pointer EXITs a Gizmo
* Pointer Button is pressed DOWN and HOLD
* Pointer is DRAG while button is held down
* Pointer ScrollWheel is SCROLLing
* Pointer Button is released UP
* Gizmo is IDLE (no collision)

Collision Detection can be simple or complex. For your typical rectangle collision objects maths can be simple:

If you gonna need 3D collision, you can use a simple distance formula more complex 3D maths. You don't see much about 3D GUIs but I have written one and they are really cool.

So, I would expect you to want to create different type of gizmos for buttons, scrollbars, checkboxes etc, however, between you and me, a button is a behavior of a Gizmo. Behavior is determined by the Events. What if you could assign a Gizmo any behavior? That's what I did with my GUI. In fact Scrollbars and Dropdown boxes were composite Gizmos each with different behaviors.

Most folks go into the GUI making process based on the typical Windows GUI. But GUIs for Games are different. They are usually more animated and can use the same resources that other game entities use.

How you code what a Gizmo does during a Event is even more fun. I implemented a Scripting Engine to use scripts, but, some folks hard code the actions.

I could blab on this for hours. Most of this may not be relevant for your needs but I hope I given you some other possibilities to consider.

Paynterboi TicTacToe
16
Years of Service
User Offline
Joined: 23rd Dec 2007
Location: That one place
Posted: 3rd Dec 2009 15:49 Edited at: 3rd Dec 2009 15:52
I didn't feel like reading the posts os if your question was answered already sorry... tyr code like this...



Now, one issue I ran into was that if your cursor is collideing with 2 different sprites ( or more ) it will perform all the actions. To fix this, I made a image of 1x1 pixel that was the same color as the topleft pixel of my custom cursor and pasted it at the same x/y as the mouse and tested collision for that instead of the bigger cursor.

Sorry wrote this in like 2 minutes right into the forum will answer any questions you have.

Proud member of: DarkGDK.us
Bluethunder
15
Years of Service
User Offline
Joined: 12th Aug 2009
Location:
Posted: 5th Dec 2009 06:05
Hmm thank you all for the responses.

Firstly, how do I replace the mouse with a sprite?
Second, all of the mentioned seem to be mostly like buttons and such. How would I make a mini window though? I do see what you all mean by the buttons though.

Lastly, does anyone know about Glade? Or Gtk+ / gtkmm, for that matter?
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 5th Dec 2009 09:00
Quote: "how do i replace the mouse with a sprite?"


in the main loop, position the sprite on the mouse location:



Paynterboi TicTacToe
16
Years of Service
User Offline
Joined: 23rd Dec 2007
Location: That one place
Posted: 7th Dec 2009 20:48
If you read the code sample I provided it shows you how to replace the mouse.

First, hide the windows cursor:


Second, as hassan said, paste the sprite of the custom cursor at the mouse x and y positions, In my code I used variales to store the positions but hassan's method works just as well:


OR:



Quote: " How would I make a mini window though?"


This is a very difficult task to perform, it requires Knowledge of windows API and maybe even MDI. Mista has a great thread explaining how to do this but be aware it is an advanced topic ( will add a link later ).

Quote: "Lastly, does anyone know about Glade? Or Gtk+ / gtkmm, for that matter? "


Sorry, none of that is familliar to me but I assume they are GUI plugins of some sort? at any rate, you have all the nessisary tools needed to make your game with GDK. If you give specific examples of what you are trying to achieve we may be able to help you develope your own methods for creating your gui.

Proud member of: DarkGDK.us
Bluethunder
15
Years of Service
User Offline
Joined: 12th Aug 2009
Location:
Posted: 9th Dec 2009 05:16
Thanks so much for all your help! I have created some basic testing images for sprites. The one question I would like to ask at this point though, is how to test for collision with an object that has transparency? Say I have a circular button, for example.. How do I test for if the mouse is in the circle part of it, as opposed to the transparent part of the square image?

Thanks,
Bluethunder
George_W
16
Years of Service
User Offline
Joined: 21st Jun 2008
Location: USA - California.
Posted: 10th Dec 2009 20:13
Checking if the mouse is with in a buttons Rect is pretty simple. you dont need SpriteCollision nor anything like that. All you have to check are 4 points agains your X and Y Coordinates, the Boxes Top, Left, Right, Bottom. I use this type of boundry detecton with in many of the projects I have done.

This is how it works:


For the Circle, you would like to Find the Circumference which is (Pi*Diameter). Its kind of complicated(at least for me it is at the moment).

My Advise is to stick to Rectangular Figures or just check the Circles Rect instead of a Circle if you know what i mean. Its pretty complicated. So yeah.

You can also make some nice Buttons and windows with just Boxes, I have made some Functions for that. Its pretty simple.



Pretty Simple. You can more or less functionality to this.

Hope this was of help and if not. then I am sorry =]

Have a nice day!

If you want something, You'll find a way; If you don't, you'll find an excuse.

Education is a comitment.
NosGenerated
14
Years of Service
User Offline
Joined: 11th Dec 2009
Location:
Posted: 11th Dec 2009 21:25
Well Geometry is an amazing thing.
There is the easy way, and the one that consumes the least CPU or the way which will be exact to the last pixel.
The easy way is as George_W says, test for the square area inside the circle. This is probably the most advisable method (especially if it is a tiny circle); however if you must be exact.

if x is the width of your sprite and y is it's length and s is it's number or id and r is the radius of the circle;
dbOffsetSprite(s,.5x,.5y);
float xval=(dbMouseX()-dbSpriteX(s));
float yval=(dbMouseY()-dbSpriteY(s));
if(sqrt((xval8xval)+(yval*yval))<=r)
{
//do stuff
}

The above is indeed the distance formula and the reason why it will use more cpu is because the sqrt function is really not very pretty.
Paynterboi TicTacToe
16
Years of Service
User Offline
Joined: 23rd Dec 2007
Location: That one place
Posted: 12th Dec 2009 03:30
Just for the record using collision works with transparent objects, I cannot guarantee how much cpu it uses but it is the least amount of code and exact to the pixel if you use my method of creating a cursor ( early post )

Proud member of: DarkGDK.us
Bluethunder
15
Years of Service
User Offline
Joined: 12th Aug 2009
Location:
Posted: 14th Dec 2009 05:25
Ok thanks so much for all the help so far. I'll search around for this answer, and see if I can find it... but I haven't yet...

Why is it when I call dbSetDisplayMode(1600,900,32) on my computer which is running in 1600x900 with 32 bit color, cause the program to run, but not display any of the 3D objects? When I run the game, it becomes fullscreen and 1600x900, but none of the 3D objects display, and only the text appears. (I don't remember if the 2D images display)....
Bluethunder
15
Years of Service
User Offline
Joined: 12th Aug 2009
Location:
Posted: 18th Dec 2009 05:43
Anyone have answers on the previous?

Also, should I use dbText to put text in those windows? How can I put integers into dbText, by the way? Let's say I wanted to print the Frames Per second of the game.. how would I do that?
RanQor
17
Years of Service
User Offline
Joined: 8th Jun 2007
Location:
Posted: 18th Dec 2009 20:22
I'm just curious, has anyone successfully tried implementing a QT gui?
http://qt.nokia.com/products
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 18th Dec 2009 21:08 Edited at: 18th Dec 2009 21:08
@Paynterboi TicTacToe
Quote: "Just for the record using collision works with transparent objects"


Just for the record... No it doesn't. DGDK doesn't support pixel perfect sprite collision, it simply checks if the sprite rectangles collide.

Paynterboi TicTacToe
16
Years of Service
User Offline
Joined: 23rd Dec 2007
Location: That one place
Posted: 23rd Dec 2009 05:28
Sorry, you need to get an image of a circle Not an image of a circle inside a rectangle with transparent edges. It takes quite a bit more effort to make the image but taking that with the image of 1 pixel it will work. If you don't want to go through the effort than just use the 2d maths it's up to preference.

Proud member of: DarkGDK.us

Login to post a reply

Server time is: 2024-10-01 20:15:00
Your offset time is: 2024-10-01 20:15:00