Anonymní profil Hano – Programujte.com
 x   TIP: Přetáhni ikonu na hlavní panel pro připnutí webu

Anonymní profil Hano – Programujte.comAnonymní profil Hano – Programujte.com

 

Příspěvky odeslané z IP adresy 77.234.254.–

Hano
Pascal › Zaverečná práca
3. 4. 2012   #155962

Aha hej mate pravdu s tym a1, neviem preco ma to tak napadlo 

A:=a-3-- odcitaval som to preto lebo mi to najprv pracovalo tak ze som mal napr strely v poli 1 2 3 a potom ked presiahli 810 nove strely som mal v poli  2 3 4 dalsie 3 4 5 a stale sa mi to takto zvysovalo, potom som to prerobil a nevedomky som vam poslal to stare    Momentalne mi to funguje tak ze ide to krasne, len niektore strely sa zaseknu v polovice cesty a ostanu tak nakreslene, nezmazu sa.

Myslim ze toto je najdolezitejsia cast a princip programu. Medzitym je iba menu a ze vsetkym lodiam priradim zivot.

Deklaracia:

    A,B,c,D,f,y,x,i,w,y1,x1,x2,w1,I1,R,R1,B1,Y2,S,Z1,h: integer;
    GD,GM: smallint;
    K: char;
    pole: array[1..8] of integer;
    pola: array[1..5] of integer;
    zivot: array[1..10,1..10] of integer;
    strelax: array [1..200] of integer;
    strelay: array [1..200] of integer;
    zivots: array [1..200] of integer;
    label L;
    label L1;
    label L2;
    label L3;
    label M;
    label reset;
    label E;

______________

menu

______________

Y1:=790;  
F:=0;
Z1:=0;
w1:=100;
X1:=500;
w:=500;
h:=1;
a:=1;
a1:=1;
c:=1;
h1:=1;

__________

priradenie zivot lodiam
zivot[i1,i]=1

__________

while X<1200 do
                     begin
                          L:while not(keypressed) and (X<1200) do
                          begin
                          setcolor(15);
                          y:=W1;
                                for I1:=1 to 5 do {kreslim lode}
                                begin
                                x:=w;
                                     for I:=1 to 8 do
                                     begin
                                          if zivot[i1,i]=1 then
                                          begin
                                          setcolor(15);
                                          circle(X,Y,10);
                                          pole[i]:=x;
                                          pola[i1]:=y;
                                          X:=x+70;
                                          end;
                                          if zivot[i1,i]=0 then
                                          begin
                                          setcolor(0);
                                          circle(X,Y,10);
                                          X:=x+70;
                                          setcolor(15);
                                          end;
                                     end;
                                Y:=y+30;
                                end;
                                    if Z1<3 then
                                    begin
                                         if C=0 then
                                         begin
                                         a:=h;
                                         c:=1;
                                         end;
                                    I:=random(8)+1;
                                    I1:=random(5)+1;
                                                    if zivot[i1,i]= 1 then
                                                    begin
                                                    strelax[a]:=pole[i];
                                                    strelay[a]:=pola[i1];
                                                    zivots[a]:=1;
                                                    Z1:=Z1+1;
                                                    a:=a+1;
                                                    end;
                                    end;
                                         for a:=1 to 3 do
                                         begin
                                               setcolor(0);
                                               line(strelax[a],strelay[a],strelax[a],strelay[a]+19);
                                               strelay[a]:=strelay[a]+19;
                                               setcolor(15);
                                               line(strelax[a],strelay[a],strelax[a],strelay[a]+19);
                                                                      if strelay[a]>810 then
                                                                      begin
                                                                             if (strelax[a]>x1-13) and (strelax[a]<x1+13) then
                                                                             begin
                                                                             setcolor(15);
                                                                             outtextxy(560,460,'BOOOOOOOOOOOOOOOOOOOOM');
                                                                             goto E; {koniec hry}
                                                                             end;
                                                                      setcolor(0);
                                                                      line(strelax[a],strelay[a],strelax[a],strelay[a]+19);
                                                                      zivots[a]:=0;
                                                                                   if zivots[a]=0 then
                                                                                   begin
                                                                                   C:=0;
                                                                                   h:=a; {ulozim si do H cislo strely ktora presla nad 810}
                                                                                   end;
                                                                      Z1:=Z1-1;
                                                                      end;
                                         end;
                          Y:=W1;
                                for I1:=1 to 5 do {mazem lode}
                                begin
                                x:=w;
                                     for I:=1 to 8 do
                                     begin
                                     setcolor(0);
                                     circle(X,Y,10);
                                     X:=x+70;
                                     end;
                                Y:=y+30;
                                end;
                          setcolor(15);
                          w:=w+1;
                          end;
                          setcolor(15);

V tomto cykle je este case(sipka dolava,doprava a strelba) + while X>1050( v nom sa robi to iste len ze tie lode nejdu do prava ale vracaju sa naspät pricom su posunute o jeden riadok nizsie. +cele je to este v jednom velkom cykle repeat, aby to zase islo do prava, a potom sa to vracalo, a zase do prava a naspät, a zase do prava...

Ospravedlnujem sa ze to nieje este take priehladne, zatial je to iba vo fazy vyskum a rozvoj    , neskor to dam do procedur ak budem mat cas. Popripade mozem poslat uplne cely program, ulozit ho niekde na uloz.to, ak by to nestacilo.

PS: upozornujem ze mam zivot[i1,i]=zivot lodi  a zivots[i1,i]= zivot striel.

Pascal › Zaverečná práca
2. 4. 2012   #155911

Zdravim

ako zaverecnu pracu z pascalu som si vybral znamu hru "space invaders" .. vsetko funguje tak ako ma az na jeden problem a tym je strielanie nepriatelov proti mne(hracovi).

Chcel by som aby proti mne vzdy boli vystrelene 3 strely z nahodne vybrat nepriatelskej lode, ked jedna strela ma netrafi tak nech sa zjavy dalsia, a tak dalej az do konca.

Da sa to spravit tak ze najprv si nahodne vyberem tri nepriatelske lode, cislo strely ktora prva minie moju lod ulozim do premennej H, a kontrolujem ak sa pocet striel znizil priradim novu lod odkial pojde strela?

Z1=pocet striel
a=x-ova suradnica strely
a1=y-ova suradnica strely
zivots[a]= zivot strely 1. alebo 2. alebo 3.
E=label.. end game

while Z1<3 do-- vzdy chcem aby isli proti mne 3 nepriatelske strely
begin
I:=random(8)+1; --nahodne mi vybere x-ovu suradnicu lode z ktorej pojde strela
I1:=random(5)+1;---nahodne mi vybere y-ovu suradnicu lode z ktorej pojde strela
strelax[a]:=pole[i];-- do strelax[a] ulozim x-ovu hodnotu lode(napr 350)
strelay[a1]:=pola[i1];--do strelax[a] ulozim y-ovu hodnotu lode(napr 280)
zivots[a]:=1;-- pridelim zivot strele
Z1:=Z1+1;
a:=a+1;
a1:=a1+1;
end;

a:=a-3;
a1:=a1-3;
for I:=1 to 3 do--3x lebo mam 3 strely
begin
setcolor(0);
line(strelax[a],strelay[a1],strelax[a],strelay[a1]+19);
strelay[a1]:=strelay[a1]+19;-- dlzka tej strely, ma 19
setcolor(15);
line(strelax[a],strelay[a1],strelax[a],strelay[a1]+19);
if strelay[a1]>810 then--ak prejde za hranicu tak ju vymazem a pridelim jej zivot 0 a zmazem ju
begin
setcolor(0); line(strelax[a],strelay[a1],strelax[a],strelay[a1]+19);
zivots[a]:=0;
Z1:=Z1-1;
end;
a:=a+1;
a1:=a1+1;
end;

dufam ze chapete... niekde je chyba s timi "ackami" podla mna, lebo funguje mi to tak ze vystreli tri nepriatelske strely ale ked prejde y-ova hodnota jednej zo striel nad 810 tak iba tu strelu ktora presla vymaze a ostatne nevymazu a zastanu, nikdy nedostanu hodnotu 810 .. ale niekdy vsetky tri prejdu normalne tak ako by to malo ist, nechapem tomu    som zvedavy vy nato :D :D :D ak nechapete napiste, skusim to inak vysvetlit 

Vdaka

 

 

Hostujeme u Českého hostingu       ISSN 1801-1586       ⇡ Nahoru Webtea.cz logo © 20032024 Programujte.com
Zasadilo a pěstuje Webtea.cz, šéfredaktor Lukáš Churý