Show MainForm.pas syntax highlighted
//*******************************//
// //
// Strange Game Engine Main Form //
// //
//******************//*******************************//*********************//
// //
// This unit is the part of a real time 3d space strategy engine //
// (www.federation.netfirms.com) //
// //
//**************************************************************************//
{
Author : Alexander Federyakov aka Da Stranger
Version : 0.001 ;-]
Date : 02 December '2005
License : You can use this unit ONLY for educational purposes. You cannot use
more than 10% of its code in your own personal projects. It cannot
be used for any commercial products.
Comments: This is the core of a 3d realtime space strategy game engine.
Much is still to be done...
Requirements: GLScene
Known Bugs and limitations: too many...
Contacts:
Web: http://www.sector-37.com
E-mail: datarget@mail.ru
ICQ: 293-963-070
Odigo: 8077227
}
unit MainForm;
interface
uses
Windows, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,VectorTypes,vectorgeometry,
jpeg, StdCtrls, ExtCtrls,{FRMMSnapShot,}
GameConstants,GameEngine, GLMisc, GLTexture, GLScene, GLObjects,
StrangeIniObjects;
type
TGameForm = class(TForm)
Panel1: TPanel;
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Button6: TButton;
GroupBox3: TGroupBox;
Memo1: TMemo;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
CheckBox1: TCheckBox;
Memo2: TMemo;
Panel2: TPanel;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
GLScene1: TGLScene;
GLDummyCube1: TGLDummyCube;
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button1Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
GameForm: TGameForm;
Game: TGame;
PLAYER_1, PLAYER_2: integer;
// mem_info:TRMMSnapShot;
implementation
{$R *.dfm}
procedure TGameForm.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=VK_ESCape then close;
end;
procedure TGameForm.FormCreate(Sender: TObject);
begin
Game := TGame.Create(Panel1, GameForm);
RadioButton4Click(self);
end;
procedure TGameForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Game.free;
end;
procedure TGameForm.Button1Click(Sender: TObject);
begin
{if mem_info=nil then
begin
mem_info := TRMMSnapShot.Create(self);
end;
mem_info.Show;}
end;
procedure TGameForm.Button6Click(Sender: TObject);
var
Un: TUnit;
begin
GroupBox2.Visible := false;
GroupBox1.Visible := true;
GameForm.SetFocus;
Application.ProcessMessages;
if RadioButton2.Checked then
begin
if CheckBox1.checked then Game.CurrentProfile.GeneralSettings.FullScreenMode := True;
Game.AddPlayer('Da Stranger', PT_ALL_SCREEN, Game.races[PLAYER_1]);
Game.AddPlayer('CPU Player', PT_CPU_AVERAGE, Game.races[PLAYER_2]);
end
else
begin
Game.CurrentProfile.GeneralSettings.SplitScreenMode := true;
Game.AddPlayer('Da Stranger', PT_LEFT_SCREEN, Game.races[PLAYER_1]);
Game.AddPlayer('Some other dude', PT_RIGHT_SCREEN, Game.races[PLAYER_2]);
Game.Players[0].LocalSettings.ControlType := CT_KEYBOARD;
end;
Game.Players[PLAYER_1].MainColor := clRed;
Game.Players[PLAYER_1].Secondcolor := clLime;
Game.Players[PLAYER_2].MainColor := clblue;
Game.Players[PLAYER_2].Secondcolor := clFuchsia;
Game.LoadMission('Mission1');
if not Game.Init then
begin
showmessage('Something''s wrong... ');
exit;
end;
//you won't be able to select some of them, because they belong to another player!!!
Un := Game.Players[PLAYER_2].AddUnit('Strange Corvette');
Un.MovementCube.Position.AsAffineVector := AffineVectormake(12,12,0);
Un.ColObject.PredictStaticPositions;
//one unit type
Un := Game.Players[PLAYER_2].AddUnit('Strange Corvette');
Un.MovementCube.Position.AsAffineVector := AffineVectormake(8, 8, 0);
Un.ColObject.PredictStaticPositions;
Un := Game.Players[PLAYER_2].AddUnit('Strange Corvette');
Un.MovementCube.Position.AsAffineVector := AffineVectormake(8, 12, 0);
Un.ColObject.PredictStaticPositions;
Un := Game.Players[PLAYER_2].AddUnit('Strange Corvette');
Un.MovementCube.Position.AsAffineVector := AffineVectormake(12, 8, 0);
Un.ColObject.PredictStaticPositions;
Un := Game.Players[PLAYER_2].AddUnit('Strange Corvette');
Un.MovementCube.Position.AsAffineVector := AffineVectormake(4, 4, 0);
Un.ColObject.PredictStaticPositions;
Un := Game.Players[PLAYER_2].AddUnit('Strange Corvette');
Un.MovementCube.Position.AsAffineVector := AffineVectormake(4, 8, 0);
Un.ColObject.PredictStaticPositions;
Un := Game.Players[PLAYER_2].AddUnit('Strange Corvette');
Un.MovementCube.Position.AsAffineVector := AffineVectormake(8, 4, 0);
Un.ColObject.PredictStaticPositions;
Un := Game.Players[PLAYER_2].AddUnit('Strange Corvette');
Un.MovementCube.Position.AsAffineVector := AffineVectormake(12, 4, 0);
Un.ColObject.PredictStaticPositions;
Un := Game.Players[PLAYER_2].AddUnit('Strange Corvette');
Un.MovementCube.Position.AsAffineVector := AffineVectormake(4, 12, 0);
Un.ColObject.PredictStaticPositions;
Un := Game.Players[PLAYER_2].AddUnit('Strange Corvette');
Un.MovementCube.Position.AsAffineVector := AffineVectormake(8, 8, 4);
Un.ColObject.PredictStaticPositions;
Un := Game.Players[PLAYER_2].AddUnit('Quake Model');
Un.MovementCube.Position.AsAffineVector := AffineVectormake(8, 8, -4);
Un.ColObject.PredictStaticPositions;
//another unit type
Un := Game.Players[PLAYER_1].AddUnit('Earth fighter');
Un.MovementCube.Position.AsAffineVector := AffineVectormake(2, 2, 0);
Un.ColObject.PredictStaticPositions;
Un := Game.Players[PLAYER_1].AddUnit('Earth fighter');
Un.MovementCube.Position.AsAffineVector := AffineVectormake(-2, -2, 0);
Un.ColObject.PredictStaticPositions;
Un.Health := 100;
Un.Shields := 10;
Game.GetPlayer('Da Stranger').LocalSettings.Camera.PointTo(NullHmgVector,ZHmgVector);
if Game.CurrentProfile.GeneralSettings.SplitScreenMode then memo1.Lines.Add(
'Keyboard player controls are loaded from Current Profile config.ini file.' +
'Do NOT press any buttons on the left, because it will cause the form ' +
'to loose focus and no Mousebutton emulation buttons will work');
Beep;
Application.ProcessMessages;
end;
procedure TGameForm.RadioButton1Click(Sender: TObject);
begin
if RadioButton1.Checked then CheckBox1.Enabled := false
else CheckBox1.Enabled := true;
end;
procedure TGameForm.RadioButton4Click(Sender: TObject);
begin
if RadioButton4.Checked then
begin
PLAYER_1 := 1;
PLAYER_2 := 0;
end
else
begin
PLAYER_1 := 0;
PLAYER_2 := 1;
end;
end;
end.
See more files for this project here