|
Registriert seit: 11. Jan 2006 16 Beiträge Delphi 2005 Personal |
#1
ich hab noch 1 Problem + 1 Frage
Die Frage: ich wollte mal fragen ob es möglich ist einfach eine mp3-datein einzufügen die die ganze zeit im hintergrund läuft Das Problem: Ich wollte machen das mein programm einen zähler hat der die schüsse durchzählt und maximal 5 schüsse pro bildschirm hat aber er nimmt immer nur den 1. und übermalt das dann am ausgang hier mein quellcode
Delphi-Quellcode:
unit Unit1;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Menus, Buttons; type TForm1 = class(TForm) background: TImage; player: TImage; enemy1: TImage; MainMenu1: TMainMenu; Datei1: TMenuItem; Start1: TMenuItem; Beenden1: TMenuItem; Timer1: TTimer; bullet1: TImage; planet1: TImage; bullet2: TImage; bullet3: TImage; bullet4: TImage; bullet5: TImage; Timer2: TTimer; enemy2: TImage; enemy3: TImage; explosion1: TImage; Timer3: TTimer; procedure Timer3Timer(Sender: TObject); procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure Beenden1Click(Sender: TObject); procedure Start1Click(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure Timer2Timer(Sender: TObject); private { Private-Deklarationen } public { Public-Deklarationen } end; var Form1: TForm1; x,y:integer; {Schiff-X/Y Koordinaten} e,f,ee,ff:integer; {Planet-X/Y Koordinaten} c,cc,ccc,cccc,ccccc,d,dd,ddd,dddd,ddddd:integer; {Schuss-X/Y Koordinaten} a,aa,aaa,b,bb,bbb:integer; {Feinde-x/y Koordinaten} g,h,k:integer; {Explosion-x/y Koordinate} p:integer; z:boolean; implementation {$R *.dfm} procedure Schuss; begin p:=0; c:=x+50; d:=y+23; cc:=x+50; dd:=y+23; ccc:=x+50; ddd:=y+23; cccc:=x+50; dddd:=y+23; ccccc:=x+50; ddddd:=y+23; form1.bullet1.picture.loadfromfile('bullet1.bmp'); form1.bullet2.picture.loadfromfile('bullet1.bmp'); form1.bullet3.picture.loadfromfile('bullet1.bmp'); form1.bullet4.picture.loadfromfile('bullet1.bmp'); form1.bullet5.picture.loadfromfile('bullet1.bmp'); form1.bullet1.Visible:=false; form1.bullet2.Visible:=false; form1.bullet3.Visible:=false; form1.bullet4.Visible:=false; form1.bullet5.Visible:=false; form1.bullet1.Left:=c; form1.bullet1.Top:=d; form1.bullet2.Left:=cc; form1.bullet2.Top:=dd; form1.bullet3.Left:=ccc; form1.bullet3.Top:=ddd; form1.bullet4.Left:=cccc; form1.bullet4.Top:=dddd; form1.bullet5.Left:=ccccc; form1.bullet5.Top:=ddddd; end; procedure Planet; begin e:=random(250); f:=random(200); form1.planet1.Left:=e; form1.planet1.Top:=f; form1.planet1.Picture.LoadFromFile('planet5.bmp'); end; procedure Enemy; begin a:=random(300)+100; b:=random(400)+50; aa:=random(300)+100; bb:=random(400)+50; aaa:=random(300)+100; bbb:=random(400)+50; form1.enemy1.Picture.loadfromfile('enemy1.bmp'); form1.enemy2.picture.LoadFromFile('enemy1.bmp'); form1.enemy3.picture.LoadFromFile('enemy1.bmp'); form1.enemy1.left:=a; form1.enemy1.top:=b; form1.enemy2.left:=aa; form1.enemy2.top:=bb; form1.enemy3.left:=aaa; form1.enemy3.top:=bbb; end; procedure Kollision1; begin k:=0; g:=a; h:=b; form1.explosion1.left:=g; form1.explosion1.Top:=h; form1.explosion1.picture.LoadFromFile('explosion1.bmp'); form1.explosion1.Visible:=false; end; procedure Neu; begin form1.doublebuffered:=true; Enemy; Schuss; Planet; Kollision1; x:=0; y:=150; form1.background.picture.loadfromfile('space1.bmp'); form1.player.picture.loadfromfile ('player.bmp'); form1.player.Left:=x; form1.player.Top:=y; z:=true; end; procedure TForm1.Start1Click(Sender: TObject); begin Neu; end; procedure Feuern; begin c:=x+50; d:=y+23; cc:=x+50; dd:=y+23; ccc:=x+50; ddd:=y+23; cccc:=x+50; dddd:=y+23; ccccc:=x+50; ddddd:=y+23; if p=0 then begin form1.bullet1.visible:=true; p:=p+1; end; if p=1 then begin form1.bullet2.Visible:=true; p:=p+1; end; if p=2 then begin form1.bullet3.Visible:=true; p:=p+1; end; if p=3 then begin form1.bullet4.Visible:=true; p:=p+1; end; if p=4 then begin form1.bullet5.Visible:=true; p:=0; end; form1.Timer2.enabled:=true; end; procedure Kollision2; begin form1.explosion1.Visible:=true; k:=0; end; procedure Tform1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin //form1.Caption:=inttostr(key); if x=0 then begin if y=0 then begin if key=113 then Neu; if p=5 then p:=1; if key=37 then x:=x; if key=38 then y:=y; if key=39 then x:=x+5; if key=40 then y:=y+5; if key=17 then Feuern; end else begin if y=450 then begin if key=113 then Neu; if p=5 then p:=1; if key=37 then x:=x; if key=38 then y:=y-5; if key=39 then x:=x+5; if key=40 then y:=y; if key=17 then Feuern; end else begin if key=113 then Neu; if p=5 then p:=1; if key=37 then x:=x; if key=38 then y:=y-5; if key=39 then x:=x+5; if key=40 then y:=y+5; if key=17 then Feuern; end; end end else begin if y=0 then begin if key=113 then Neu; if p=5 then p:=1; if key=37 then x:=x-5; if key=38 then y:=y; if key=39 then x:=x+5; if key=40 then y:=y+5; if key=17 then Feuern; end else begin if x=450 then begin if y=450 then begin if key=113 then Neu; if p=5 then p:=1; if key=37 then x:=x-5; if key=38 then y:=y-5; if key=39 then x:=x; if key=40 then y:=y; if key=17 then Feuern; end else begin if y=0 then begin if key=113 then Neu; if p=5 then p:=1; if key=37 then x:=x-5; if key=38 then y:=y; if key=39 then x:=x; if key=40 then y:=y+5; if key=17 then Feuern; end else begin if key=113 then Neu; if p=5 then p:=1; if key=37 then x:=x-5; if key=38 then y:=y-5; if key=39 then x:=x; if key=40 then y:=y+5; if key=17 then Feuern; end end end else begin if y=450 then begin if key=113 then Neu; if p=5 then p:=1; if key=37 then x:=x-5; if key=38 then y:=y-5; if key=39 then x:=x+5; if key=40 then y:=y; if key=17 then Feuern; end else begin if key=113 then Neu; if p=5 then p:=1; if key=37 then x:=x-5; if key=38 then y:=y-5; if key=39 then x:=x+5; if key=40 then y:=y+5; if key=17 then Feuern; end; end; end; end; end; procedure Tform1.Timer1Timer(Sender: TObject); begin player.Left:=x; player.top:=y; if x=450 then x:=x+0; if y=450 then y:=y+0; //Schiff if (player.Left < (enemy1.Left+enemy1.Width)) and ((player.Left+player.Width)>enemy1.Left) and (player.Top < (enemy1.Top+enemy1.Height)) and ((player.Top+player.Height)> enemy1.Top) then begin form1.enemy1.Visible:=false; form1.player.Visible:=false; end; if (player.Left < (enemy2.Left+enemy2.Width)) and ((player.Left+player.Width)>enemy2.Left) and (player.Top < (enemy2.Top+enemy2.Height)) and ((player.Top+player.Height)> enemy2.Top) then begin form1.enemy2.Visible:=false; form1.player.Visible:=false; end; if (player.Left < (enemy3.Left+enemy3.Width)) and ((player.Left+player.Width)>enemy3.Left) and (player.Top < (enemy3.Top+enemy3.Height)) and ((player.Top+player.Height)> enemy3.Top) then begin form1.enemy3.Visible:=false; form1.player.Visible:=false; end; end; procedure TForm1.Timer2Timer(Sender: TObject); begin form1.bullet1.Left:=c; form1.bullet1.Top:=d; form1.bullet2.Left:=cc; form1.bullet2.Top:=dd; form1.bullet3.Left:=ccc; form1.bullet3.Top:=ddd; form1.bullet4.Left:=cccc; form1.bullet4.Top:=dddd; form1.bullet5.Left:=ccccc; form1.bullet5.Top:=ddddd; //Bullet 1 if c=490 then begin form1.bullet1.Visible:=false; c:=0; d:=0; end else begin if (bullet1.Left < (enemy1.Left+enemy1.Width)) and ((bullet1.Left+bullet1.Width)>enemy1.Left) and (bullet1.Top < (enemy1.Top+enemy1.Height)) and ((bullet1.Top+bullet1.Height)> enemy1.Top) then begin enemy1.Visible:=false; end; if (bullet1.Left < (enemy2.Left+enemy2.Width)) and ((bullet1.Left+bullet1.Width)>enemy2.Left) and (bullet1.Top < (enemy2.Top+enemy2.Height)) and ((bullet1.Top+bullet1.Height)> enemy2.Top) then begin enemy2.Visible:=false; end; if (bullet1.Left < (enemy3.Left+enemy3.Width)) and ((bullet1.Left+bullet1.Width)>enemy3.Left) and (bullet1.Top < (enemy3.Top+enemy3.Height)) and ((bullet1.Top+bullet1.Height)> enemy3.Top) then begin enemy3.Visible:=false; end; c:=c+5; end; //Bullet 2 if cc=490 then begin form1.bullet2.Visible:=false; c:=0; d:=0; end else begin if (bullet2.Left < (enemy1.Left+enemy1.Width)) and ((bullet2.Left+bullet2.Width)>enemy1.Left) and (bullet2.Top < (enemy1.Top+enemy1.Height)) and ((bullet2.Top+bullet2.Height)> enemy1.Top) then begin enemy1.Visible:=false; end; if (bullet2.Left < (enemy2.Left+enemy2.Width)) and ((bullet2.Left+bullet2.Width)>enemy2.Left) and (bullet2.Top < (enemy2.Top+enemy2.Height)) and ((bullet2.Top+bullet2.Height)> enemy2.Top) then begin enemy2.Visible:=false; end; if (bullet2.Left < (enemy3.Left+enemy3.Width)) and ((bullet2.Left+bullet2.Width)>enemy3.Left) and (bullet2.Top < (enemy3.Top+enemy3.Height)) and ((bullet2.Top+bullet2.Height)> enemy3.Top) then begin enemy3.Visible:=false; end; cc:=cc+5; end; //Bullet 3 if ccc=490 then begin form1.bullet3.Visible:=false; ccc:=0; ddd:=0; end else begin if (bullet3.Left < (enemy1.Left+enemy1.Width)) and ((bullet3.Left+bullet3.Width)>enemy1.Left) and (bullet3.Top < (enemy1.Top+enemy1.Height)) and ((bullet3.Top+bullet3.Height)> enemy1.Top) then begin enemy1.Visible:=false; end; if (bullet3.Left < (enemy2.Left+enemy2.Width)) and ((bullet3.Left+bullet3.Width)>enemy2.Left) and (bullet3.Top < (enemy2.Top+enemy2.Height)) and ((bullet3.Top+bullet3.Height)> enemy2.Top) then begin enemy2.Visible:=false; end; if (bullet3.Left < (enemy3.Left+enemy3.Width)) and ((bullet3.Left+bullet3.Width)>enemy3.Left) and (bullet3.Top < (enemy3.Top+enemy3.Height)) and ((bullet3.Top+bullet3.Height)> enemy3.Top) then begin enemy3.Visible:=false; end; ccc:=ccc+5; end; //Bullet 4 if cccc=490 then begin form1.bullet4.Visible:=false; cccc:=0; dddd:=0; end else begin if (bullet4.Left < (enemy1.Left+enemy1.Width)) and ((bullet4.Left+bullet4.Width)>enemy1.Left) and (bullet4.Top < (enemy1.Top+enemy1.Height)) and ((bullet4.Top+bullet4.Height)> enemy1.Top) then begin enemy1.Visible:=false; end; if (bullet4.Left < (enemy2.Left+enemy2.Width)) and ((bullet4.Left+bullet4.Width)>enemy2.Left) and (bullet4.Top < (enemy2.Top+enemy2.Height)) and ((bullet4.Top+bullet4.Height)> enemy2.Top) then begin enemy2.Visible:=false; end; if (bullet4.Left < (enemy3.Left+enemy3.Width)) and ((bullet4.Left+bullet4.Width)>enemy3.Left) and (bullet4.Top < (enemy3.Top+enemy3.Height)) and ((bullet4.Top+bullet4.Height)> enemy3.Top) then begin enemy3.Visible:=false; end; cccc:=cccc+5; end; //Bullet 5 if ccccc=490 then begin form1.bullet5.Visible:=false; ccccc:=0; ddddd:=0; end else begin if (bullet5.Left < (enemy1.Left+enemy1.Width)) and ((bullet5.Left+bullet5.Width)>enemy1.Left) and (bullet5.Top < (enemy1.Top+enemy1.Height)) and ((bullet5.Top+bullet5.Height)> enemy1.Top) then begin enemy1.Visible:=false; end; if (bullet5.Left < (enemy2.Left+enemy2.Width)) and ((bullet5.Left+bullet5.Width)>enemy2.Left) and (bullet5.Top < (enemy2.Top+enemy2.Height)) and ((bullet5.Top+bullet5.Height)> enemy2.Top) then begin enemy2.Visible:=false; end; if (bullet5.Left < (enemy3.Left+enemy3.Width)) and ((bullet5.Left+bullet5.Width)>enemy3.Left) and (bullet5.Top < (enemy3.Top+enemy3.Height)) and ((bullet5.Top+bullet5.Height)> enemy3.Top) then begin enemy3.Visible:=false; end; ccccc:=ccccc+5; end; end; procedure TForm1.Timer3Timer(Sender: TObject); begin form1.enemy1.left:=a; form1.enemy1.top:=b; form1.enemy2.left:=aa; form1.enemy2.top:=bb; form1.enemy3.left:=aaa; form1.enemy3.top:=bbb; a:=a-5; aa:=aa-5; aaa:=aaa-5; end; procedure TForm1.Beenden1Click(Sender: TObject); begin close; end; end. |
![]() |
Ansicht |
![]() |
![]() |
![]() |
ForumregelnEs ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.
BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus. Trackbacks are an
Pingbacks are an
Refbacks are aus
|
|
Nützliche Links |
Heutige Beiträge |
Sitemap |
Suchen |
Code-Library |
Wer ist online |
Alle Foren als gelesen markieren |
Gehe zu... |
LinkBack |
![]() |
![]() |