Autor Beitrag
Unknown
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 184

Win XP
Delphi 7
BeitragVerfasst: Fr 22.06.07 16:01 
Hallo erstmal.

Ich wollt ma wissen, wie das geht, das z.B. ein Panzer (im Bitmap und Tranzparent) eine mit Canvas gezeichtnete Ebene langfährt. Also wenn man "d" drückt ,damit er nucht einfach nach rechts fährt, sondern auf der Ebene fährt..

thx im vorraus

Edit: oder wenn das mit Panzer zu schwer ist dann einfach mit nem cube....
Ironwulf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Fr 22.06.07 16:48 
ich wollt ma ne art worms machn, aber is ja johnny was da übern bildschirm wandert ;D

das gelände muss schwarz sein und der hintergrund weiß, wenns bei die anders is, einfach anpassn

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
If Image1.Canvas.Pixels[Image2.Width div 2 + Image2.Left,Image2.Height + Image2.Top] = clWhite Then//wenn der Pixel in mitte unter dem panzer kein geländer ist dann fällt er nach unten
  begin   // Fallen
    Image2.Top:= Image2.Top + 1;
  end else
  begin

    If Richtung = 0 Then //richtun ne var in meinem prog das sagt das sich die figur nach links bewegt
    begin
      If Image1.Canvas.Pixels[Image2.Left,Image2.Height div 2 + Image2.Top] <> clBlack Then Image2.Left:= Image2.Left - 1; //links laufen

      If Image1.Canvas.Pixels[Image2.Width div 2 + Image2.Left - 1,Image2.Height + Image2.Top - Y] = clBlack Then //Y grad der max steigung des berges in pixel, war bei mir 1
      begin
        Image2.Top:= Image2.Top - Y;   //berg steign
      end;
    end;


ich häng meins einfach mal mit an, macht vllt alles ein wenig klarer
Einloggen, um Attachments anzusehen!
Unknown Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 184

Win XP
Delphi 7
BeitragVerfasst: Fr 22.06.07 16:55 
danke erstmal..
wenn du deine Project dateien noch hast kannst du sie mir auch schicken?

Hat alles funktioniert
Ironwulf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Fr 22.06.07 17:19 
ich habs doch hochgeladen, weinfach auf download klicken...
Unknown Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 184

Win XP
Delphi 7
BeitragVerfasst: Fr 22.06.07 17:21 
ohh :oops:
habe ich nicht gesehen, sorry thx nochmal :)
Unknown Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 184

Win XP
Delphi 7
BeitragVerfasst: Fr 22.06.07 17:58 
Funktioniert nicht:
ausblenden volle Höhe Delphi-Quelltext
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:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Image1: TImage;
    Image2: TImage;
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Image1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  ls:Tbitmap;
  punkt: array [1..7] of Tpoint;
implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var  abstand:integer;
begin
Image2.Picture.LoadFromFile('C:\blablabla\Game\Bits\b1.bmp');
abstand:=Image1.Width div 4;
ls:=Tbitmap.Create;
ls.Width:=Image1.Width;
ls.Height:=Image1.Height;
Randomize;
punkt[2].Y:=Random(137)+100;
punkt[6].Y:=Random(137)+100;
punkt[4].Y:=Random(137)+100;
punkt[3].Y:=Random(137)+100;
punkt[5].Y:=Random(137)+100;
punkt[1].Y:=image1.Height;
punkt[7].Y:=Image1.Height;
punkt[2].x:=0;
punkt[6].x:=Image1.Width;
punkt[4].x:=Image1.Width div 2;
punkt[3].x:=abstand;
punkt[5].x:=3*abstand;
punkt[1].x:=0;
punkt[7].x:=Image1.Width;
with ls.Canvas do
 begin
   pen.Color:=clwhite;
   rectangle(0,0,Image1.Width,Image1.Height);
   pen.Color:=clblack;
   brush.Color:=clblack;
   polygon(punkt);
 end;
Image1.Picture.Bitmap:=ls;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
If Image1.Canvas.Pixels[Image2.Width div 2 + Image2.Left,Image2.Height + Image2.Top] = clwhite Then//wenn der Pixel in mitte unter dem panzer kein geländer ist dann fällt er nach unten
  begin   // Fallen
    Image2.Top:= Image2.Top + 1;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
end;

procedure TForm1.Image1Click(Sender: TObject);
begin

end;

end.


Es kommt zwar kein Fehler aber er fällt nicht herunter?????

Ich hab noch nen bmp drangehängt, wie die form aussieht
Einloggen, um Attachments anzusehen!
Ironwulf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Fr 22.06.07 19:06 
is der timer auch an? :D
Unknown Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 184

Win XP
Delphi 7
BeitragVerfasst: Sa 23.06.07 13:04 
Natürlich :-)
Ironwulf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Sa 23.06.07 18:36 
mit dem obigen code klappt das bei mir, is der timer schnell genug ich habs mit 1000 getestet war kaum sichtbar die bewegung :D

wth?
ich seh grad das der bei mir auch nur zu 90% fällt und die restl. 10% der versuche auch nur da oben häng bleibt

mom ich glaub ich weiß worans liegt ;D

setz mal die top position von deinem image1 auf 0

oder du nimmst statt
ausblenden Delphi-Quelltext
1:
2:
3:
4:
If Image1.Canvas.Pixels[Image2.Width div 2 + Image2.Left,Image2.Height + Image2.Top] = clwhite Then//wenn der Pixel in mitte unter dem panzer kein geländer ist dann fällt er nach unten
  begin   // Fallen
    Image2.Top:= Image2.Top + 1;
  end;


oder du findest raus an welcher position des image1 sich grad das image 2 befindet und ersetzt image2.top dadmit in obigen code

sry is mir grad zu aufwendig mir die formel ausm kopf zudrückn die das macht ;)