анимация в 4 стороны
- program erni;
- const
- image_count=13;
- width=240;
- height=320;
- var
- key,k,x,y: integer ;
- temp: integer ;
- anim,tanim,n: integer ;
- prox,proy: integer;
- img:array [1..image_count] of image ;
- procedure LoadImages;
- Begin
- For temp:=1 To image_count Do
- img[temp]:=LoadImage(''+temp+'.png');
- End ;
- procedure Background;
- Begin
- SetColor(150,150,150);
- FillRect(0,0,width,height);
- End ;
- procedure DrawMaps;\
- var
- map_x: integer;
- map_y: integer;
- Begin
- For map_x:=0 To 10 Do
- For map_y:=0 To 10 Do\
- DrawImage(img[1],(map_x*30)+x,(map_y*30)+y);
- End ;
- procedure DrawPers;
- Begin
- if (tanim=1) then anim:=1;
- if (tanim=4) then anim:=3;
- if (tanim=7) then anim:=1;
- if (tanim=10) then anim:=2;
- if (tanim=13) then tanim:=0;
- if (n=0) then n:=3;
- if (n=1) then DrawImage(img[4+anim],(width/2),
- (height/2)-35);
- if (n=2) then DrawImage(img[10+anim],(width/2),
- (height/2)-35);
- if (n=3) then DrawImage(img[1+anim],(width/2),
- (height/2)-35);
- if (n=4) then DrawImage(img[7+anim],(width/2),
- (height/2)-35);
- if (key=GA_UP) then
- Begin
- n:=1;
- tanim:=tanim+1;
- y:=y-3;
- End else
- if (key=GA_DOWN) then
- Begin
- n:=3;
- tanim:=tanim+1;
- y:=y+3;
- End else
- if (key=GA_RIGHT) then
- Begin
- n:=2;
- tanim:=tanim+1;
- x:=x+3;
- End else
- if (key=GA_LEFT) then
- Begin
- n:=4;
- tanim:=tanim+1;
- x:=x-3;
- End else tanim:=0;
- SetColor(255,255,0);
- DrawText(''+(x/30)+':'+(y/30),3,3);
- End ;
- begin
- LoadImages;
- prox:=width/2;
- proy:=height/2;
- anim:=1;
- Repeat
- key:=keyToAction(getKeyPressed);
- k:=keyToAction(getKeyClicked);
- Background; {зарисовка экрана}
- DrawMaps;
- DrawPers;
- Repaint;
- Delay(15);
- until false;
- end .
как бы там всё понятно)