In a friend's program written in Pascal (a basic bowling game), the game elements (ball, backouground, etc.) are drawn in a TShape's canvas (Shape1.Canvas
)
The problem is that the element drawn on that Canvas are cropped in a small rectangle on the top left canvas of this TShape. See this screenshot:
Note that I already seen this kind of problem with another Pascal program also using Lazarus/LCL (lazarus's main graphic/ui library) and that this bowling program is running without any bug in Windows, the bug is only experienced in Linux I guess ...
Note also that when drawing on this canvas from a procedure other than the timer's one (for example in OnFormCreate or something), the whole canvas is drawn.
Here are the drawing operations performed (in the timer's procedure):
procedure TForm2.Timer1Timer(Sender: TObject);
var
i: integer;
affich:word;
begin
Shape1.Canvas.Clear;
Lapiste.display(shape1.Canvas);
Laboule.move(Coupcourant, Lapiste);
Laboule.display(Shape1.Canvas);
//LeTabQuilles.collision(CoupCourant);
for i := 1 to 10 do
begin
LeTabQuilles.tab[i].check(LaBoule, CoupCourant);
(LeTabQuilles.tab[i] as CQuille).display(shape1.Canvas);
end;
// ... (rest of the procedure)
The drawing operations (.display) basically draw bitmaps in the canvas given as an attribute ...
It seems like not all Canvases are born equal :).
The problem was solved by simply replacing the TShape
by a TImage
.
Note that this problem is really frequent (at least in my school, and only in Linux) and also happens if you draw directly on the Form's canvas (which is kind of stupid btw).