PDA

View Full Version : Single form



jamesa
21-02-2005, 04:09 PM
Hello,

What is the best technique to create an application (game) that use only a single form?

I dont like to have a lot of popup window.

For example, I have 3 screen layouts :
- Menu
- Game Play
- Options

The easiest way is to create "MainForm" for the Menu screen, and 2 other forms for the Game Play and the Options screen.

What I want to achieve is, for those 3 screens, I use only one form.

I tought that I will use PageControl component, and each screen will be created in the "page". This will work well, because I virtually can hide screens (pages), and display it using PageControl.TabIndex := X.

But, I cant REMOVE the "Tabbed" control :( .

Then I came up with idea to use Frame. But it is hard to manage, because I must put all frames (screens) into that single form, and control the display by using .visible property.

So, what can you suggest?

Thanks

Crisp_N_Dry
21-02-2005, 04:54 PM
Well what you suggested with the pagecontrol would work but that is aimed at applications rather than games. For games it is better to have a single form (well ideally it would be fullscreen but if you are using a window then a signle form will do) with an image based object such as a TImage (or even the forms canvas) to display the game. Then your game code would determine which state of the game to display i.e MainGame, Menu, Options, GameOver, etc. Then when the logic has decided which state it wishes to display, it would go run the code for that specific state and draw this to the screen/window/timage. But most games use DirectX or OpenGl for fast drawing of the graphics, even if it's a 2D game you're still gonna need a bit of speed and the Windows graphics API's are notoriously slow. If you are new to this then I would recommend DelphiX (A DirectDraw interface). It's not as fast as it's competitors but easy to pick up and there's plenty of examples about on how to get it up and running.

EDIT: Oh and welcome to PGD, you will find muchos help on these boards. Check out the #PGD channel on IRC at
irc.freenode.net: 6667

Incubii
22-02-2005, 02:35 AM
hmm i think what he was after was an MDI form that has MDI children.