![]() |
Wyjście Spis treści Poprzedni Następny
Autor: mgr Jerzy Wałaszek, wersja 3.0 |
©2008 mgr
Jerzy Wałaszek
|
| W tym rozdziale: | Podrozdziały: |
Prezentowane poniżej programy utworzono w następujących środowiskach programowania:
Jeśli stosujesz inne środowiska, to prawdopodobnie będziesz musiał przetworzyć odpowiednio kod programów.
Na podstawie opisanego algorytmu tworzymy program w języku Pascal. Poniżej przedstawiamy przykładowe zrzuty zawartości okienka konsoli oraz kod źródłowy programu.
![]() Strona tytułowa gry |
|---|
![]() Przykładowa rozgrywka |
// B O M B O W I E C
// WERSJA PROCEDURALNA
//--------------------------------------------
// (C)2004 mgr Jerzy Wałaszek I LO w Tarnowie
program Bombowiec;
uses Crt;
//----------------------------------------------------
// PROCEDURY I FUNKCJE POMOCNICZE
//----------------------------------------------------
// Funkcja PL konwertuje tekst ze standardu Windows 1250
// na standard konsoli znakowej Latin II
//------------------------------------------------------
function PL(s : string) : string;
var
i : integer;
c : char;
begin
for i := 1 to length(s) do
begin
case s[i] of
'ą' : c := #165;
'ć' : c := #134;
'ę' : c := #169;
'ł' : c := #136;
'ń' : c := #228;
'ó' : c := #162;
'ś' : c := #152;
'ż' : c := #190;
'ź' : c := #171;
'Ą' : c := #164;
'Ć' : c := #143;
'Ę' : c := #168;
'Ł' : c := #157;
'Ń' : c := #227;
'Ó' : c := #224;
'Ś' : c := #151;
'Ż' : c := #189;
'Ź' : c := #141;
else
c := s[i];
end;
s[i] := c;
end;
Result := s;
end;
// Procedura centruje w bieżącym wierszu
// tekst podany jako parametr
//----------------------------------------------------
procedure Centruj(t : string);
begin
GotoXY(1 + (80-length(t)) div 2, WhereY);
writeln(t);
end;
// Procedura rysuje pojedynczą ramkę ze znaków
// tabelek. Parametry określają współrzędne
// lewego górnego i prawego dolnego narożnika
//----------------------------------------------------
procedure Ramka(xp,yp,xk,yk : integer);
var
i : integer;
begin
GotoXY(xp,yp); write(#218);
GotoXY(xp,yk); write(#192);
GotoXY(xk,yp); write(#191);
GotoXY(xk,yk); write(#217);
for i := xp + 1 to xk - 1 do
begin
GotoXY(i,yp); write(#196);
GotoXY(i,yk); write(#196);
end;
for i := yp + 1 to yk - 1 do
begin
GotoXY(xp,i); write(#179);
GotoXY(xk,i); write(#179);
end;
end;
//------------------------------------------------------
// PROGRAM GRY
//------------------------------------------------------
var
miasto : array[1..80] of integer;
bx,by,oby,sx,sy,ox,oy : integer;
// Procedura wyświetla stronę tytułową, czeka na dowolny
// klawisz i czyści ekran
//------------------------------------------------------
procedure StronaTytulowa;
begin
TextAttr := $07; ClrScr;
GotoXY(1,4);
TextAttr := $5e;
Centruj(PL(' '));
Centruj(PL(' B O M B O W I E C '));
Centruj(PL(' ===================== '));
Centruj(PL(' '));
TextAttr := $1f;
Centruj(PL(' '));
Centruj(PL(' (C)2004 mgr Jerzy Wałaszek '));
Centruj(PL(' '));
TextAttr := $2e;
Centruj(PL(' '));
Centruj(PL(' I Liceum Ogólnokształcące '));
Centruj(PL(' im. Kazimierza Brodzińskiego '));
Centruj(PL(' w Tarnowie '));
Centruj(PL(' '));
TextAttr := $f0;
Centruj(PL(' '));
Centruj(PL(' Przygotuj się na bombardowanie...'));
Centruj(PL(' '));
TextAttr := $f4;
Centruj(PL(' Gdy będziesz gotowy, '));
Centruj(PL(' naciśnij dowolny klawisz '));
Centruj(PL(' '));
TextAttr := $0e; Ramka(23,3,58,22);
while ReadKey = #0 do; // Oczekiwanie na dowolny klawisz
TextAttr := $07; ClrScr;
end;
// Procedura inicjuje zmienne i wyświetla miasto
//----------------------------------------------------
procedure Inicjalizacja;
var
i,j : integer;
begin
TextAttr := $b0; ClrScr; // tło nieba
TextAttr := $1e; //granatowe domy
for i := 1 to 80 do
begin
if (i >= 6) and (i <= 75) then
begin
miasto[i] := 1 + random(10);
for j := 1 to miasto[i] do
begin
GotoXY(i,26-j); write('-');
end;
end
else miasto[i] := 0;
end;
by := 0; oby := 0; sx := 1; ox := 1; sy := 25; oy := 25;
end;
// Procedura obsługuje ruch bombowca
//----------------------------------------------------
procedure LotBombowca;
begin
inc(sx);
if(sx > 80) then
begin
sx := 1; dec(sy);
end;
GotoXY(ox,26-oy); TextAttr := $b0; write(' ');
GotoXY(sx,26-sy); write('>');
ox := sx; oy := sy;
end;
// Procedura sprawdza, czy naciśnięto klawisz spacji.
// Jeśli tak i żadna bomba nie jest w locie, to
// inicjuje zrzut nowej bomby.
//---------------------------------------------------
procedure ZrzutBomb;
var
c : char;
begin
if KeyPressed then
begin
repeat
c := ReadKey;
until c <> #0;
if (c = ' ') and (by = 0) then
begin
bx := sx; by := sy; oby := by - 1;
end;
end;
end;
// Procedura obsługuje lot bomby.
//----------------------------------------------------
procedure LotBomby;
begin
if by > 0 then
begin
TextAttr := $b0; GotoXY(bx,26-oby); write(' ');
dec(by); oby := by;
if miasto[bx] >= by then
begin
miasto[bx] := by;
TextAttr := $ce;
end;
if by > 0 then
begin
GotoXY(bx,26-by); write('*');
end;
end;
end;
// Funkcja zwraca true, jeśli miasto zostało zniszczone
// lub samolot uderzył w dom. Obsługuje napisy końcowe.
//----------------------------------------------------
function KoniecObiegu : boolean;
var
i,t : integer;
begin
Result := false;
if sy = miasto[sx] then
begin
TextAttr := $ce; GotoXY(sx,26-sy); write('#');
TextAttr := $b4; write(' KRACH!');
TextAttr := $1f; GotoXY(1,6); Centruj(PL(' GRA SKOŃCZONA '));
Result := true;
end
else
begin
t := 0;
for i := 6 to 75 do t := t + miasto[i];
if t = 0 then
begin
TextAttr := $1e; GotoXY(1,6); Centruj(' GRATULACJE! ');
Result := true;
end;
end;
end;
// Funkcja zwraca true, jeśli gracz nie ma ochoty na
// kolejną rozgrywkę.
//------------------------------------------------------
function KoniecGry : boolean;
begin
GotoXY(1,2); TextAttr := $4e;
Centruj(' ');
Centruj(' Jeszcze raz ? [T] = Tak, [Inny] = Nie ');
Centruj(' ');
Result := UpCase(ReadKey) <> 'T';
end;
var
a : integer;
begin
Randomize; CursorOff; a := TextAttr;
repeat
StronaTytulowa;
Inicjalizacja;
repeat
LotBombowca;
ZrzutBomb;
LotBomby;
Delay(100);
until KoniecObiegu;
until KoniecGry;
TextAttr := a; CursorOn; ClrScr;
end. |
// B O M B O W I E C
// WERSJA OBIEKTOWA
//--------------------------------------------
// (C)2004 mgr Jerzy Wałaszek I LO w Tarnowie
program Bombowiec;
uses Crt;
//----------------------------------------------------
// PROCEDURY I FUNKCJE POMOCNICZE
//----------------------------------------------------
// Funkcja PL konwertuje tekst ze standardu Windows 1250
// na standard konsoli znakowej Latin II
//------------------------------------------------------
function PL(s : string) : string;
var
i : integer;
c : char;
begin
for i := 1 to length(s) do
begin
case s[i] of
'ą' : c := #165;
'ć' : c := #134;
'ę' : c := #169;
'ł' : c := #136;
'ń' : c := #228;
'ó' : c := #162;
'ś' : c := #152;
'ż' : c := #190;
'ź' : c := #171;
'Ą' : c := #164;
'Ć' : c := #143;
'Ę' : c := #168;
'Ł' : c := #157;
'Ń' : c := #227;
'Ó' : c := #224;
'Ś' : c := #151;
'Ż' : c := #189;
'Ź' : c := #141;
else
c := s[i];
end;
s[i] := c;
end;
Result := s;
end;
// Procedura centruje w bieżącym wierszu
// tekst podany jako parametr
//----------------------------------------------------
procedure Centruj(t : string);
begin
GotoXY(1 + (80-length(t)) div 2, WhereY);
writeln(t);
end;
// Procedura rysuje pojedynczą ramkę ze znaków
// tabelek. Parametry określają współrzędne
// lewego górnego i prawego dolnego narożnika
//----------------------------------------------------
procedure Ramka(xp,yp,xk,yk : integer);
var
i : integer;
begin
GotoXY(xp,yp); write(#218);
GotoXY(xp,yk); write(#192);
GotoXY(xk,yp); write(#191);
GotoXY(xk,yk); write(#217);
for i := xp + 1 to xk - 1 do
begin
GotoXY(i,yp); write(#196);
GotoXY(i,yk); write(#196);
end;
for i := yp + 1 to yk - 1 do
begin
GotoXY(xp,i); write(#179);
GotoXY(xk,i); write(#179);
end;
end;
//------------------------------------------------------
// PROGRAM GRY
//------------------------------------------------------
// Definicje klas
//------------------------------------------------------
type
TMiasto = class
public
domy : array[1..80] of integer;
constructor Utworz;
procedure Inicjuj;
function Koniec(x,y : integer) : boolean;
end;
TBomba = class
private
oby : integer;
public
bx,by : integer;
constructor Utworz;
procedure Inicjuj;
procedure ZrzutBomb(x,y : integer);
procedure LotBomby(var y : integer);
end;
TSamolot = class
private
ox,oy : integer;
public
sx,sy : integer;
constructor Utworz;
procedure Inicjuj;
procedure LotBombowca;
end;
TGra = class
private
miasto : TMiasto;
bomba : TBomba;
samolot : TSamolot;
a : integer;
procedure StronaTytulowa;
public
constructor Utworz;
procedure Inicjuj;
procedure Uruchom;
function Koniec : boolean;
end;
// Definicje metod obiektowych
//------------------------------------------------------
constructor TMiasto.Utworz;
begin
// Tylko działanie podstawowe
end;
procedure TMiasto.Inicjuj;
var
i,j : integer;
begin
TextAttr := $b0; ClrScr; // tło nieba
TextAttr := $1e; //granatowe domy
for i := 1 to 80 do
begin
if (i >= 6) and (i <= 75) then
begin
domy[i] := 1 + random(10);
for j := 1 to domy[i] do
begin
GotoXY(i,26-j); write('-');
end;
end
else domy[i] := 0;
end;
end;
function TMiasto.Koniec(x,y : integer) : boolean;
var
i,t : integer;
begin
Result := false;
if y = domy[x] then
begin
TextAttr := $ce; GotoXY(x,26-y); write('#');
TextAttr := $b4; write(' KRACH!');
TextAttr := $1f; GotoXY(1,6); Centruj(PL(' GRA SKOŃCZONA '));
Result := true;
end
else
begin
t := 0;
for i := 6 to 75 do t := t + domy[i];
if t = 0 then
begin
TextAttr := $1e; GotoXY(1,6); Centruj(' GRATULACJE! ');
Result := true;
end;
end;
end;
//------------------------------------------------------
constructor TBomba.Utworz;
begin
// Tylko działanie podstawowe
end;
procedure TBomba.Inicjuj;
begin
bx := 1; by := 0; oby := 0
end;
procedure TBomba.ZrzutBomb(x,y : integer);
var
c : char;
begin
if KeyPressed then
begin
repeat
c := ReadKey;
until c <> #0;
if (c = ' ') and (by = 0) then
begin
bx := x; by := y; oby := by - 1;
end;
end;
end;
procedure TBomba.LotBomby(var y : integer);
begin
if by > 0 then
begin
TextAttr := $b0; GotoXY(bx,26-oby); write(' ');
dec(by); oby := by;
if y >= by then
begin
y := by;
TextAttr := $ce;
end;
if by > 0 then
begin
GotoXY(bx,26-by); write('*');
end;
end;
end;
//------------------------------------------------------
constructor TSamolot.Utworz;
begin
// Tylko działanie podstawowe
end;
procedure TSamolot.Inicjuj;
begin
sx := 1; ox := 1; sy := 25; oy := 25
end;
procedure TSamolot.LotBombowca;
begin
inc(sx);
if sx > 80 then
begin
sx := 1; dec(sy);
end;
GotoXY(ox,26-oy); TextAttr := $b0; write(' ');
GotoXY(sx,26-sy); write('>');
ox := sx; oy := sy;
end;
//------------------------------------------------------
constructor TGra.Utworz;
begin
randomize; a := TextAttr; CursorOff;
miasto := TMiasto.Utworz;
bomba := TBomba.Utworz;
samolot := TSamolot.Utworz;
end;
procedure TGra.StronaTytulowa;
begin
TextAttr := $07; ClrScr;
GotoXY(1,4);
TextAttr := $5e;
Centruj(PL(' '));
Centruj(PL(' B O M B O W I E C '));
Centruj(PL(' ===================== '));
Centruj(PL(' '));
TextAttr := $1f;
Centruj(PL(' '));
Centruj(PL(' (C)2004 mgr Jerzy Wałaszek '));
Centruj(PL(' '));
TextAttr := $2e;
Centruj(PL(' '));
Centruj(PL(' I Liceum Ogólnokształcące '));
Centruj(PL(' im. Kazimierza Brodzińskiego '));
Centruj(PL(' w Tarnowie '));
Centruj(PL(' '));
TextAttr := $f0;
Centruj(PL(' '));
Centruj(PL(' Przygotuj się na bombardowanie...'));
Centruj(PL(' '));
TextAttr := $f4;
Centruj(PL(' Gdy będziesz gotowy, '));
Centruj(PL(' naciśnij dowolny klawisz '));
Centruj(PL(' '));
TextAttr := $0e; Ramka(23,3,58,22);
while ReadKey = #0 do; // Oczekiwanie na dowolny klawisz
TextAttr := $07; ClrScr;
end;
procedure TGra.Inicjuj;
begin
StronaTytulowa;
miasto.Inicjuj;
samolot.Inicjuj;
bomba.Inicjuj;
end;
procedure TGra.Uruchom;
begin
repeat
samolot.LotBombowca;
bomba.ZrzutBomb(samolot.sx,samolot.sy);
bomba.LotBomby(miasto.domy[bomba.bx]);
delay(100);
until miasto.Koniec(samolot.sx,samolot.sy);
end;
function TGra.Koniec : boolean;
begin
GotoXY(1,2); TextAttr := $4e;
Centruj(' ');
Centruj(' Jeszcze raz ? [T] = Tak, [Inny] = Nie ');
Centruj(' ');
Result := UpCase(ReadKey) <> 'T';
end;
//------------------------------------------------------
// Blok główny programu
//------------------------------------------------------
var
gra : TGra;
begin
gra := TGra.Utworz;
repeat
gra.Inicjuj;
gra.Uruchom;
until gra.Koniec
end. |
Program uruchomiono w środowisku Dev-C++.
// B O M B O W I E C
//--------------------------------------------
// (C)2004 mgr Jerzy Wałaszek I LO w Tarnowie
#include <conio.h>
#include <windows.h>
#include <strings.h>
#include <iostream>
using namespace std;
//----------------------------------------------------
// Deklaracja klasy gry
//----------------------------------------------------
class TMiasto
{
public:
int domy[81];
void Inicjuj();
int Koniec(int x, int y);
};
class TBomba
{
int oby;
public:
int bx,by;
void Inicjuj();
void ZrzutBomb(int x, int y);
void LotBomby(int * y);
};
class TSamolot
{
int ox,oy;
public:
int sx,sy;
void Inicjuj();
void LotBombowca();
};
class TGra
{
TMiasto miasto;
TBomba bomba;
TSamolot samolot;
int a;
void StronaTytulowa();
public:
void Inicjuj();
void Uruchom();
int Koniec();
};
//----------------------------------------------------
// PROCEDURY I FUNKCJE POMOCNICZE
//----------------------------------------------------
const int BLACK = 0;
const int BLUE = 1;
const int GREEN = 2;
const int CYAN = 3;
const int RED = 4;
const int MAGENTA = 5;
const int BROWN = 6;
const int LIGHTGRAY = 7;
const int DARKGRAY = 8;
const int LIGHTBLUE = 9;
const int LIGHTGREEN = 10;
const int LIGHTCYAN = 11;
const int LIGHTRED = 12;
const int LIGHTMAGENTA = 13;
const int YELLOW = 14;
const int WHITE = 15;
static int __BACKGROUND = BLACK;
static int __FOREGROUND = LIGHTGRAY;
// Procedura ustawia pozycję wydruku w oknie konsoli
//----------------------------------------------------
void gotoxy(int x, int y)
{
COORD c;
c.X = x - 1;
c.Y = y - 1;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);
}
// Procedura ustawia kolor tła wydruku
//----------------------------------------------------
void textbackground(int color)
{
__BACKGROUND = color;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
__FOREGROUND + (color << 4));
}
// Procedura ustawia kolor tekstu
//----------------------------------------------------
void textcolor(int color)
{
__FOREGROUND = color;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
color + (__BACKGROUND << 4));
}
// Procedura ustawia atrybuty koloru tekstu i tła
//----------------------------------------------------
void textattr(int _attr)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), _attr);
}
// Funkcja zwraca aktualną pozycję x kursora
//----------------------------------------------------
int wherex()
{
CONSOLE_SCREEN_BUFFER_INFO info;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info);
return info.dwCursorPosition.X + 1;
}
// Funkcja zwraca aktualną pozycję y kursora
//----------------------------------------------------
int wherey()
{
CONSOLE_SCREEN_BUFFER_INFO info;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info);
return info.dwCursorPosition.Y + 1;
}
// Procedura czyści zawartość okna konsoli
//----------------------------------------------------
void clrscr()
{
DWORD written;
FillConsoleOutputAttribute(GetStdHandle (STD_OUTPUT_HANDLE),
__FOREGROUND + (__BACKGROUND << 4), 2000, (COORD){0, 0}, &written);
FillConsoleOutputCharacter(GetStdHandle(STD_OUTPUT_HANDLE), ' ',
2000, (COORD){0, 0}, &written);
gotoxy(1, 1);
}
// Procedura ukrywa kursor okienka konsoli
//------------------------------------------------------
void CursorOff()
{
CONSOLE_CURSOR_INFO Info;
GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &Info);
Info.bVisible = 0;
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &Info);
};
// Procedura przywraca kursor okienka konsoli
//------------------------------------------------------
void CursorOn()
{
CONSOLE_CURSOR_INFO Info;
GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &Info);
Info.bVisible = -1;
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &Info);
};
// Funkcja PL konwertuje tekst ze standardu Windows 1250
// na standard konsoli znakowej Latin II
//------------------------------------------------------
string PL(string s)
{
int i;
char c;
for(i = 0; i < s.length(); i++)
{
switch(s[i])
{
case 'ą' : c = char(165); break;
case 'ć' : c = char(134); break;
case 'ę' : c = char(169); break;
case 'ł' : c = char(136); break;
case 'ń' : c = char(228); break;
case 'ó' : c = char(162); break;
case 'ś' : c = char(152); break;
case 'ż' : c = char(190); break;
case 'ź' : c = char(171); break;
case 'Ą' : c = char(164); break;
case 'Ć' : c = char(143); break;
case 'Ę' : c = char(168); break;
case 'Ł' : c = char(157); break;
case 'Ń' : c = char(227); break;
case 'Ó' : c = char(224); break;
case 'Ś' : c = char(151); break;
case 'Ż' : c = char(189); break;
case 'Ź' : c = char(141); break;
default: c = s[i];
};
s[i] = c;
};
return(s);
}
// Procedura centruje w bieżącym wierszu
// tekst podany jako parametr
//----------------------------------------------------
void Centruj(string t)
{
gotoxy(1 + (80 - t.length()) / 2, wherey());
cout << t << endl;
}
// Procedura rysuje pojedynczą ramkę ze znaków
// tabelek. Parametry określają współrzędne
// lewego górnego i prawego dolnego narożnika
//----------------------------------------------------
void Ramka(int xp,int yp,int xk,int yk)
{
int i;
gotoxy(xp,yp); putch(char(218));
gotoxy(xp,yk); putch(char(192));
gotoxy(xk,yp); putch(char(191));
gotoxy(xk,yk); putch(char(217));
for(i = xp + 1; i <= xk - 1; i++)
{
gotoxy(i,yp); putch(char(196));
gotoxy(i,yk); putch(char(196));
};
for(i = yp + 1; i <= yk - 1; i++)
{
gotoxy(xp,i); putch(char(179));
gotoxy(xk,i); putch(char(179));
};
}
// Procedura wprowadza opóźnienie
// o zadaną ilość milisekund
//----------------------------------------------------
void Delay(int d)
{
long start;
start = GetTickCount();
while((GetTickCount() - start) < d);
}
//----------------------------------------------------
// Definicje metod klas
//----------------------------------------------------
void TMiasto::Inicjuj()
{
int i,j;
textbackground(0xb); clrscr(); // tło nieba
textattr(0x1e); //granatowe domy
for(i = 1; i <= 80; i++)
{
if((i >= 6) && (i <= 75))
{
domy[i] = 1 + rand() % 10;
for(j = 1; j <= domy[i]; j++)
{
gotoxy(i,26-j); cout << "-";
};
}
else domy[i] = 0;
};
}
int TMiasto::Koniec(int x, int y)
{
int i,t;
if(y == domy[x])
{
textattr(0xce); gotoxy(x,26-y); cout << "#";
textattr(0xb4); cout << " KRACH!";
textattr(0x1f); gotoxy(1,6); Centruj(PL(" GRA SKOŃCZONA "));
return(true);
}
else
{
t = 0;
for(i = 6; i <= 75; t = t + domy[i++]);
if(t == 0)
{
textattr(0x1e); gotoxy(1,6); Centruj(" GRATULACJE! ");
return(true);
};
};
return(false);
}
//------------------------------------------------------
void TBomba::Inicjuj()
{
bx = 1; by = oby = 0;
}
void TBomba::ZrzutBomb(int x, int y)
{
char c;
if(kbhit())
{
while(!(c = getch())) ;
if((c == ' ') && !by)
{
bx = x; by = y; oby = by - 1;
};
};
}
void TBomba::LotBomby(int * y)
{
if(by)
{
textattr(0xb0); gotoxy(bx,26-oby); cout << " ";
oby = --by;
if(*y > by)
{
*y = by; textattr(0xce);
};
if(by)
{
gotoxy(bx,26-by); cout << "*";
};
};
}
//------------------------------------------------------
void TSamolot::Inicjuj()
{
sx = ox = 1; sy = oy = 25;
}
void TSamolot::LotBombowca()
{
if(++sx > 80)
{
sx = 1; --sy;
};
gotoxy(ox,26-oy); textattr(0xb0); cout << " ";
gotoxy(sx,26-sy); cout << ">";
ox = sx; oy = sy;
}
//------------------------------------------------------
void TGra::StronaTytulowa()
{
textbackground(0); clrscr();
gotoxy(1,4); textattr(0x5e);
Centruj(PL(" "));
Centruj(PL(" B O M B O W I E C "));
Centruj(PL(" ===================== "));
Centruj(PL(" "));
textattr(0x1f);
Centruj(PL(" "));
Centruj(PL(" (C)2004 mgr Jerzy Wałaszek "));
Centruj(PL(" "));
textattr(0x2e);
Centruj(PL(" "));
Centruj(PL(" I Liceum Ogólnokształcące "));
Centruj(PL(" im. Kazimierza Brodzińskiego "));
Centruj(PL(" w Tarnowie "));
Centruj(PL(" "));
textattr(0xf0);
Centruj(PL(" "));
Centruj(PL(" Przygotuj się na bombardowanie..."));
Centruj(PL(" "));
textattr(0xf4);
Centruj(PL(" Gdy będziesz gotowy, "));
Centruj(PL(" naciśnij dowolny klawisz "));
Centruj(PL(" "));
textattr(0x0e); Ramka(23,3,58,22);
while(getch() == 0); // Oczekiwanie na dowolny klawisz
textattr(0x07); clrscr();
}
void TGra::Inicjuj()
{
StronaTytulowa();
miasto.Inicjuj();
samolot.Inicjuj();
bomba.Inicjuj();
}
void TGra::Uruchom()
{
do
{
samolot.LotBombowca();
bomba.ZrzutBomb(samolot.sx,samolot.sy);
bomba.LotBomby(&miasto.domy[bomba.bx]);
Delay(100);
} while(!miasto.Koniec(samolot.sx,samolot.sy));
}
int TGra::Koniec()
{
gotoxy(1,2); textattr(0x4e);
Centruj(" ");
Centruj(" Jeszcze raz ? [T] = Tak, [Inny] = Nie ");
Centruj(" ");
return(toupper(getch()) != 'T');
}
int main()
{
TGra gra;
srand((unsigned)time(NULL));
CursorOff();
do
{
gra.Inicjuj();
gra.Uruchom();
} while(!gra.Koniec());
CursorOn(); textbackground(0); textcolor(7); clrscr();
return(0);
} |
![]() | I Liceum Ogólnokształcące |
Pytania proszę przesyłać na adres email: i-lo@eduinf.waw.pl
W artykułach serwisu są używane cookies. Jeśli nie chcesz ich otrzymywać,
zablokuj je w swojej przeglądarce.
Informacje dodatkowe