Proof that using Phoenix is easy:
I wrote a testbed incorporating a turnable freighter in 20 minutes from the included template in Turbo Delphi. I took an image I knew of that was 20 frames worth of rotation, turned it into a PNG and then made it into a 5x4 grid. 4 minutes of processing. Getting the basic template working took a little more effort as I forgot to copy the DLLs. I easily got my image in, rotating, and my framerate appearing in the window title within in under about 10 minutes. The delay was caused by a minor bug I can't quite track down (showing the frame rate hid the freighter somehow). After that I included a fullscreen toggle in no time at all, complete with reloading images and so on.
It totals only 90 lines and is really easy to understand. It even averages 5,300FPS.
Sum total I learned to use the images, input, screen, and timer objects in less than 30 minutes. Now I'm starting to get ready to have a bit more fun in making something that is more of an actual game.
Here's my code for those interested:
Code:
unit Main;
{$IFDEF FPC}
{$mode objfpc}{$H+}
{$ENDIF}
interface
uses
Classes, SysUtils, Math,
phxBase,
phxScreen,
phxImages,
phxInput,
phxTimer;
procedure MainLoop;
implementation
//------------------------------------------------------------------------------
procedure MainLoop;
const
TurnSpeed = 12;
var Screen: TPHXScreen;
Image: TPHXImage;
KeyBoard: TPHXKeyboard;
Timer: TPHXTimer;
Rotation: Single;
Switched: Boolean;
begin
// Get the window
Screen := TPHXScreen.getInstance();
Screen.VSync := True;
KeyBoard := TPHXKeyboard.Create;
Timer := TPHXTimer.Create;
// Open the window
if not Screen.Open('Rotating Freighter Example', -1, -1, 800, 600) then Exit;
Image := TPHXImage.Create;
Image.LoadImage('robominer.png');
Image.UpdatePatterns(128,128);
Rotation := 0;
Switched := False;
repeat
KeyBoard.Update;
if (KeyBoard.Keys[VK_RALT] and KeyBoard.Keys[VK_RETURN]) and (not Switched) then begin
Screen.Close;
Screen.Fullscreen := not Screen.Fullscreen;
Screen.Update;
Screen.Open;
Image.Clear;
Image.LoadImage('robominer.png');
Image.UpdatePatterns(128,128);
Switched := True;
end else if not (KeyBoard.Keys[VK_RALT] and KeyBoard.Keys[VK_RETURN]) then
Switched := False;
Timer.Update;
if Timer.FrameCount mod 50 = 0 then
Screen.Title := Format('Rotating Freighter Example [%dFPS]',[Timer.FrameRate]);
// Clear the window
Screen.Clear();
// Turn the ship! Woo!
if KeyBoard.Keys[VK_LEFT] then
Rotation := Rotation - TurnSpeed*Timer.FrameTime;
if KeyBoard.Keys[VK_RIGHT] then
Rotation := Rotation + TurnSpeed*Timer.FrameTime;
if Rotation <0> 359 then
Rotation := Rotation - 359;
Image.Draw(336,236, Trunc(Rotation) mod 20);
// Flip the buffers
Screen.Flip();
until (Screen.Visible = False);
end;
end.
Bookmarks