Works for me;
Code:
//------------------------------------------------------------------------------
procedure MainLoop;
var Screen: TPHXScreen;
var Timer : TPHXTimer;
var Images: TPHXImageList;
var Input : TPHXInput;
var SpriteEngine: TPHXSpriteEngine;
var Font : TPHXFont;
NumSprites : Integer;
NumCollisions: Integer;
begin
// Create the window
Screen:=TPHXScreen.getInstance();
// Open the window
Screen.Open('Phoenix Sprite Demo', -1, -1, 800, 600);
Screen.Color:= clrBlack;
//Font:=TPHXFont.Create;
//Font.LoadFont('Arial16.phxfnt');
Images:= TPHXImageList.Create;
Images.LoadImage('1945.phximg');
SpriteEngine:= TPHXSpriteEngine.Create;
SpriteEngine.ImageList:= Images;
// Create a new layer with our spriteset
SpriteEngine.Layers.Add( TPHXSpriteLayer.Create( SpriteEngine, '1945.png' ) );
// Create some sprites, see DemoSprites.pas
CreateSprites(SpriteEngine, Images);
Input:= TPHXInput.Create;
Input.Keyboard.KeyBinding[isButton1]:= KeyBinding(VK_SPACE);
Input.Keyboard.KeyBinding[isButton2]:= KeyBinding( Ord('B'), Ord('2'));
Input.Keyboard.KeyBinding[isButton3]:= KeyBinding( Ord('C'), Ord('3'));
Input.Keyboard.KeyBinding[isButton4]:= KeyBinding( VK_DELETE);
Screen.Color:= Color4f(0, 67 / 255, 171 / 255, 0);
Timer:= TPHXTimer.Create;
repeat
Input.Update;
Timer.Update;
Player.Input(Input, Timer.FrameTime);
SpriteEngine.Move(Timer.FrameTime);
// The collision detection is quite expensive, there will be improvements to this later on
// It can be helped alot with the collisiongroups through
NumCollisions:=SpriteEngine.CollisionTest;
// Clear the window
Screen.Clear();
if Player.Lives > 0 then begin
NumSprites:=SpriteEngine.Render(Screen.Width, Screen.Height);
SpriteEngine.WorldY:= SpriteEngine.WorldY - Timer.FrameTime * 100;
Player.Y:= Player.Y - Timer.FrameTime * 100;
end else begin
NumSprites:= 0;
if Trunc(Timer.ElapsedTime * 2) mod 2 = 0 then
// Font.TextOut((Screen.Width - Font.TextWidth(GameOverText)) div 2, (Screen.Height - Font.TextHeight(GameOverText)) div 2, GameOverText, clrYellow)
else
// Font.TextOut((Screen.Width - Font.TextWidth(GameOverText)) div 2, (Screen.Height - Font.TextHeight(GameOverText)) div 2, GameOverText, clrRed);
end;
// Font.TextOut(400, 4 + Font.LineHeight * 0, Format('Lives: %d', [Player.Lives]));
// Font.TextOut(400, 4 + Font.LineHeight * 1, Format('Score: %d', [Player.Score]));
// Font.TextOut(5, 5 + Font.LineHeight * 0, Format('FPS: %d', [Timer.FrameRate]) );
// Font.TextOut(5, 5 + Font.LineHeight * 1, Format('Sprites: %d / %d', [NumSprites, SpriteEngine.Sprites.Count]));
// Font.TextOut(5, 5 + Font.LineHeight * 2, Format('Collisions: %d', [NumCollisions]));
// Flip the buffers
Screen.Flip();
until (Screen.Visible = False);
Images.Free;
Font.Free;
end;
Bookmarks