Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Uses graphABC,ABCObjects;
- var
- ball:CircleABC;
- player:pictureABC;
- block:array[1..10] of PictureABC;
- block2:array[1..10] of PictureABC;
- xBall,yBall,kx,ky,xPlayer,yPlayer,xBlock,yBlock,xBlock2,yBlock2,right,left,cr,cg,cb:integer;
- count,i,i2,step:integer;
- procedure keyDown(key:integer);
- begin
- if(key = VK_Right) then
- begin
- right := 1;
- end;
- if(key = VK_Left) then
- begin
- left := 1;
- end;
- end;
- procedure keyUp(key:integer);
- begin
- if(key = VK_Right) then
- begin
- right := 0;
- end;
- if(key = VK_Left) then
- begin
- left := 0;
- end;
- end;
- begin
- randomize;
- count := 0;
- xBall := 100;
- yBall := 100;
- ball := CircleABC.Create(xBall,yBall,13,clBlack);
- xPlayer := 200;
- yPlayer := windowheight-100;
- player := pictureABC.Create(xPlayer,yPlayer,'player 3.bmp');
- ball.BorderColor := clWhite;
- for i:=1 to 10 do
- begin
- xBlock := 72 + (i-1)*53;
- yBlock := 0;
- block[i] := PictureABC.Create(xBlock,yBlock,'green 3.bmp');
- block[i].TransparentColor := clWhite;
- block[i].Transparent := true;
- end;
- for i2:=1 to 10 do
- begin
- xBlock2 := 72 + (i2-1)*106;
- yBlock2 := 0;
- block[i2] := PictureABC.Create(xBlock,yBlock,'white.bmp');
- block[i2].Transparent := true;
- end;
- kx := 1;
- ky := 1;
- onKeyDown := keyDown;
- onKeyUp := keyUp;
- while(true) do
- begin
- if(player.Intersect(ball)) then
- begin
- //kx:=-kx;
- ky := -ky;
- end;
- for i:=1 to 10 do
- begin
- if(ball.Intersect(block[i])) then
- begin
- block[i].MoveTo(1000,20);
- ky := -ky;
- end ;
- end;
- for i2:=1 to 10 do
- begin
- if(ball.Intersect(block2[i2])) then
- begin
- block2[i2].MoveTo(1000,20);
- ky := -ky;
- end ;
- end;
- xBall := xBall + kx;
- yBall := yBall + ky;
- if((xBall+40 > windowWidth) or (xBall < 0)) then
- begin
- kx := -kx;
- end;
- if((yBall < 0)) then
- begin
- ky := -ky;
- end;
- if(yBall+40 > windowHeight) then
- begin
- xBall := 200;
- yBall := 20;
- end;
- if(right = 1) then
- begin
- xPlayer := xPlayer + 1;
- player.MoveTo(xPlayer,yPlayer);
- end;
- if(left = 1) then
- begin
- xPlayer := xPlayer - 1;
- player.MoveTo(xPlayer,yPlayer);
- end;
- step := step + 1;
- if(step = 100) then
- begin
- cr := random(1,255);
- cg := random(1,255);
- cb := random(1,255);
- step := 0;
- end;
- ball.Color := RGB(cr,cg,cb);
- ball.MoveTo(xBall,yBall);
- sleep(1);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement