unit uSpiel;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, AdDraws, AdClasses, AdTypes, AdSprites, AdPNG, AdPerformanceCounter,
AdComponents, AdGUI, AdGUIConnector;
type
TBild =
class(TImageSpriteEx)
private
protected
procedure DoMove(TimeGap: double);
override;
public
shake: boolean;
procedure pict(pict:
string);
constructor Create(AParent:TSprite);
override;
end;
type
TSpieler =
class
private
protected
public
name:
string;
StatsPic: tBild;
StatsPos: tPoint;
Spielernummer: integer;
constructor create(pName:
string);
destructor frei;
end;
type
TForm1 =
class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Idle(Sender:TObject;
var Done:boolean);
private
{ Private declarations }
public
procedure HauptSpielerHinzu(Sender: TObject);
procedure HauptSpielerEntf(Sender: TObject);
procedure HauptSpielerDone(Sender: TObject);
procedure AddPlayerDone(Sender: TObject);
end;
var
Form1: TForm1;
AdDraw: TAdDraw;
AdSpriteEngine: TSpriteEngine;
AdImageList: TAdImageList;
AdPerCounter: TAdPerformanceCounter;
AdGui: TAdGUI;
AdConnector: TAdGUIConnector;
Spieler:
Array[0..9]
of tSpieler;
AnzSpieler: integer;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
AdDraw := TAdDraw.Create(self);
AdDraw.DllName := '
AndorraOGl.dll';
AdSpriteEngine := TSpriteEngine.Create(
nil);
AdSpriteEngine.Surface := AdDraw;
AdImageList := TAdImageList.Create(AdDraw);
AdPerCounter := TAdPerformanceCounter.Create;
AnzSpieler := 0;
AdGUI := TAdGUI.Create(AdDraw);
if AdDraw.Initialize
then
begin
Application.OnIdle := Idle;
AdGUI.Skin.LoadFromFile('
sunna.axs');
AdGUI.Cursors.LoadFromFile('
cursors.xml');
AdGUI.LoadFromFile('
hauptmenu.axg');
AdConnector := TAdGUIConnector.Create(AdGUI);
AdConnector.ConnectEventHandlers(AdDraw.Window);
TAdButton(AdGUI.FindComponent('
SpielerHinzu')).OnClick := HauptSpielerHinzu;
AdImageList.Restore;
end
else
begin
ShowMessage('
Grafikenginefehler.');
halt;
end;
end;
procedure TForm1.HauptSpielerHinzu(Sender: TObject);
begin
AdGUI.LoadFromFile('
Spielerhinzu.axg');
TAdButton(AdGUI.FindComponent('
done')).OnClick := AddPlayerDone;
end;
procedure TForm1.HauptSpielerEntf(Sender: TObject);
begin
end;
procedure TForm1.HauptSpielerDone(Sender: TObject);
begin
end;
procedure TForm1.AddPlayerDone(Sender: TObject);
begin
inc(AnzSpieler);
Spieler[AnzSpieler] := tSpieler.create(TAdEdit(AdGUI.FindComponent('
name')).text);
AdGUI.LoadFromFile('
Hauptmenu.axg');
end;
procedure TForm1.Idle(Sender: TObject;
var Done: boolean);
begin
if AdDraw.CanDraw
then
begin
AdPerCounter.Calculate;
AdDraw.ClearSurface(clBlack);
AdDraw.BeginScene;
AdSpriteEngine.Move(AdPerCounter.TimeGap / 1000);
AdSpriteEngine.Draw;
AdSpriteEngine.Dead;
AdGUI.Update(AdPerCounter.TimeGap / 1000);
AdDraw.EndScene;
AdDraw.Flip;
end;
Done := false;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
AdDraw.Free;
end;
constructor TBild.Create(AParent:TSprite);
begin
inherited;
end;
procedure TBild.Pict(pict:
string);
begin
if AdImageList.Find(pict) =
nil then
begin
with AdImageList.Add(pict)
do
begin
Texture.LoadGraphicFromFile(pict, true, clFuchsia);
end;
AdImageList.Restore;
end;
self.SetImage(AdImageList.Find(pict));
end;
procedure TBild.DoMove(TimeGap: double);
begin
inherited;
end;
constructor TSpieler.create(pName:
string);
begin
name := pName;
Spielernummer := AnzSpieler;
StatsPic := tBild.create(AdSpriteEngine);
StatsPic.pict('
pic/stats.png');
StatsPic.Y := 1;
StatsPic.X := (StatsPic.Width)*(Spielernummer) - StatsPic.Width;
if StatsPic.X = 0
then StatsPic.X := 1;
end;
destructor TSpieler.frei;
begin
end;
end.