Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Project1;
- uses crt, classes;
- type
- { TBlock }
- TBlock = class(Tobject)
- private
- public
- X,Y,C,Timer,Speed:integer;
- constructor Create();
- procedure Move();
- procedure Draw();
- end;
- { TPlayer }
- TPlayer = class(TObject)
- private
- public
- X,Y,Life:Integer;
- Key:Char;
- constructor Create();
- procedure Move();
- procedure Draw();
- end;
- { TPlayer }
- constructor TPlayer.Create;
- begin
- X:=120 div 2;
- Y:=40;
- Life:=3;
- end;
- procedure TPlayer.Move;
- begin
- key:=' ';
- if keypressed then key:=readkey;
- if key='a' then x:=x-1;
- if key='d' then x:=x+1;
- end;
- procedure TPlayer.Draw;
- begin
- Gotoxy(x,y);
- write('=');
- Gotoxy(x-1,y);
- write('=');
- Gotoxy(x+1,y);
- write('=');
- end;
- { TBlock }
- constructor TBlock.Create;
- begin
- x:=random(140);
- y:=1;
- speed:=2; //+Random(10)
- timer:=3;
- end;
- procedure TBlock.Move;
- begin
- timer:=timer-1;
- if timer=0 then
- begin
- timer:=timer+speed;
- y:=y+1;
- end;
- end;
- procedure TBlock.Draw;
- begin
- Gotoxy(x,y);
- write('|');
- end;
- var
- Player:TPlayer;
- Block:TBlock;
- List:TList;
- i:integer;
- begin
- Player:=TPlayer.Create;
- List:=TList.Create;
- while 1=1 do
- begin
- clrscr;
- if random(100)>20 then
- begin
- Block:=Tblock.Create();
- list.add(Block);
- end;
- Player.Move;
- For i:=list.count-1 downto 0 do
- begin
- Block:=TBlock(list.Items[i]);
- Block.Move;
- Block.Draw;
- gotoxy(1,i+1);
- write(Block.X,' ',Block.Y);
- if Block.Y>40 Then begin list.Delete(i); Block.free; end;
- end;
- Player.Draw;
- gotoxy(1,1);
- Delay(50);
- end;
- List.Free;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement