hlmod.hu
https://hlmod.hu/

Pascal/Scilexer
https://hlmod.hu/viewtopic.php?f=18&t=4222
Oldal: 1 / 1

Szerző:  kiki [2012.04.27. 18:28 ]
Hozzászólás témája:  Pascal/Scilexer

Honnan tudok egy működő scilexert szerezni? És hogyan kell telepíteni, beüzemelni?

Szerző:  VirTuaL ~` [2012.04.27. 18:30 ]
Hozzászólás témája:  Re: Pascal/Scilexer

Pascal? Amivel programot kell írni?xd Ma írtunk azzal programot infó órán xd

Szerző:  kiki [2012.04.27. 18:41 ]
Hozzászólás témája:  Re: Pascal/Scilexer

Pascallal mióta írsz programot? Ez egy programnyelv, delphivel közös szinte, de amúgy nemhiszem hogy ilyen emelt szinten használjátok! Elég bonyolult egy programnyelv!

Példa:
Kód:
  1. unit PlayGround;

  2.  

  3. {$mode objfpc}{$H+}

  4.  

  5. interface

  6.  

  7. uses

  8.   Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, LMessages,

  9.   ExtCtrls;

  10.  

  11. type

  12.  

  13.   { TPictureControl }

  14.  

  15.   TPictureControl = class(TCustomControl)

  16.     procedure PictureChanged(Sender: TObject);

  17.   private

  18.     FPicture: TPicture;

  19.     procedure SetPicture(const AValue: TPicture);

  20.     procedure WMEraseBkgnd(var Msg: TLMessage); message LM_ERASEBKGND;

  21.   public

  22.     constructor Create(TheOwner: TComponent); override;

  23.     destructor Destroy; override;

  24.     procedure Paint; override;

  25.   published

  26.     property Picture: TPicture read FPicture write SetPicture;

  27.   end;

  28.  

  29.   { TPlayGroundForm }

  30.  

  31.   TPlayGroundForm = class(TForm)

  32.     Timer1: TTimer;

  33.     procedure PlayGroundFormClose(Sender: TObject; var CloseAction: TCloseAction

  34.       );

  35.     procedure PlayGroundFormCreate(Sender: TObject);

  36.     procedure PlayGroundFormDestroy(Sender: TObject);

  37.     procedure Timer1Timer(Sender: TObject);

  38.   private

  39.     procedure UpdateImage;

  40.   public

  41.     PictureControl: TPictureControl;

  42.     SpriteImg: TCustomBitmap;

  43.     BackgroundImg: TCustomBitmap;

  44.     BufferImg: TCustomBitmap;

  45.   end;

  46.  

  47. var

  48.   PlayGroundForm: TPlayGroundForm;

  49.  

  50. implementation

  51.  

  52. { TPlayGroundForm }

  53.  

  54. procedure TPlayGroundForm.PlayGroundFormCreate(Sender: TObject);

  55. begin

  56.   PictureControl:=TPictureControl.Create(Self);

  57.   with PictureControl do begin

  58.     Parent:=Self;

  59.     Align:=alClient;

  60.   end;

  61.  

  62.   SpriteImg:=TPortableNetworkGraphic.Create;

  63.   BackgroundImg:=TPortableNetworkGraphic.Create;

  64.   BufferImg:=TBitmap.Create;

  65.  

  66.   SpriteImg.LoadFromFile(SetDirSeparators('../../kepek/mozgokep.png'));

  67.   BackgroundImg.LoadFromFile(SetDirSeparators('../../kepek/hatterkep.png'));

  68.   BufferImg.Width:=BackgroundImg.Width;

  69.   BufferImg.Height:=BackgroundImg.Height;

  70.  

  71.   UpdateImage;

  72. end;

  73.  

  74. procedure TPlayGroundForm.PlayGroundFormClose(Sender: TObject;

  75.   var CloseAction: TCloseAction);

  76. begin

  77.   Timer1.Enabled:=false;

  78. end;

  79.  

  80. procedure TPlayGroundForm.PlayGroundFormDestroy(Sender: TObject);

  81. begin

  82.   SpriteImg.Free;

  83.   BackgroundImg.Free;

  84.   BufferImg.Free;

  85. end;

  86.  

  87. procedure TPlayGroundForm.Timer1Timer(Sender: TObject);

  88. begin

  89.   if csDestroying in ComponentState then exit;

  90.   UpdateImage;

  91. end;

  92.  

  93. procedure TPlayGroundForm.UpdateImage;

  94. var

  95.   DestImg: TBitmap;

  96.   t: Double;

  97.   x: Int64;

  98.   y: Integer;

  99.   CenterX: Integer;

  100.   CenterY: Integer;

  101. begin

  102.  

  103.   BufferImg.Canvas.CopyRect(Rect(0,0,BufferImg.Width,BufferImg.Height),

  104.        BackgroundImg.Canvas,Rect(0,0,BackgroundImg.Width,BackgroundImg.Height));

  105.   CenterX:=BufferImg.Width div 2;

  106.   CenterY:=BufferImg.Height div 2;

  107.   t:=Now*86400;

  108.   x:=CenterX+round(cos(t)*CenterX*2/3)-(SpriteImg.Width div 2);

  109.   y:=CenterY+round(sin(t*0.7)*CenterY*2/3)-(SpriteImg.Height div 2);

  110.   BufferImg.Canvas.Draw(x, y, SpriteImg);

  111.  

  112.   DestImg:=PictureControl.Picture.Bitmap;

  113.   DestImg.Width:=BufferImg.Width;

  114.   DestImg.Height:=BufferImg.Height;

  115.   DestImg.Canvas.Draw(0,0,BufferImg);

  116. end;

  117.  

  118. { TPictureControl }

  119.  

  120. procedure TPictureControl.SetPicture(const AValue: TPicture);

  121. begin

  122.   if FPicture=AValue then exit;

  123.   FPicture.Assign(AValue);

  124. end;

  125.  

  126. procedure TPictureControl.WMEraseBkgnd(var Msg: TLMessage);

  127. begin

  128.   Msg.Result := 1;

  129. end;

  130.  

  131. procedure TPictureControl.PictureChanged(Sender: TObject);

  132. begin

  133.   Invalidate;

  134. end;

  135.  

  136. constructor TPictureControl.Create(TheOwner: TComponent);

  137. begin

  138.   inherited Create(TheOwner);

  139.   FPicture:=TPicture.Create;

  140.   FPicture.OnChange:=@PictureChanged;

  141. end;

  142.  

  143. destructor TPictureControl.Destroy;

  144. begin

  145.   FreeAndNil(FPicture);

  146.   inherited Destroy;

  147. end;

  148.  

  149. procedure TPictureControl.Paint;

  150. begin

  151.   if Picture.Graphic<>nil then

  152.     Canvas.StretchDraw(Rect(0,0,Width,Height),Picture.Graphic);

  153.   inherited Paint;

  154. end;

  155.  

  156. initialization

  157.   {$I playground.lrs}

  158.  

  159. end.    

Szerző:  GhostRyder [2012.04.27. 18:42 ]
Hozzászólás témája:  Re: Pascal/Scilexer

Virtual nektek volt ma suli? :O

Szerző:  tson_ [2012.04.27. 18:46 ]
Hozzászólás témája:  Re: Pascal/Scilexer

Volt, és nekemis viszont hétfő keddet megadják és nem köll menni.
Jól mondom Virtual ? :D

Oldal: 1 / 1 Minden időpont UTC+02:00 időzóna szerinti
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/