Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program project1;
- uses crt;
- var
- map:array[1..80,1..23] of string; //wip
- x:integer; //player X
- y:integer; //player y
- inp:char;
- bally:array [1..10] of integer; //snowballs Y
- ballx:array [1..10] of integer; //snowballs x
- snowballs:array[1..10] of integer;//store each snow ball on screen
- numsnball:integer;
- count:integer;
- snowammo:integer;
- procedure collision(x,y:integer);
- begin
- if map[x,y] = '*' then
- begin
- gotoXY(40,10);
- write('you have been hit');
- end;
- end;
- procedure move(inp:char);
- begin
- //inp:=readkey;
- gotoXY(x,y);
- write(' ');
- case inp of
- 'w':y:=y-1;
- 'a':x:=x-1;
- 's':y:=y+1;
- 'd':x:=x+1;
- end;
- gotoXY(x,y);
- write('O');
- collision(x,y);
- end;
- procedure speed();
- begin
- for count:= 1 to numsnball do
- begin
- gotoXY(ballx[count],bally[count]);
- write(' ');
- if bally[count]<24 then bally[count]:=bally[count]+1;
- gotoXY(ballx[count],bally[count]);
- write('*');
- delay(25);
- if bally[count]>=24 then
- begin
- numsnball:=numsnball-1;
- gotoXY(ballx[count],bally[count]);
- write(' ');
- end;
- end;
- procedure fire;
- begin
- snowammo:=snowammo-1;
- numsnball:=numsnball+1;
- ballx[numsnball]:=x;
- bally[numsnball]:=y+1;
- gotoXY(ballx[numsnball],bally[numsnball]);
- write('*');
- if numsnball=10
- nowballs[numsnball]:=1;
- end;
- begin
- cursoroff;
- snowammo:=10;
- x:=1;
- y:=1;
- map[7,10]:='*';
- //snow ball fight
- //draw map
- //move
- repeat
- repeat
- if numsnball>0 then speed;
- until keypressed;
- inp:=readkey;
- move(inp);
- //throw ball
- if inp='e' then
- begin
- if snowammo>0 then fire;
- else snowammo:=0;
- end;
- until inp=' ';
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement