Показать сообщение отдельно
Старый 01.02.2012, 19:31   #7
Igor
Мастер
 
Аватар для Igor
 
Регистрация: 03.05.2010
Адрес: Подмосковье
Сообщений: 1,218
Написано 438 полезных сообщений
(для 790 пользователей)
Ответ: Procedure and Function

Program tst:
var x,y:integer;
i,e,c:image;
left_x,right_x,up_y,down_y:integer;

function peresek(xp,yp:integer):boolean;
begin
peresek:=((xp>left_x) and (xp<right_x) and (yp>up_y) and(yp<down_y));
end;

begin
i:=loadImage('fon5.PNG');
e:=loadImage('object1.png');
c:=loadImage('object2.png');
left_x:=40-GetImageWidth(e);
right_x:=40+GetImageWidth(c);
up_y:=40-GetImageHeight(e);
down_y:=40+getImageHeight(c);

repeat
if getKeyPressed=KE_KEY4 then x:=x-1;
if getKeyPressed=KE_KEY6 then x:=x+1;
if getKeyPressed=KE_KEY8 then y:=y+1;
if getKeyPressed=KE_KEY2 then y:=y-1;
drawImage(i,0,0); drawImage(c,40,40);
drawImage(e,x,y);
repaint;
until peresek(x,y);
end.
__________________
О¯О ¡¡¡ʁɔvʎнdǝʚǝdǝu dиW
(Offline)
 
Ответить с цитированием