Autor Beitrag
mg4all
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 62

WIN 7
Delphi 7 Enterprise
BeitragVerfasst: Mi 29.12.10 09:27 
Hallo Leute !

Habe wieder mal eine grundlegende Frage :

In meinem Spiel werden Figuren auf einem TImage plaziert (wenn die Farbe <> clfuchsia ist). Alles kein Problem, wenn sich aber die Bildschirmauflösung ändert und ich TImage.strech = true; gesetzt habe bleibt meine Figur auf der gleichen Höhe stecken, kann mir jemand sagen wo das Problem liegt ?

Hier noch ein bischen Quelltext :

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm3.raupesetzen;
for i := 0 to 5000 do
 if spielfeld.Canvas.Pixels[image1.left,i] <> clfuchsia then
 begin
  image1.Top := i - image1.Height;
  break;
 end;
end;
:?: :?: :?: :?: :?: :?: :?: :?:

Moderiert von user profile iconNarses: Code- durch Delphi-Tags ersetzt
Moderiert von user profile iconMartok: Topic aus VCL (Visual Component Library) verschoben am Mi 29.12.2010 um 16:04

_________________
Wer nicht fragt hat schon verloren !!!
JDKDelphi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 115
Erhaltene Danke: 22

WIN2000, XP, WIN 7 , UNIX, LINUX
Assembler für (Z8x, 68xxx,R6000,Intel), DELPHI 6 Enterprise, MAGIC eDeveloper V9+V10, C++, C#,VB, .NET, zertifizierter iBOLT-Programmierer
BeitragVerfasst: Mi 29.12.10 10:07 
Hallo,

ich hatte mal so gelöst:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure TAXBitmap.RefreshAX;
var abmp : TBITMAP;
   x,y : integer;
begin
  x := width;
  y := height;
  image1.Width := x;
  image1.Height:= y;
  fgui.USR_WINDOW(0,x,0,y);
  fgui.USR_SCALE(-1,flength,fwidth,-1);
  //------ Größe ändern
  abmp := tbitmap.Create;
  abmp.Height := image1.Height;
  abmp.Width  := image1.Width;
  image1.Picture.Bitmap := abmp;
  abmp.Free;
  fgui.Move_2D(0,0,image1.Canvas);
end;

//fGui. xxxx   // eigene GUI-Verwaltung
// ab abmp   wirds interessant




Gruß

_________________
Wo andere aufhören, fange ich erst an..
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Mi 29.12.10 10:28 
Du greifst per Canvas.Pixels immer auf das zugrundeliegende Bitmap zu, nicht auf die Darstellung.
Wenn Du z.B. ein BMP mit 100*100 Punkten hast und auf 200*200 Strechet, greift Du schon mit Pixels[100,100] in einen ungültigen Bereich.
Da das ganze nach Animation klingt, vielleicht kannst Du das brauchen:
www.delphipraxis.net...rehung-und-zoom.html

_________________
Das Problem liegt üblicherweise zwischen den Ohren H₂♂
DRY DRY KISS
mg4all Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 62

WIN 7
Delphi 7 Enterprise
BeitragVerfasst: Fr 31.12.10 01:59 
:D Danke für die Antworten :D

Ich habe das Problem jetzt so gelöst :

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
procedure TForm3.spielfeldwandeln;
var tmpbmp: TBitmap;
    rechteck: TRect;
begin
rechteck.Left := 0;
rechteck.Top := 0;
rechteck.Right := form3.ClientWidth;
rechteck.Bottom := form3.ClientHeight;
tmpbmp := TBitmap.Create;
tmpbmp.Width := form3.ClientWidth;
tmpbmp.Height := form3.ClientHeight;
tmpbmp.Canvas.StretchDraw(rechteck,spielfeld.Picture.Graphic);
BitBlt(spielfeld.Canvas.Handle,0,0,screen.Width,screen.Height,tmpbmp.Canvas.Handle, 00, SRCCOPY);
spielfeld.Picture := nil;
spielfeld.Picture.Bitmap := tmpbmp;
tmpbmp.Free;
end;

Und hiermit hatte ich Erfolg:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm3.raupesetzen;
begin
image1.Left := 5;
for i := 1 to 5000 do
 if spielfeld.Canvas.Pixels[image1.left,i] <> clfuchsia then
 begin
  image1.Top := i - image1.Height;
  break;
 end;
end;


Wenn Jemand eine andere Lösung hat die schneller ist, bitte Posten :!: :!: :!:

_________________
Wer nicht fragt hat schon verloren !!!
platzwart
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1054
Erhaltene Danke: 78

Win 7, Ubuntu 9.10
Delphi 2007 Pro, C++, Qt
BeitragVerfasst: Fr 31.12.10 02:34 
Benutz die graphics32. Das ist eine Sammlung von Komponenten für Grafik (Image, Paintbox, Bitmap, also alles, was Delphi auch so hat, bloß sind diese Komponenten unglaublich schnell).

Abgesehen davon solltest du mit Scanline arbeiten, einfach mal danach suchen ;)

_________________
Wissenschaft schafft Wissenschaft, denn Wissenschaft ist Wissenschaft, die mit Wissen und Schaffen Wissen schafft. (myself)
der organist
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 467
Erhaltene Danke: 17

WIN 7
NQC, Basic, Delphi 2010
BeitragVerfasst: Fr 31.12.10 11:54 
wofür hast du da ein break drin? So ne for schleife mit Abfrage lässt sich doch auch mit ner while-Schleife vereinfachen...

ausblenden Delphi-Quelltext
1:
2:
3:
k:=1;
while((k<5001)AND(spielfeld.Canvas.Pixels[image1.left,i] <> clfuchsia))then
  image1.Top:=k-image1.Height;

_________________
»Gedanken sind mächtiger als Waffen. Wir erlauben es unseren Bürgern nicht, Waffen zu führen - warum sollten wir es ihnen erlauben, selbständig zu denken?« Josef Stalin
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19321
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 31.12.10 12:41 
Ich frage mich eigentlich eher, ob man das ganze nicht auch anders lösen kann. Wofür dient denn diese Abfrage nach einer Farbe?

Das sieht fast so aus als würdest du damit quasi versuchen zu kompensieren, dass du vergessen hast die Daten zu speichern was bisher passiert ist. :gruebel: Wenn dem so ist, ist das so ungefähr die ungünstigste und langsamste Lösungsmöglichkeit, die mir einfällt...