Advertisement
Zung_the_great

[Pascal] (Paint version 2.1)

Mar 28th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.36 KB | None | 0 0
  1. program paint;
  2. uses crt;
  3. type int = integer;
  4. var
  5. kt : boolean;
  6. k : char;
  7. co : int;
  8. s : string;
  9. bl : array[1..80,1..25]of int;
  10.  
  11. f : text;
  12. procedure change(var k:char);
  13. var i,c:int;
  14. begin
  15. val(k,i,c);
  16. co:=i;
  17. textcolor(co);
  18. textbackground(co);
  19. end;
  20.  
  21. procedure movement(var i,j:int);
  22. var io,jo:int;
  23. begin
  24. k:=readkey;
  25.  
  26. case k of
  27.  
  28. 'M' : if(j<80) then begin
  29. textcolor(co);
  30. gotoxy(j,i); write('>');
  31. j:=j+1;
  32. textcolor(black);
  33. gotoxy(j,i); write('>');
  34. end;
  35. 'K' : if (j>1) then begin
  36.  
  37. textcolor(co);
  38. gotoxy(j,i); write('<');
  39. textcolor(black);
  40. j:=j-1;
  41. gotoxy(j,i); write('<');
  42. end;
  43. 'H' : if (i>1) then begin
  44. textcolor(co);
  45. gotoxy(j,i); write('^');
  46. i:=i-1;
  47. textcolor(black);
  48. gotoxy(j,i); write('^');
  49. end;
  50. 'P' : if (i<24) then begin
  51. textcolor(co);
  52. gotoxy(j,i); write('V');
  53. textcolor(black);
  54. i:=i+1;
  55. gotoxy(j,i); write('V');
  56. end;
  57. 'c' : begin
  58. inc(co); kt:=true;
  59. textcolor(co);
  60. textbackground(co);
  61. if co=8 then begin
  62. co:=1;
  63. textcolor(co+blink);
  64. textbackground(co+blink);
  65. end;
  66.  
  67. end;
  68. '1' :change(k); '2' :change(k);
  69. '3' :change(k); '4' :change(k);
  70. '5' :change(k); '6' :change(k);
  71. '7' :change(k);
  72. 't' :begin
  73. textcolor(black); gotoxy(54,25); write('remember to type space 1st');
  74. gotoxy(j,i);
  75. readln(s); gotoxy(54,25); clreol;
  76. gotoxy(j,i);
  77. textcolor(co);
  78. end;
  79. {text}
  80. 'e' :begin
  81. co:=7;
  82. textcolor(co);
  83. textbackground(co); kt:=false;
  84. end;
  85.  
  86. 'a' :begin
  87. co:=0;
  88. repeat
  89.  
  90. inc(co);
  91. textcolor(co);
  92. textbackground(co);
  93. for io:=1 to 25 do for jo:=1 to 80 do begin write('C'); clrscr; end;
  94.  
  95. until co=7;
  96. textcolor(black);
  97. gotoxy(1,25); write('COLOR : ');
  98. gotoxy(1,1); write('Y'); i:=1; j:=1;
  99. end;
  100.  
  101. end;
  102.  
  103. end;
  104.  
  105.  
  106. procedure play;
  107. var i,j,dem:int;
  108. begin
  109. fillchar(bl,sizeof(bl),0);
  110. textbackground(7); textcolor(7);
  111. for i:=1 to 25 do for j:=1 to 80 do write('C');
  112. kt:=false;
  113. textcolor(black);
  114. textbackground(white);
  115. gotoxy(1,1); write('Y'); i:=1; j:=i; co:=7;
  116. textcolor(black);
  117. gotoxy(1,25); write('COLOR : ');
  118.  
  119. dem:=0; kt:=false;
  120. while k<>#27 do
  121. begin
  122. movement(i,j); textcolor(co);
  123.  
  124. textcolor(co);
  125. if kt then
  126. begin {Village_1.dat}
  127. bl[j,i]:=co;
  128. end else bl[j,i]:=0;
  129. gotoxy(9,25); write('0 ');
  130. textcolor(black); textbackground(7);
  131. gotoxy(25,25); clreol;
  132. gotoxy(25,25); write('position: ',j,'_',i,' Color code=',bl[j,i],' ',kt);
  133. textcolor(co); textbackground(co);
  134. end;
  135. assign(f,'Line.out'); rewrite(f); {ho tro cho captain moving}
  136. textcolor(4); textbackground(4);
  137. for i:=1 to 80 do
  138. for j:=1 to 25 do if bl[i,j]<>0 then
  139. begin
  140. gotoxy(i,j); write('C');
  141. writeln(f,i,' ',j,' ',bl[i,j]);
  142.  
  143. end;
  144. textcolor(black); textbackground(7);
  145. gotoxy(72,25); write('Checked');
  146. readln;
  147.  
  148. close(f);
  149. end;
  150.  
  151. procedure head;
  152. begin
  153.  
  154. end;
  155.  
  156. begin
  157. clrscr;
  158. play;
  159. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement