Guest User

Untitled

a guest
Aug 6th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 18.21 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, dglOpenGL, Vcl.ExtCtrls, Vcl.StdCtrls, Vcl.Menus, Vcl.ToolWin,
  8.   Vcl.ComCtrls, Vcl.Samples.Spin, Vcl.Tabs, Vcl.CheckLst, Vcl.ActnMan,
  9.   Vcl.ActnColorMaps, Vcl.ExtDlgs, Vcl.ImgList;
  10.  
  11.  
  12.  
  13. type
  14.  
  15.   TForm1 = class(TForm)
  16.     MainMenu1: TMainMenu;
  17.     N1: TMenuItem;
  18.     N2: TMenuItem;
  19.     N3: TMenuItem;
  20.     N4: TMenuItem;
  21.     N5: TMenuItem;
  22.     N6: TMenuItem;
  23.     N7: TMenuItem;
  24.     N8: TMenuItem;
  25.     N9: TMenuItem;
  26.     N10: TMenuItem;
  27.     PopupMenu1: TPopupMenu;
  28.     N12: TMenuItem;
  29.     N13: TMenuItem;
  30.     N14: TMenuItem;
  31.     N15: TMenuItem;
  32.     StatusBar1: TStatusBar;
  33.     TrayIcon1: TTrayIcon;
  34.     Panel1: TPanel;
  35.     PaintBox1: TPaintBox;
  36.     Timer1: TTimer;
  37.     FileOpenDialog1: TFileOpenDialog;
  38.     FileSaveDialog1: TFileSaveDialog;
  39.     BalloonHint1: TBalloonHint;
  40.     PageControl1: TPageControl;
  41.     TabSheet1: TTabSheet;
  42.     TabSheet2: TTabSheet;
  43.     TabSheet3: TTabSheet;
  44.     ScrollBox1: TScrollBox;
  45.     GroupBox1: TGroupBox;
  46.     CheckBox1: TCheckBox;
  47.     SpinEdit1: TSpinEdit;
  48.     SpinEdit2: TSpinEdit;
  49.     ScrollBox2: TScrollBox;
  50.     GroupBox2: TGroupBox;
  51.     ToolBar1: TToolBar;
  52.     ComboBox1: TComboBox;
  53.     ToolButton1: TToolButton;
  54.     ToolButton2: TToolButton;
  55.     ToolButton3: TToolButton;
  56.     ToolButton4: TToolButton;
  57.     ToolButton5: TToolButton;
  58.     ToolButton6: TToolButton;
  59.     ToolButton7: TToolButton;
  60.     ToolButton8: TToolButton;
  61.     ToolButton9: TToolButton;
  62.     ToolButton10: TToolButton;
  63.     ToolButton11: TToolButton;
  64.     ImageList1: TImageList;
  65.     procedure FormResize(Sender: TObject);
  66.     procedure FormDestroy(Sender: TObject);
  67.     procedure IdleHandler(Sender: TObject; var Done : Boolean);
  68.     procedure InitMode(M_type: integer);
  69.     procedure FormCreate(Sender: TObject);
  70.     procedure TrayIcon1DblClick(Sender: TObject);
  71.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  72.     procedure FormHide(Sender: TObject);
  73.     procedure PaintBox1Paint(Sender: TObject);
  74.     procedure Timer1Timer(Sender: TObject);
  75.     procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
  76.       Shift: TShiftState; X, Y: Integer);
  77.     procedure PaintBox1Click(Sender: TObject);
  78.  
  79.     procedure N4Click(Sender: TObject);
  80.     procedure N3Click(Sender: TObject);
  81.     procedure N2Click(Sender: TObject);
  82.     procedure N6Click(Sender: TObject);
  83.     procedure N5Click(Sender: TObject);
  84.     procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
  85.     procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
  86.       Shift: TShiftState; X, Y: Integer);
  87.  
  88.  
  89.   private
  90.     { Private declarations }
  91.     procedure SetupGL;
  92.   public
  93.     { Public declarations }
  94.     dc : HDC;
  95.     hrc : HGLRC;
  96.     rotation: real;
  97.     bx,by:integer;
  98.     createcontext: boolean;
  99.  
  100.   end;
  101.  
  102. const
  103.   NearClipping = 0.1;    //Ближняя плоскость отсечения
  104.   FarClipping  = 200;    //Дальняя плоскость отсечения
  105.   g = 9.8;
  106.  
  107.  
  108. type
  109.   Rectangle=record
  110.     x: real;
  111.     y: real;
  112.     width: integer;
  113.     height: integer;
  114.   end;
  115.  
  116.   Objects = record
  117.   box : Rectangle;
  118.   lives : integer;
  119.   typei:integer;
  120.   Ttype: integer;
  121.   Collision: Boolean;
  122.   draw: integer;
  123.   end;
  124.  
  125.   Textures = record
  126.     gobject:array[1..5] of glUint;
  127.   end;
  128.  
  129. var
  130.   Form1: TForm1;
  131.   mode: integer=1;
  132.   camera_x: extended=0.0;
  133.   camera_y: extended=0.0;
  134.   mouse_up: boolean=true;
  135.   mouse_down, mouse_move: boolean;
  136.   box: rectangle;
  137.   gameobj: array[1..5000] of objects;
  138.   useSnap: boolean;
  139.   snapstepy, snapstepx: integer;
  140.   gobj_count: longint;
  141.   filename: string='0';
  142.   filelable: string='0';
  143.   mouse_x, mouse_y, mouse_mx, mouse_my: integer;
  144.   Tex: Textures;
  145.  
  146. implementation
  147.  
  148. {$R *.dfm}
  149.  
  150. function Texture_Init(path:pchar):GLuint;
  151. var
  152.   i:longint;
  153.   gBitmap:hBitmap;
  154.   sBitmap:Bitmap;
  155.   TextureID : GLuint;
  156.   format: GLuint;
  157. begin
  158.   writeln(path);
  159.   gbitmap:=LoadImage(GetModuleHandle(NIL), path, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION or LR_LOADFROMFILE);
  160.   GetObject(gbitmap, sizeof(sbitmap), @sbitmap);
  161.   glEnable(GL_TEXTURE_2D);
  162.   glGenTextures(1,@TextureID);
  163.   glBindTexture(GL_TEXTURE_2D,TextureID);
  164.   glPixelStorei(GL_UNPACK_ALIGNMENT,4);
  165.   glPixelStorei(GL_UNPACK_ROW_LENGTH,0);
  166.   glPixelStorei(GL_UNPACK_SKIP_ROWS,0);
  167.   glPixelStorei(GL_UNPACK_SKIP_PIXELS,0);
  168.   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  169.   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  170.   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  171.   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  172.   if sbitmap.bmBitsPixel / 8 = 4 then begin
  173.      format:=GL_BGRA_EXT;
  174.   end else begin
  175.      format:=GL_BGR_EXT;
  176.   end;
  177.  glTexImage2D(GL_TEXTURE_2D, 0, sbitmap.bmBitsPixel div 8, sbitmap.bmWidth, sbitmap.bmHeight,
  178.                0, format, GL_UNSIGNED_BYTE, sbitmap.bmBits);
  179.   glBindTexture(GL_TEXTURE_2D, TextureID);
  180.   Texture_Init:=TextureID;
  181. end;
  182.  
  183. procedure TextInit;
  184. begin
  185.   Tex.gobject[1]:=Texture_Init('Data\Images\1.bmp');
  186.  
  187. end;
  188.  
  189. procedure TForm1.SetupGL;
  190. begin
  191.   glClearColor(0.3,0.4,0.7,0.0); // цвет фона голубой
  192.   glEnable(GL_DEPTH_TEST); //включить режим тест глубины
  193.   glEnable(GL_CULL_FACE); //включить режим отображения только передних поверхностей
  194. end;
  195.  
  196.  
  197.  
  198. procedure TForm1.Timer1Timer(Sender: TObject);
  199. begin
  200. PaintBox1Paint(Sender);
  201. end;
  202.  
  203. procedure TForm1.TrayIcon1DblClick(Sender: TObject);
  204. begin
  205. ShowWindow(Application.Handle, SW_RESTORE);
  206. end;
  207.  
  208. procedure TForm1.IdleHandler(Sender : TObject; var Done : Boolean);
  209. begin
  210.   Sleep(1);
  211.   Done := False;
  212.  
  213. end;
  214.  
  215.  
  216.  
  217. procedure DrawGrid(size: real; tWidth: integer; tHeight: integer);
  218. var i: integer;
  219. begin
  220.   glBegin(GL_LINES);
  221.   for i:=0 to tWidth do
  222.   begin
  223.       if (i=0) then  glColor3f(0.6,0.3,0.3)
  224.                else  glColor3f(0.25,0.25,0.25);
  225.       glVertex3f(0,i*size,0);
  226.       glVertex3f(tWidth,i*size,0);
  227.   end;
  228.   for i := 0 to tHeight do
  229.   begin
  230.       if (i=0) then  glColor3f(0.3,0.3,0.6)
  231.                else  glColor3f(0.25,0.25,0.25);
  232.       glVertex3f(i*size,0,0);
  233.       glVertex3f(i*size,tHeight,0);
  234.   end;
  235.   glEnd();
  236. end;
  237.  
  238. procedure draw_quad(_x, _y, _width, _height :real);
  239. begin
  240.   glBegin( GL_QUADS );
  241.     glTexCoord2f(0.0, 0.0); glVertex2f(_x, _y + _height);
  242.     glTexCoord2f(1.0, 0.0); glVertex2f(_x + _width, _y + _height);
  243.     glTexCoord2f(1.0, 1.0); glVertex2f(_x + _width, _y);
  244.     glTexCoord2f(0.0, 1.0); glVertex2f(_x, _y);
  245.   glEnd();
  246. end;
  247.  
  248. procedure TForm1.InitMode(M_type: integer);      //Мы можем работать в двух режимах, либо в ортографическом либо в перспективной проекции
  249. begin
  250.   if (M_type=1)
  251.     then
  252.       begin
  253.           glViewport(0,0,ClientWidth,ClientHeight);
  254.           //установка видовой и проекционной матриц //
  255.           glmatrixmode(GL_PROJECTION);        //работаем в режиме проекционной матрицы
  256.           glloadidentity();                   //замещаем текущую матрицу не единичную
  257.           glortho(0, ClientWidth, ClientHeight, 0, 0, 1); //заружаем ортогональную проекционную матрицу
  258.           glmatrixmode(GL_MODELVIEW);         //работаем в режиме объектно-видовой матрицы
  259.           glloadidentity();                   //заменяем текущую матрицу на единичную
  260.           gltranslatef(camera_x, camera_y, 0);      //смещаем текущую матрицу (хак, чтобы тексели попадали в пиксели)
  261.           glDisable(GL_DEPTH_TEST);           //отключаем проверку буфера глубины
  262.           glEnable(GL_CULL_FACE);             //включаем отсечение задних граней
  263.           glCullFace(GL_BACK);                //отсекаться будут задние грани (повёрнутые задом к камере)
  264.           glFrontFace(GL_CCW);                //верншины полигонов должны задаваться в порядке "против часовой стрелки"
  265.           glShadeModel(GL_SMOOTH);            //устанавливаем модель шейдинга
  266.       end;
  267.  
  268. end;
  269.  
  270. procedure TForm1.N2Click(Sender: TObject);
  271. var
  272.   i:integer;
  273. begin
  274.   filename:='0';
  275.   filelable:='0';
  276.   for I := 1 to 5000 do
  277.      begin
  278.        gameobj[i].box.width:=0;
  279.           gameobj[i].box.height:=0;
  280.           gameobj[i].box.x:=0;
  281.           gameobj[i].box.y:=0;
  282.           gameobj[i].typei:=0;
  283.           gameobj[i].lives:=0;
  284.           gameobj[i].draw:=0;
  285.           gameobj[i].Ttype:=0;
  286.           gameobj[i].Collision:=false;
  287.      end;
  288.   gobj_count:=0;
  289. end;
  290.  
  291. procedure TForm1.N3Click(Sender: TObject);
  292. var f:textfile; i: integer;
  293. begin
  294.   if filename='0' then
  295.     begin
  296.  
  297.       if FileSaveDialog1.Execute then
  298.         begin
  299.           filename:=FileSaveDialog1.FileName;
  300.           filelable:=FileSaveDialog1.FileNameLabel;
  301.           for I := 1 to length(filename) do
  302.             if (filename[i]='.') and (filename[i+1]='t') and (filename[i+2]='x')
  303.             and (filename[i+3]='t')
  304.               then AssignFile(f,filename) ;
  305.  
  306.           Rewrite(f);
  307.           for i := 1 to 5000 do
  308.           begin
  309.             Writeln(f, gameobj[i].box.x:2:4,' ',
  310.                        gameobj[i].box.y:2:4,' ',
  311.                        gameobj[i].box.width,' ',
  312.                        gameobj[i].box.height,' ',
  313.                        gameobj[i].typei,' ',
  314.                        gameobj[i].draw,' ',
  315.                        gameobj[i].lives,' ',
  316.                        gobj_count)
  317.           end;
  318.           CloseFile(f);
  319.         end;
  320.     end ;
  321. end;
  322.  
  323. procedure TForm1.N4Click(Sender: TObject);
  324. var f: textfile; i: integer;
  325. begin
  326.   if FileSaveDialog1.Execute then
  327.     begin
  328.       filename:=FileSaveDialog1.FileName;
  329.       filelable:=FileSaveDialog1.FileNameLabel;
  330.       for I := 1 to length(filename) do
  331.         if (filename[i]='.') and (filename[i+1]='t') and (filename[i+2]='x') and
  332.         (filename[i+3]='t')
  333.         then AssignFile(f,filename)
  334.         else AssignFile(f,filename+'.txt');
  335.  
  336.       Rewrite(f);
  337.       for i := 1 to 5000 do
  338.       begin
  339.         Writeln(f, gameobj[i].box.x:2:4,' ',
  340.                    gameobj[i].box.y:2:4,' ',
  341.                    gameobj[i].box.width,' ',
  342.                    gameobj[i].box.height,' ',
  343.                    gameobj[i].typei,' ',
  344.                    gameobj[i].draw,' ',
  345.                    gameobj[i].lives,' ',
  346.                    gobj_count)
  347.       end;
  348.       CloseFile(f);
  349.     end;
  350. end;
  351.  
  352. procedure TForm1.N5Click(Sender: TObject);
  353. var
  354.   i:integer;   f: textfile;
  355. begin
  356.  
  357.   if FileOpenDialog1.Execute then
  358.     begin
  359.       filename:='0';
  360.       filelable:='0';
  361.       for I := 1 to 5000 do
  362.          begin
  363.               gameobj[gobj_count].box.width:=0;
  364.               gameobj[gobj_count].box.height:=0;
  365.               gameobj[gobj_count].box.x:=0;
  366.               gameobj[gobj_count].box.y:=0;
  367.               gameobj[gobj_count].typei:=0;
  368.               gameobj[gobj_count].lives:=0;
  369.               gameobj[gobj_count].draw:=0;
  370.               gameobj[gobj_count].Ttype:=0;
  371.               gameobj[gobj_count].Collision:=false;
  372.          end;
  373.       gobj_count:=0;
  374.       filename:=FileOpenDialog1.FileName;
  375.       filelable:=FileOpenDialog1.FileNameLabel;
  376.       AssignFile(f, filename);
  377.       Reset(f);
  378.       for I := 1 to 5000 do
  379.         readln(f,  gameobj[i].box.x,
  380.                    gameobj[i].box.y,
  381.                    gameobj[i].box.width,
  382.                    gameobj[i].box.height,
  383.                    gameobj[i].typei,
  384.                    gameobj[i].draw,
  385.                    gameobj[i].lives,
  386.                    gobj_count);
  387.       CloseFile(f);
  388.     end;
  389.  
  390. end;
  391.  
  392. procedure TForm1.N6Click(Sender: TObject);
  393. begin
  394.   PostQuitMessage(0);
  395. end;
  396.  
  397. procedure TForm1.PaintBox1Click(Sender: TObject);
  398. var
  399.   I: Integer;
  400. begin
  401.  
  402. end;
  403.  
  404. procedure TForm1.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
  405.   Shift: TShiftState; X, Y: Integer);
  406.   var bricks_count: integer;
  407. begin
  408.  
  409. end;
  410.  
  411.  
  412.  
  413. procedure Scene_Draw();
  414. var i:integer;
  415. begin
  416.   for I := 1 to 5000 do
  417.     draw_quad(gameobj[i].box.x,
  418.               gameobj[i].box.y,
  419.               gameobj[i].box.width,
  420.               gameobj[i].box.height);
  421.  
  422.  
  423. end;
  424.  
  425. procedure TForm1.PaintBox1Paint(Sender: TObject);
  426. begin
  427.  glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  428.     InitMode(mode);
  429.  
  430.     if checkbox1.Checked=true then
  431.        DrawGrid(SpinEdit2.Value, SpinEdit1.Value, SpinEdit1.Value);
  432.  
  433.     Scene_Draw;
  434.     if GetKeyState(38) and 128>=128 then
  435.       begin
  436.         camera_y:=camera_y+2
  437.       end;
  438.  
  439.     if GetKeyState(40) and 128>=128 then
  440.       begin
  441.         camera_y:=camera_y-2
  442.       end;
  443.  
  444.     if GetKeyState(37) and 128>=128 then
  445.       begin
  446.         camera_x:=camera_x+2
  447.       end;
  448.  
  449.     if GetKeyState(39) and 128>=128 then
  450.       begin
  451.         camera_x:=camera_x-2
  452.       end;
  453.  
  454.     //InvalidateRect(Handle,nil,false);
  455.     if filename='0' then  StatusBar1.Panels.Items[4].Text:='* NEW FILE'
  456.            else StatusBar1.Panels.Items[4].Text:=filename;
  457.     StatusBar1.Panels.Items[0].Text:='X: '+IntToStr(mouse_x);
  458.     StatusBar1.Panels.Items[1].Text:='Y: '+IntToStr(mouse_y);
  459.     StatusBar1.Panels.Items[3].Text:=IntToStr(gobj_count);
  460.  
  461.     SwapBuffers(dc);
  462. end;
  463.  
  464. procedure TForm1.FormResize(Sender: TObject);
  465. var
  466.   tmpBool : Boolean;
  467. begin
  468.   InitMode(mode);
  469.   idleHandler(Sender,tmpBool);
  470. end;
  471.  
  472. procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
  473. begin
  474. ShowWindow(Application.Handle, SW_HIDE);
  475. end;
  476.  
  477.  
  478. procedure TForm1.FormCreate(Sender: TObject);
  479. begin
  480.      dc := GetDC(Panel1.Handle); //получаем контекст устройства по форме Form1
  481.  
  482.   //с InitOpenGL инициализирцется OpenGL, если это не удается то приложение закрывается
  483.   if  not InitOpenGL then
  484.     Application.Terminate;
  485.  
  486.   //эта строка создаёт контекст рендеринга
  487.   hrc := CreateRenderingContext(dc,[opDoubleBuffered],32,24,0,0,0,0);
  488.   //TextInit;
  489.   ActivateRenderingContext(dc,hrc); //активируем контекст рендеринга
  490.   SetupGL;                          //установка режимов OpenGL
  491.   Application.OnIdle := IdleHandler;
  492. end;
  493.  
  494. procedure TForm1.FormDestroy(Sender: TObject);
  495. begin
  496.   DeactivateRenderingContext;
  497.   DestroyRenderingContext(hrc);
  498.   ReleaseDC(Handle,dc);
  499. end;
  500.  
  501. procedure TForm1.FormHide(Sender: TObject);
  502. begin
  503.   ShowWindow(Application.Handle, SW_HIDE);
  504. end;
  505.  
  506.  
  507.  
  508.  
  509. procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  510.   Shift: TShiftState; X, Y: Integer);
  511. begin
  512.  
  513.   if ComboBox1.ItemIndex=0 then
  514.         begin
  515.           gobj_count:=gobj_count+1;
  516.           gameobj[gobj_count].box.width:=32;
  517.           gameobj[gobj_count].box.height:=32;
  518.           gameobj[gobj_count].box.x:=mouse_x-camera_x;
  519.           gameobj[gobj_count].box.y:=mouse_y-camera_y;
  520.           gameobj[gobj_count].typei:=1;
  521.           gameobj[gobj_count].lives:=1;
  522.           gameobj[gobj_count].draw:=1;
  523.         end;
  524.  
  525.   if ComboBox1.ItemIndex=1 then
  526.         begin
  527.           gobj_count:=gobj_count+1;
  528.           gameobj[gobj_count].box.width:=32;
  529.           gameobj[gobj_count].box.height:=32;
  530.           gameobj[gobj_count].box.x:=mouse_x-camera_x;
  531.           gameobj[gobj_count].box.y:=mouse_y-camera_y;
  532.           gameobj[gobj_count].typei:=2;
  533.           gameobj[gobj_count].lives:=1;
  534.           gameobj[gobj_count].draw:=1;
  535.         end;
  536.  
  537.   if ComboBox1.ItemIndex=2 then
  538.         begin
  539.           gobj_count:=gobj_count+1;
  540.           gameobj[gobj_count].box.width:=32;
  541.           gameobj[gobj_count].box.height:=32;
  542.           gameobj[gobj_count].box.x:=mouse_x-camera_x;
  543.           gameobj[gobj_count].box.y:=mouse_y-camera_y;
  544.           gameobj[gobj_count].typei:=3;
  545.           gameobj[gobj_count].lives:=1;
  546.           gameobj[gobj_count].draw:=1;
  547.         end;
  548.  
  549.   if ComboBox1.ItemIndex=3 then
  550.         begin
  551.           gobj_count:=gobj_count+1;
  552.           gameobj[gobj_count].box.width:=32;
  553.           gameobj[gobj_count].box.height:=32;
  554.           gameobj[gobj_count].box.x:=mouse_x-camera_x;
  555.           gameobj[gobj_count].box.y:=mouse_y-camera_y;
  556.           gameobj[gobj_count].typei:=4;
  557.           gameobj[gobj_count].lives:=1;
  558.           gameobj[gobj_count].draw:=1;
  559.         end;
  560.  
  561.   if ComboBox1.ItemIndex=4 then
  562.         begin
  563.           gobj_count:=gobj_count+1;
  564.           gameobj[gobj_count].box.width:=32;
  565.           gameobj[gobj_count].box.height:=32;
  566.           gameobj[gobj_count].box.x:=mouse_x-camera_x;
  567.           gameobj[gobj_count].box.y:=mouse_y-camera_y;
  568.           gameobj[gobj_count].typei:=5;
  569.           gameobj[gobj_count].lives:=1;
  570.           gameobj[gobj_count].draw:=1;
  571.         end;
  572.  
  573.   if ((GetKeyState(97) and 128)>=128) and (mouse_x>gameobj[gobj_count].box.x)
  574.       and (mouse_x<gameobj[gobj_count].box.x + gameobj[gobj_count].box.width)
  575.       and (mouse_y<gameobj[gobj_count].box.y + gameobj[gobj_count].box.height)
  576.       and (mouse_y>gameobj[gobj_count].box.y)
  577.       then
  578.         begin
  579.           gameobj[gobj_count].box.width:=0;
  580.           gameobj[gobj_count].box.height:=0;
  581.           gameobj[gobj_count].box.x:=0;
  582.           gameobj[gobj_count].box.y:=0;
  583.           gameobj[gobj_count].typei:=0;
  584.           gameobj[gobj_count].lives:=0;
  585.           gameobj[gobj_count].draw:=0;
  586.           gameobj[gobj_count].Ttype:=0;
  587.           gameobj[gobj_count].Collision:=false;
  588.           gobj_count:=gobj_count-1;
  589.         end;
  590.  
  591. end;
  592.  
  593. procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  594.   Y: Integer);
  595. begin
  596.   if (GetKeyState(17) and 128)>=128 then
  597.     begin
  598.       camera_x:= camera_x - (mouse_x / 1000);
  599.       camera_y:=  camera_y - (mouse_y / 1000);
  600.     end;
  601.  
  602.   if CheckBox1.Checked=true then
  603.   begin
  604.     mouse_x:=round(x/SpinEdit2.Value)*SpinEdit2.Value;
  605.     mouse_y:=round(y/SpinEdit2.Value)*SpinEdit2.Value;
  606.   end
  607.  
  608.   else begin
  609.     mouse_x:=x;
  610.     mouse_y:=y;
  611.   end;
  612. end;
  613.  
  614. end.
Add Comment
Please, Sign In to add comment