PDA

Просмотр полной версии : Очень нужна помощь Pascal ABC PLZ!!!



AlexANGEL_!
18.12.2009, 17:46
Помогите пожалуйста с игрой.
Суть в том, что должны падать звезды, которые нужно сбивать мышкой (кликами).
У меня после первого попадания больще не хочет стрелять. В чем ошибка? :confused:
Буду очень признателен, если помощь придет сегодня, т.к. завтра нужно сдавать...

ВОТ ТЕКСТ:



program Star;
uses GraphABC, Events, ABCObjects;

var Result,Shout,m:integer;
ObStar,ObStar1,ObStar2: StarABC;
txt1,txt2:TextABC;


//------Различные пути следования------//
procedure Move1(s: StarABC; v:integer);
var ob: ObjectABC; i,x,y,x0{,y0}:integer;
begin
x0:=s.Center.x;
//y0:=s.Center.y;
for i:=1 to WindowHeight+15 do
begin
x:=x0;
y:=i;
s.MoveTo(x,y);
sleep(150-v);
end;
end;

//--//

procedure Move2(s: StarABC; v:integer);
var ob: ObjectABC; i,x,y,x0{,y0}:integer;
begin
x0:=s.Center.x;
//y0:=s.Center.y;
for i:=1 to WindowHeight+15 do
begin
x:=x0+round(5*sin(i*Pi/180));
y:=i;
s.MoveTo(x,y);
sleep(150-v);
end;
end;

//------выбор пути следования звезды----//
procedure My(result: integer);
var ob: ObjectABC;
begin
case result of
0..5:begin
obStar:= StarABC.Create(Random(WindowWidth-100)+50,-20,20,10,Random(5)+4,clRandom);
Inc(m);
Move1(obstar,100);
end;
6..15:begin
obStar:= StarABC.Create(Random(WindowWidth-100)+50,20,20,10,Random(5)+4,clRandom);
Inc(m);
Move1(obstar,120);
end;
16..30:begin
obStar:= StarABC.Create(Random(WindowWidth-100)+50,20,20,10,Random(5)+4,clRandom);
Inc(m);
obStar1:= StarABC.Create(Random(WindowWidth-100)+50,20,20,10,Random(5)+4,clRandom);
Inc(m);
obStar2:= StarABC.Create(Random(WindowWidth-100)+50,20,20,10,Random(5)+4,clRandom);
Inc(m);
Move1(obstar,100);Move1(obstar,120);Move2(obstar,1 20);
end;
31..50:begin
obStar:= StarABC.Create(Random(WindowWidth-100)+50,20,20,10,Random(5)+4,clRandom);
Inc(m);
obStar1:= StarABC.Create(Random(WindowWidth-100)+50,20,20,10,Random(5)+4,clRandom);
Inc(m);
obStar2:= StarABC.Create(Random(WindowWidth-100)+50,20,20,10,Random(5)+4,clRandom);
Inc(m);
Move1(obstar,100);Move2(obstar,120);Move2(obstar,1 40);
end;
51..60:begin
obStar:= StarABC.Create(Random(WindowWidth-50)+25,20,20,10,Random(5)+4,clRandom);Inc(m);
obStar1:= StarABC.Create(Random(WindowWidth-50)+25,20,20,10,Random(5)+4,clRandom);Inc(m);
obStar2:= StarABC.Create(Random(WindowWidth-50)+25,20,20,10,Random(5)+4,clRandom);Inc(m);
Move2(obstar,140);Move2(obstar,120);Move2(obstar,1 40);
end;
end;
end;

//----Щелчек----//

procedure MyMouseDown(x,y,mb: integer);
var ob: ObjectABC;
begin
Inc(Shout);
txt1.Text:='Выстрелов: '+IntToStr(Shout);
ob:=ObjectUnderPoint(x,y);
if (ob<>nil) and (ob is StarABC) then
begin
Inc(Result);
ob.Destroy;
m:=m-1;
txt2.Text:='Попаданий: '+IntToStr(Result);
end;
if m=0 then my(result);
exit;
end;

//---ПРОГРАММА---//

BEGIN
SetWindowCaption('Поймай звезду');
SetWindowSize(800,600);
FillWindow('Textures\sky.jpg');
txt1:=TextABC.Create(10,WindowHeight-40,14,clRed,'Выстрелов: 0');
txt2:=TextABC.Create(390,WindowHeight-40,14,clBlue,'Попаданий: 0');
onmousemove:=ABCmousemove;
onmousedown:=MyMouseDown;
my(result);
while result<60 do begin
onmousedown:=MyMouseDown;
end;
END.