Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Roger Hill

GUI questions about turn based strategy game

This topic is 6920 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I am an experienced programmer starting to work with Windows/DirectX for the first time. I want to try my hand at a turn based strategy game, as this seems to be a simple first step into game development. My question is: what is the best way of creating a GUI for a TBS game? I could treat the whole screen as one big window, and place the ''data windows'', (containing your money, score, resource points, whatever) as sprites, taking advantage of the Z-order feature in DX7. Of course, then whenever you click somewhere, you would have to determine where on the screen the mouse was. Alternately, I could create child windows for each sub-screen. Then they have to be arranged, and updated individually, but it''s simple to have a separate message loop for each child window. Is there some simple method I''m missing? Or, perhaps some slick trick that makes things easy? Roger

Share this post


Link to post
Share on other sites
Advertisement
First of all, if this is your first game (even if you are an experienced programmer) I would suggest trying your hand at a Tetris clone (or something similar like Pong, Breakout, whatever.) This will really help you to get used to handling the Windows/Direct X stuff without haveing to worry about any complex game mechanics. (Check out the article on this site, "A Path to Game Development" or something like that, its a wonderful article.)

At any rate, if you are intent on tackling a TBS game right of the bat then I would have to say that either method should work fine. Are you planning on making the game fullscreen or windowed? (MFC or no?) A little more info would make it easier to figure our the pros and cons of each approach.

Check out the GPI project today!

Share this post


Link to post
Share on other sites
When the mouse button is clicked, grab its coordinates. Then loop from topmost window/sprite (windows from here on) to bottommost window. For each window, if the mouse coordinates are inside the window''s bounding box, you clicked on that window.

If you need window hierarchies (eg. a FormWindow can contain its own ButtonWindows, etc) then you simply repeat the process for that window''s children.

Repeat until you either looped through all the topmost windows and didn''t find one that the mouse was inside (result: nothing was clicked upon), or you looped through all of a window''s children and didn''t find one the mouse was inside (result: you clicked on that window itself, rather than its children) or you reach a window that has no children (you clicked on that window).

Is that what you wanted?

Some sample pseudo-code for anyone who might need it...

// Abstract class defining the interface
class WindowContainer
{
WindowList child_windows;
void AddWindow();
void RemoveWindow();
// any other functions for manipulating them
};

class GUI : public WindowContainer
{
// Only 1 GUI per app/monitor/whatever suits you
};

class Window : public WindowContainer
{
Rectangle GetBoundingBox() const;
// Basic window functions
}

class ButtonWindow : public Window
{
// Button stuff
};

class CaptionWindow : public Window
{
// Caption stuff
};

etc etc etc...

Share this post


Link to post
Share on other sites
In reply to both posts:

I am thinking about using MFC''s, as I like their elegance. I haven''t seen a lot of DX7 API manuals for MFCs, though. I know they exist, because I have seen code examples that use DX7 & MFCs.

The suggestion of looping through all the sprites is an interesting one. It just might be what I was looking for. I''ll have to think about in context, though. The game will be initially be full-screen, though when everything is running smoothly, I''m thinking about allowing the user to switch modes. (WAAAAAY down the line...)

Actually, I find the direct draw stuff kind of simple. Getting windows to do what I want is the hard part. I mean, where do you learn about all the platform function calls, fer crist sake? (I know, VC++ helpfiles...there''s just so many of em.)

What I was fishing for is suggestions as to which would be simpler, cleaner, and any odd lessons learned the hard way.
The thought of multiple child windows leaves me cold, but maybe there''s some benifit I''m overlooking.

Share this post


Link to post
Share on other sites
You don''t want to do that. Try Pong, Space Invaders, Frogger, Breakout, etc. first. Start small or you will quit in a week, I promise.

Note, don''t call your games Pong, Space Invaders, Frogger, or Breakout... Hasbro will probably sue you.

Share this post


Link to post
Share on other sites
Ha HA!

KA-ZING! Buster 1, Hasbro 0.

Actually, I''ve already been working on the project for about 6 months. I''m in mid-process of developing a C++ virtual engine, that will power the GUI. it''s already taking up about 95 header files, and growing daily. As I said, I''m an experienced programmer.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!