Code Search for Developers
 
 
  

MainForm.pas from Sector-37 at Krugle


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

Sector-37

Sector-37 (real time 3D cosmic strategy)

Project homepage: http://sourceforge.net/projects/sector37
Programming language(s): Pascal
License: lgpl21

  Campaigns/
    Main/
      map.dsc
      mission1.mis
      mission2.mis
      settings.dsc
    NOT_DECIDED_YET
  Images/
    Cursors/
      Attack.bmp
      Attack.cur
      FollowAndDefend.bmp
      FollowAndDefend.cur
      Menu.bmp
      Menu.cur
      Normal.bmp
      Normal.cur
    Menu/
      Exit-Game.gif
      New-Game.gif
    Misc/
      Console.jpg
  Maps/
    MaterialScripts/
      Sprite.dsc
      clouds.dsc
      default.txt
      planet_day.dsc
      planet_day_origina_minel.dsc
      planet_night.dsc
      red.dsc
      scriptreflective.txt
      super_transparent_planet.dsc
      transparent_planet.dsc
    Meshes/
      asteroid1.3DS
      asteroid2.3DS
      asteroid3.3DS
      asteroid4.3DS
      asteroid5.3DS
      mesh.md3
      mesh_little.md3
      xxx.MD3
    Misc/
      Animations/
        animation.aaf
      Atmospheres/
        atm.dsc
        atm2.dsc
        atm3.dsc
      MovementPaths/
        complicated.dsc
        simple_saved.dsc
      MovementSettings/
        settings.dsc
      Stars/
        xxx.stars
    ObjectScripts/
      AsteroidField.dsc
      AsteroidField2.dsc
      AsteroidField3.dsc
      AsteroidField4.dsc
      Fire_Fx.dsc
      Lensflare1.dsc
      LightSource.dsc
      LightSource_enhanced.dsc
      Light_FX.dsc
      Perlin_FX.dsc
      Real SkyShere.dsc
      SkyShere1.dsc
      SkyShere2.dsc
      Sprite_jupiter.dsc
      Sprite_venus.dsc
      dustCloud1.dsc
      dustCloud2.dsc
      my skybox.dsc
      planet_day_night.dsc
      planet_day_night2.dsc
      planet_mars.dsc
      skybox1.dsc
      stardome1.dsc
      stardome2.dsc
    Textures/
      Meshes/
      Misc/
      Planets/
      SkyBoxes/
      SkySpheres/
      Sprites/
    1.dsc
    2.dsc
    3.dsc
    mission_map.dsc
    xxx.dsc
  Missions/
    Mission1/
  Objects/
    Artifacts/
    Engines/
    Equipment/
    Explosions/
    Race Types/
    Races/
    Shields/
    Unit Classes/
    Units/
    Weapons/
  Profiles/
    Default/
  GLP.nfo
  GameClassAncestors.pas
  GameConstants.pas
  GameEconomyClasses.pas
  GameEngine.pas
  GameSettings.pas
  GameStatisticsClasses.pas
  GameUnitClasses.pas
  MainForm.dfm
  MainForm.pas
  Project_Licence.txt
  Sector37.dpr
  Sector37.ico
  Sector37.res
  Sector37.stat
  Sector37.todo
  _Cleanup.bat
  config.ini
  testing_weapon_position.pas