Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- setscreen ("graphics:max,max")
- setscreen ("offscreenonly")
- var paddlex : int := 400
- var ballx, bally : int := 500 % Location of ball
- var dx, dy : int := 1 % Speed of ball
- var size : int := 70 % half the size of paddle
- var mx, my, mb : int
- var go : int := Pic.FileNew ("gameover.bmp")
- drawfillbox (400, 400, 350, 420, 3)
- drawfillbox (400, 400, 450, 420, 7)
- drawfillbox (450, 400, 500, 420, 6)
- drawfillbox (500, 400, 550, 420, 5)
- drawfillbox (550, 400, 600, 420, 4)
- loop
- mousewhere (mx, my, mb)
- drawfilloval (ballx, bally, 20, 20, 0) % Erases ball
- ballx := ballx + dx % Moves ball (left and right)
- bally := bally + dy % Moves ball (up and down)
- if bally < 40 then
- if whatdotcolour (ballx, bally - 20) > 0 then
- dy := - (dy)
- end if
- end if
- if bally > 40 then
- if whatdotcolour (ballx, bally - 20) = 7 then
- dy := - (dy)
- drawfillbox (400, 400, 450, 420, 0)
- end if
- if whatdotcolour (ballx, bally + 20) = 7 then
- dy := - (dy)
- drawfillbox (400, 400, 450, 420, 0)
- end if
- if whatdotcolour (ballx + 20, bally) = 7 then
- dx := - (dx)
- drawfillbox (400, 400, 450, 420, 0)
- end if
- if whatdotcolour (ballx - 20, bally) = 7 then
- dx := - (dx)
- drawfillbox (400, 400, 450, 420, 0)
- end if
- if whatdotcolour (ballx, bally - 20) = 6 then
- dy := - (dy)
- drawfillbox (500, 400, 550, 420, 0)
- end if
- if whatdotcolour (ballx, bally + 20) = 6 then
- dy := - (dy)
- drawfillbox (450, 400, 500, 420, 0)
- end if
- if whatdotcolour (ballx + 20, bally) = 6 then
- dx := - (dx)
- drawfillbox (450, 400, 500, 420, 0)
- end if
- if whatdotcolour (ballx - 20, bally) = 6 then
- dx := - (dx)
- drawfillbox (450, 400, 500, 420, 0)
- end if
- if whatdotcolour (ballx, bally - 20) = 5 then
- dy := - (dy)
- drawfillbox (450, 400, 500, 420, 0)
- end if
- if whatdotcolour (ballx, bally + 20) = 5 then
- dy := - (dy)
- drawfillbox (500, 400, 550, 420, 0)
- end if
- if whatdotcolour (ballx + 20, bally) = 5 then
- dx := - (dx)
- drawfillbox (500, 400, 550, 420, 0)
- end if
- if whatdotcolour (ballx - 20, bally) = 5 then
- dx := - (dx)
- drawfillbox (500, 400, 550, 420, 0)
- end if
- if whatdotcolour (ballx, bally - 20) = 4 then
- dy := - (dy)
- drawfillbox (550, 400, 600, 420, 0)
- end if
- if whatdotcolour (ballx, bally + 20) = 4 then
- dy := - (dy)
- drawfillbox (550, 400, 600, 420, 0)
- end if
- if whatdotcolour (ballx + 20, bally) = 4 then
- dx := - (dx)
- drawfillbox (550, 400, 600, 420, 0)
- end if
- if whatdotcolour (ballx - 20, bally) = 4 then
- dx := - (dx)
- drawfillbox (550, 400, 600, 420, 0)
- end if
- if whatdotcolour (ballx, bally - 20) = 3 then
- dy := - (dy)
- drawfillbox (400, 400, 350, 420, 0)
- end if
- if whatdotcolour (ballx, bally + 20) = 3 then
- dy := - (dy)
- drawfillbox (400, 400, 350, 420, 0)
- end if
- if whatdotcolour (ballx + 20, bally) = 3 then
- dx := - (dx)
- drawfillbox (400, 400, 350, 420, 0)
- end if
- if whatdotcolour (ballx - 20, bally) = 3 then
- dx := - (dx)
- drawfillbox (400, 400, 350, 420, 0)
- end if
- end if
- if ballx > maxx then %%%%%%%%Changes direction of ball if
- dx := - (dx) %%%%%%%%it touches edge of screen
- elsif ballx < 0 then
- dx := - (dx)
- elsif bally > maxy then
- dy := - (dy)
- elsif bally < 0 then
- dy := - (dy)
- bally := 400
- Pic.Draw (go, -100, -450, picCopy)
- View.Update
- loop
- mousewhere (mx, my, mb)
- if mb = 1 then
- cls
- drawfillbox (550, 400, 350, 420, 3)
- drawfillbox (400, 400, 450, 420, 7)
- drawfillbox (450, 400, 500, 420, 6)
- drawfillbox (500, 400, 550, 420, 5)
- drawfillbox (550, 400, 600, 420, 4)
- exit
- end if
- end loop
- end if
- drawfilloval (ballx, bally, 20, 20, purple) % ball
- paddlex := mx
- drawfillbox (mx - size, 0, mx + size, 20, 7) %paddle
- drawfillbox (mx - size, 0, 0, 20, 0) % erase paddle (left)
- drawfillbox (maxx, 0, mx + size, 20, 0) % erase paddle (right)
- View.Update
- end loop
Add Comment
Please, Sign In to add comment