Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. program project1;
  2. uses crt;
  3. var
  4. map:array[1..80,1..23] of string; //wip
  5. x:integer; //player X
  6. y:integer; //player y
  7. inp:char;
  8. bally:array [1..10] of integer; //snowballs Y
  9. ballx:array [1..10] of integer; //snowballs x
  10. snowballs:array[1..10] of integer;//store each snow ball on screen
  11. numsnball:integer;
  12. count:integer;
  13. snowammo:integer;
  14. procedure collision(x,y:integer);
  15. begin
  16. if map[x,y] = '*' then
  17. begin
  18. gotoXY(40,10);
  19. write('you have been hit');
  20. end;
  21. end;
  22.  
  23. procedure move(inp:char);
  24. begin
  25. //inp:=readkey;
  26. gotoXY(x,y);
  27. write(' ');
  28. case inp of
  29. 'w':y:=y-1;
  30. 'a':x:=x-1;
  31. 's':y:=y+1;
  32. 'd':x:=x+1;
  33. end;
  34. gotoXY(x,y);
  35. write('O');
  36. collision(x,y);
  37. end;
  38. procedure speed();
  39. begin
  40. for count:= 1 to numsnball do
  41. begin
  42. gotoXY(ballx[count],bally[count]);
  43. write(' ');
  44. if bally[count]<24 then bally[count]:=bally[count]+1;
  45. gotoXY(ballx[count],bally[count]);
  46. write('*');
  47. delay(25);
  48. if bally[count]>=24 then
  49. begin
  50. numsnball:=numsnball-1;
  51. gotoXY(ballx[count],bally[count]);
  52. write(' ');
  53. end;
  54. end;
  55.  
  56. procedure fire;
  57. begin
  58. snowammo:=snowammo-1;
  59. numsnball:=numsnball+1;
  60. ballx[numsnball]:=x;
  61. bally[numsnball]:=y+1;
  62. gotoXY(ballx[numsnball],bally[numsnball]);
  63. write('*');
  64. if numsnball=10
  65. nowballs[numsnball]:=1;
  66. end;
  67. begin
  68. cursoroff;
  69. snowammo:=10;
  70. x:=1;
  71. y:=1;
  72. map[7,10]:='*';
  73. //snow ball fight
  74. //draw map
  75. //move
  76. repeat
  77. repeat
  78. if numsnball>0 then speed;
  79. until keypressed;
  80. inp:=readkey;
  81. move(inp);
  82. //throw ball
  83. if inp='e' then
  84. begin
  85. if snowammo>0 then fire;
  86. else snowammo:=0;
  87. end;
  88.  
  89. until inp=' ';
  90.  
  91.  
  92.  
  93. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement