Hallo,
ich bin gerade dabei einen kleinen Level Editor für mein Spiel zu schreiben. Das Level ist auf einem 2-Dimensionalen Feld aufgebaut. Ich wollte dazu jetzt ein Image nehmen und auf dieses das Raster zeichnen.
Das klappt auch. Ich will jetzt das Image größenabhängig von Form1 machen. Das klappt jetzt nurnoch halbwegs
Wenn ich das Programm kleiner mache klappt alles wunderbar, mache ich es aber größer als es beim Starten war dann klapps nichtmehr. Es wird zwar größer (Image1.Width) aber ich sehe nur einen Teil davon (der eben genau so groß ist wie das Image am Anfang war)
Ich weiß wirklich nichtmehr weiter.....
Hier mal der Code:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54:
| var FelderX, FelderY, FelderW, FelderH: Integer;
[...]
procedure TForm1.DrawGrid; var i: Integer; begin FelderW := (GroupBox1.Width - 16) div FelderX; FelderH := (GroupBox1.Height - 24) div FelderY;
Image1.Width := FelderW * FelderX + 1; Image1.Height := FelderH * FelderY + 1;
Image1.Canvas.Brush.Color := clRed; Image1.Canvas.Brush.Style := bsSolid; Image1.Canvas.FillRect(Rect(0, 0, Image1.Width, Image1.Height));
for i := 0 to FelderX do begin Image1.Canvas.MoveTo(i*FelderW, 0); Image1.Canvas.LineTo(i*FelderW, FelderH*FelderY); end;
for i := 0 to FelderY do begin Image1.Canvas.MoveTo(0, i * FelderH); Image1.Canvas.LineTo(FelderW * FelderX, i* FelderH); end;
Form1.Caption := IntToStr(Image1.Width) + ' | ' + IntToStr(Image1.Height); end;
procedure TForm1.FormResize(Sender: TObject); begin GroupBox2.Left := Form1.Width - GroupBox2.Width - 14; GroupBox3.Left := Form1.Width - GroupBox3.Width - 14; GroupBox1.Width := Form1.Width - GroupBox2.Width - 32; GroupBox1.Height := Form1.Height - 50; DrawGrid; end;
procedure TForm1.Button1Click(Sender: TObject); begin FelderX := StrToInt(Edit1.Text); FelderY := StrToInt(Edit2.Text); DrawGrid; end;
procedure TForm1.FormCreate(Sender: TObject); begin FelderX := 2; FelderY := 3; end; |