PDA

View Full Version : DelphiX Game (Delphi 6) - Intro Screen



Wizard
13-12-2006, 11:31 AM
Hi, me again (My game looks very nice and I've sorted out most of the bugs...it's a starfighter game)

I would like to add an intro (bitmap) and when the app starts it should 1st show the bitmap and when the user enteres a key the app should run.

Does anyone have examples/code/suggestions?

Thank you.

jasonf
13-12-2006, 01:23 PM
Does your game use a State system for the main game loop?

Although I don't use DelphiX for my game, I display a splash screen while my game resources are being loaded, before my main game loop is reached.

If you have a state system then you should be able to do this easily.




While not quitting
Begin

Case GameState of
Intro:
Blit into image to screen canvas.
Do Into specific input checks - Change GameState to MainMenu when key pressed

MainMenu:
Do main menu stuff
Do Menu specific input checks - Change GameState to InGame when new game is pressed, or Quitting when Quit is pressed.
InGame:
Do Game stuff
Do game specific input checks - Change GameState to MainMenu when killed or Esc pressed.
Quitting:
Render Quitting image

set Quitting Flag to True
end

Do Generic input checks
Flip surfaces.

end


Hope this makes sense.

My state machine is similar, but a bit more complicated, it uses LastState, NewState and CurrentState sections. It gives me a lot of flexibility.

Hope this helps..

P.S. you might want to put this sort of post in the DelphiX section in future, although this request appears to be for a generic answer... unless you're after DelphiX code.. but seriously, this is so noddy, it won't take you long to implement.

NecroDOME
13-12-2006, 03:54 PM
What I do: Start main loop, Render a loading screen image to the screen, load resources, This could take a while so the engine is unable to render as it is loading and after this you just render you thing to the screen (menu, game, etc)

...State machine would be better...

Wizard
14-12-2006, 05:09 AM
Thanks guys, I got it to work the way I wanted to :-)

Here's the code for a 1024*768 bitmap to be displayed when the app starts if anyone else needs it :)



procedure TForm1.Splash;
begin
DXSpriteEngine1.Engine.Moved := False;
with TSplash.Create(DXSpriteEngine1.Engine) do
begin
Image:= Form1.DXImageList1.Items.Find('Splash');
Width:= Image.Width;
Height:= Image.Height;
X:= (Form1.DXDraw1.Width-Width) div 2;
Y:= ((Form1.DXDraw1.Height-Height) div 2) + (Height -780);
Z:= 5;
end;
end;


procedure TSplash.DoMove(MoveCount: Integer);
begin
inherited DoMove(MoveCount);
if Form1.Start_Intro then
begin
Y:= Y+100;
if Y > Form1.DXDraw1.Height+Height+10 then
begin
Dead;
end;
end;
end;


I called DXSpriteEngine1.Engine.Moved := False in the splash procedure to 'pause' the game while the bitmap is displayed and TRUE in the eventhandler of the return key to play the game.