анимация в 4 стороны

  1. program erni;
  2. const
  3. image_count=13;
  4. width=240;
  5. height=320;
  6. var
  7. key,k,x,y: integer ;
  8. temp: integer ;
  9. anim,tanim,n: integer ;
  10. prox,proy: integer;
  11. img:array [1..image_count] of  image ;
  12. procedure LoadImages;
  13. Begin
  14. For temp:=1 To image_count Do
  15. img[temp]:=LoadImage(''+temp+'.png');
  16. End ;
  17. procedure Background;
  18. Begin
  19.  SetColor(150,150,150);
  20.  FillRect(0,0,width,height);
  21. End ;
  22. procedure DrawMaps;\
  23. var
  24.  map_x: integer;
  25. map_y: integer;
  26. Begin
  27.  For map_x:=0 To 10 Do
  28. For map_y:=0 To 10 Do\
  29. DrawImage(img[1],(map_x*30)+x,(map_y*30)+y);
  30. End ;
  31. procedure DrawPers;
  32. Begin
  33. if (tanim=1) then anim:=1;
  34. if (tanim=4) then anim:=3;
  35. if (tanim=7) then anim:=1;
  36. if (tanim=10) then anim:=2;
  37. if (tanim=13) then tanim:=0;
  38. if (n=0) then n:=3;
  39. if (n=1) then DrawImage(img[4+anim],(width/2),
  40. (height/2)-35);
  41. if (n=2) then DrawImage(img[10+anim],(width/2),
  42. (height/2)-35);
  43. if (n=3) then DrawImage(img[1+anim],(width/2),
  44. (height/2)-35);
  45. if (n=4) then DrawImage(img[7+anim],(width/2),
  46. (height/2)-35);
  47. if (key=GA_UP) then
  48. Begin
  49. n:=1;
  50. tanim:=tanim+1;
  51. y:=y-3;
  52. End else
  53. if (key=GA_DOWN) then
  54. Begin
  55.   n:=3;
  56.   tanim:=tanim+1;
  57.   y:=y+3;
  58. End else
  59. if (key=GA_RIGHT) then
  60. Begin
  61.   n:=2;
  62.   tanim:=tanim+1;
  63.   x:=x+3;
  64. End else
  65. if (key=GA_LEFT) then
  66. Begin
  67.   n:=4;
  68.   tanim:=tanim+1;
  69.   x:=x-3;
  70. End else tanim:=0;
  71. SetColor(255,255,0);
  72. DrawText(''+(x/30)+':'+(y/30),3,3);
  73. End ;
  74. begin
  75. LoadImages;
  76. prox:=width/2;
  77. proy:=height/2;
  78. anim:=1;
  79. Repeat
  80. key:=keyToAction(getKeyPressed);
  81. k:=keyToAction(getKeyClicked);
  82. Background; {зарисовка экрана}
  83. DrawMaps;
  84. DrawPers;
  85. Repaint;
  86. Delay(15);
  87. until false;
  88. end .
как бы там всё понятно)

Реклама

Мы в соцсетях

tw tg yt gt