unit uControl;
////////////////////////////////////////////////////////////////////////////////
INTERFACE
////////////////////////////////////////////////////////////////////////////////
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Menus, uObjekt, Buttons, StdCtrls;
const Max = 100;
type Datentyp = record
Typ : Objekttyp;
Nummer: integer;
StartX: integer;
StartY: integer;
end;
type Dateityp = file of Datentyp;
var Datensatz: Datentyp;
Datei: Dateityp;
type TRaster = class(TObject)
private
// private Deklarationen
rCanvas : TCanvas;
public
// öffentliche Deklarationen
property Canvas : TCanvas read rCanvas write rCanvas;
procedure Render();
end;
type Welttyp = array[1..Max] of TObjekt;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
Beenden1: TMenuItem;
Datei1: TMenuItem;
Speichern1: TMenuItem;
Laden1: TMenuItem;
Neu1: TMenuItem;
Bearbeiten1: TMenuItem;
Rueckgaengig1: TMenuItem;
GroupBox1: TGroupBox;
SpBtLeer: TSpeedButton;
SpBtSW: TSpeedButton;
SpBtWS: TSpeedButton;
SpBtVoll: TSpeedButton;
Image1: TImage;
OpenDialog: TOpenDialog;
SaveDialog: TSaveDialog;
BtStart: TButton;
procedure FormCreate(Sender: TObject);
// Das Raster wird erschaffen
procedure FormClose(Sender: TObject; var Action: TCloseAction);
// Der belegte Speicherplatz des Rasters wird freigegeben
procedure Speichern;
procedure Beenden1Click(Sender: TObject);
procedure Neu1Click(Sender: TObject);
procedure Speichern1Click(Sender: TObject);
procedure Laden1Click(Sender: TObject);
procedure Rueckgaengig1Click(Sender: TObject);
procedure SpBtLeerClick(Sender: TObject);
procedure SpBtSWClick(Sender: TObject);
procedure SpBtWSClick(Sender: TObject);
procedure SpBtVollClick(Sender: TObject);
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure BtStartClick(Sender: TObject);
private
// private Deklarationen
Raster : TRaster;
zBild: TBitmap;
public
// öffentliche Deklarationen
function Bild: TBitmap;
end;
var
Form1: TForm1;
Raster: TRaster;
Welt: Welttyp;
NummerAktuell: integer;
Typ : Objekttyp;
////////////////////////////////////////////////////////////////////////////////
IMPLEMENTATION
////////////////////////////////////////////////////////////////////////////////
//=============================================== Teil 1 - TRaster ===========//
//-------------------------------------------------- Raster Render -----------//
procedure TRaster.Render();
// Das Raster mit 12 * 12 Pixeln Feldgröße wird gezeichnet
var i: integer;
begin
rCanvas.Pen.Color := clWhite;
rCanvas.Rectangle(0, 0, 720, 480);
Form1.Image1.Picture.LoadFromFile('Ressources\Bitmaps\Stickman_Ruhe.bmp');
rCanvas.Pen.Color := clGray;
for i := 1 to 60 do
begin
rCanvas.MoveTo(12*i,0);
rCanvas.LineTo(12*i,480);
end;
for i := 1 to 40 do
begin
rCanvas.MoveTo(0,12*i);
rCanvas.LineTo(720,12*i);
end;
for i := 1 to Max do Welt[i].draw;
end;
////////////////////////////////////////////////////////////////////////////////
//================================================= Teil 2 - TForm ===========//
////////////////////////////////////////////////////////////////////////////////