Показать сообщение отдельно
Старый 17.04.2011, 21:44   #2 (permalink)
FPS
Member
 
Регистрация: 11.11.2010
Сообщений: 17
Сказал(а) спасибо: 0
Поблагодарили 0 раз(а) в 0 сообщениях
Репутация: 10
По умолчанию

Забыл про подключаемый модуль "monsters", в нём менять ничего не надо, вот его код
Цитата:
unit monsters;
interface
uses graph,crt;

type monstr = object
constructor init(x_, y_, health_, ammo_ : word);
procedure attack ; virtual ;
procedure draw ; virtual ;
procedure erase ; virtual ;
procedure hit;
procedure move(x_,y_: word) ;
function drag :boolean;virtual;
private
x, y : word; health, ammo : word; color : word;
end;
daemon = object (monstr)
constructor init(x_, y_, health_, ammo_ ,magic_: word);
procedure attack ; virtual ;
procedure draw ; virtual ;
procedure erase ; virtual ;
procedure wizardry;
private
magic : word;
end;

implementation
{**************************realize method monster*********}
constructor monstr.init(x_,y_,health_,ammo_: word);
begin
x:= x_;
y:=y_;
health:= health_;
ammo:=ammo_;
color:=yellow;
end;
{*****************monstr.attack**********}
procedure monstr.attack;
begin
if ammo = 0 then exit;
dec(ammo); setcolor(color); outtextXY(x+15,y,'ba-bax!');
end;
{***********monstr.draw********}
procedure monstr.draw;
begin
setcolor(color); outtextXY(x,y,'@');
end;
{****************monstr.erase***********}
procedure monstr.erase;
begin
setcolor(black); outtextXY(x,y,'@');outtextXY(x+15,y,'ba-bax!');
end;
{***********monstr.hit************}
procedure monstr.hit;
begin
if health=0 then exit;
dec(health);
if health = 0 then begin color := red; draw;exit;end;
attack;
end;
{************************monstr.move*************}
procedure monstr.move(x_,y_:word);
begin
if health = 0 then exit;
erase; x:=x_;y:=y_; draw;
end;
{*********************monster.drag**************}
function monstr.drag : boolean;
var
key : char;
dx,dy : integer;
step : integer;
begin
step := 5;
key := readkey;
if key = chr(0) then key := readkey; dx := 0; dy := 0;
case ord(key) of
72 : dy := -step;
75 : dx := -step;
77 : dx := step;
80 : dy := step;
27 : begin drag := false; exit end; end;
monstr.move(x + dx, y + dy); drag := true;
end;

{realize method object deamon}
constructor daemon.init ( x_,y_,health_,ammo_,magic_:word);
begin
inherited init ( x_,y_,health_,ammo_);
color:=green;
magic:=magic_;
end;

{daemon.attack}
procedure daemon.attack;
begin
if ammo= 0 then exit;
dec(ammo);
if magic > 0 then begin
outtextXY(x+15,y,'BY-BYX!'); dec(magic); end
else
outtextXY(x+15,y,'by-byx!');
end;
{daemon.draw}
procedure daemon.draw;
begin
setcolor(color); outtextXY(x,y,'%');
end;
{daemon.erase}
procedure daemon.erase;
begin
setcolor(black); outtextXY(x,y,'%)');outtextXY(x+15,y,'by-byx!');outtextXY(x+15,y,'BY-BYX');
end;
{daemon.wizardry}
procedure daemon.wizardry;
begin
if magic = 0 then exit;
outtextXY(x+15,y,'Krible-krable-byms!'); dec (magic);
end;
end.
FPS вне форума   Ответить с цитированием
Ads

Яндекс

Member
 
Регистрация: 31.10.2006
Сообщений: 40200
Записей в дневнике: 0
Сказал(а) спасибо: 0
Поблагодарили 0 раз(а) в 0 сообщениях
Репутация: 55070