Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Uses graphABC, ABCObjects;
- var
- ball:PictureABC;
- ballX, ballY, stepX, stepY, r,playerX,playerY,i,j,snowX,snowY,stepSnowY,stepBounce:integer;
- player:RectangleABC;
- right, left,space:boolean;
- blocks:array[1..12] of RectangleABC;
- text:TextABC;
- rect:rectangleABC;
- snow:array[1..50] of CircleABC;
- procedure keyDown(key:integer);
- begin
- if(key = vk_Right) then right := true;
- if(key = vk_Left) then left := true;
- if(key = vk_Space) then space := true;
- end;
- procedure keyUp(key:integer);
- begin
- if(key = vk_Right) then right := false;
- if(key = vk_Left) then left := false;
- end;
- begin
- window.init(300,100,640,480,clBlack);
- ballX := 100;
- ballY := 100;
- stepX := 1;
- stepY := 1;
- // ball.angle := ball.angle + 90;
- randomize;
- for i:=1 to 50 do
- begin
- snowX := random(0,windowWidth-10);
- snowY := random(0,windowHeight-10);
- snow[i] := CircleABC.Create(snowX,snowY,10,clWhite);
- snow[i].ToBack();
- end;
- stepBounce := 2;
- stepSnowY := 2;
- rect := RectangleABC.Create(windowWIdth div 2-100,windowHeight div 2 - 20,250,90,clBlack);
- rect.ToFront();
- text := TextABC.Create(windowWIdth div 2-100,windowHeight div 2 - 20,30,'Press ''Space''',clWhite);
- text.ToFront();
- onKeyDown := keyDown;
- while(space <> true) do
- begin
- for i:=1 to 50 do
- begin
- if(i mod 4 = 0) then stepBounce := -stepBounce;
- snow[i].MoveTo(snow[i].Position.X,snow[i].Position.Y+stepSnowY);
- snow[i].MoveTo(snow[i].Position.X+stepBounce,snow[i].Position.Y+stepSnowY);
- if(snow[i].Position.Y > windowHeight+100) then
- begin
- snow[i].MoveTo(snow[i].Position.X,0);
- end;
- end;
- end;
- window.init(300,100,640,480,clBlack);
- for i:=1 to 50 do
- begin
- snow[i].MoveTo(700,700);
- end;
- text.MoveTo(700,700);
- ball := PictureABC.Create(ballX,ballY,'ball2.png');
- ball.scaleX := 0.3;
- ball.ScaleY := 0.3;
- playerX := windowWidth div 2 - 100;
- playerY := windowHeight - 30;
- player := RectangleABC.Create(playerX,playerY,200,30,clblue);
- onKeyUp := keyUp;
- for i:=1 to 2 do
- begin
- for j:=1 to 6 do
- begin
- blocks[(i-1)*6 + j] := RectangleABC.Create(100*(j-1) + 20,30*(i-1) + 80,100,30,clred);
- end;
- end;
- while(true) do
- begin
- // logic moving player
- if(right = true) then playerX := playerX + 3;
- if(left = true) then playerX := playerX - 3;
- player.MoveTo(playerX,playerY);
- if((playerX + player.Width > windowWidth)
- ) then
- begin
- playerX := windowWidth - player.Width;
- end;
- if((playerX < 0)) then
- begin
- playerX := 0;
- end;
- //----------------------------------
- // logic moving ball1
- ballX := ballX + stepX;
- ballY := ballY + stepY;
- ball.MoveTo(ballX,ballY);
- if((ballX + ball.Width > windowWidth) or
- (ballX < 0)) then
- begin
- stepX := -stepX;
- end;
- if((ballY + ball.Height > windowHeight) or
- (ballY < 0)) then
- begin
- stepY := -stepY;
- end;
- //----------------------------------
- //logic contact (player, ball and player2) and disappearance (player2 and ...)
- if((ball.Intersect(player) = true) and (player.Intersect(ball) = true) ) then
- begin
- stepY := -stepY;
- end;
- for i:=1 to 12 do
- begin
- if(ball.Intersect(blocks[i]) = true) then
- begin
- blocks[i].MoveTo(700,700);
- stepY := -stepY;
- end;
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement