Hello everybody!
I'm still new here and the Lazarus is a bit new for me. I would like make a small game with Lazarus, in which the player can put down balls in the window on the mouse coordinates - but my code doesn't work. Here is:
Code:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, mouse;
type
{ TMainWindow }
TMainWindow = class(TForm)
procedure FormClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
type TBall=class(TObject)
private
public
constructor makeit(xplace,yplace: integer; itspic: Tbitmap);
end;
var
MainWindow: TMainWindow;
ballpic: TBitmap;
aball: TBall;
implementation
{$R *.lfm}
constructor TBall.makeit(xplace,yplace: integer; itspic: Tbitmap);
begin
xplace:=getmousex;
yplace:=getmousey;
itspic:=ballpic;
end;
//end;
{ TMainWindow }
procedure TMainWindow.FormClick(Sender: TObject);
begin
aball:=TBall.makeit(getmousex,getmousey,ballpic);
MainWindow.Canvas.Draw(aball.xplace,aball.yplace,aball.itspic);
end;
procedure TMainWindow.FormCreate(Sender: TObject);
begin
ballpic:=TBitmap.Create;
ballpic.LoadFromFile('ballbmp.bmp');
end;
end.
And the error messages:
Projekt fordítása, Cél: kepfutidoben.exe: Kilépési kód: 1, Hibák: 3, Tippek: 3
unit1.pas(26,24) Hint: Value parameter "xplace" is assigned but never used
unit1.pas(26,31) Hint: Value parameter "yplace" is assigned but never used
unit1.pas(26,4 Hint: Value parameter "itspic" is assigned but never used
unit1.pas(50,36) Error: identifier idents no member "xplace"
unit1.pas(50,49) Error: identifier idents no member "yplace"
unit1.pas(50,62) Error: identifier idents no member "itspic"
Somebody can help me to solving this problem? I would like placing ball objects at runtime.
Bookmarks