Pong by chipanpriest
Author |
Message |
chipanpriest
|
Posted: Sun Dec 18, 2011 4:15 pm Post subject: Pong by chipanpriest |
|
|
This is my version of pong xD enjoy
Turing: |
var paddlesize, paddle1pos, paddle2pos, ballx, bally : int
var ballspeed1, ballspeed2, font, score1, score2 : int
var ch : array char of boolean
paddlesize := 25
ballx := maxx div 2
bally := maxy div 2
ballspeed1 := 2
ballspeed2 := 2
paddle1pos := maxy div 2
paddle2pos := maxy div 2
score1 := 0
score2 := 0
font := Font.New ("Impact:48:bold")
View.Set ("graphics:1000;600,offscreenonly")
colourback (7)
cls
loop
loop
Font.Draw (intstr (score1 ), 100, 500, font, 0)
Font.Draw (intstr (score2 ), 800, 500, font, 0)
exit when score1 = 10 or score2 = 10
Input.KeyDown (ch )
if ch (KEY_DOWN_ARROW) then
paddle2pos := paddle2pos - 2
elsif ch (KEY_UP_ARROW) then
paddle2pos := paddle2pos + 2
end if
if ch ('s') then
paddle1pos := paddle1pos - 2
elsif ch ('w') then
paddle1pos := paddle1pos + 2
end if
if paddle1pos <= paddlesize then
paddle1pos := paddlesize
elsif paddle1pos > 450 - paddlesize then
paddle1pos := 450 - paddlesize
end if
if paddle2pos <= paddlesize then
paddle2pos := paddlesize
elsif paddle2pos > 450 - paddlesize then
paddle2pos := 450 - paddlesize
end if
ballx := ballx + ballspeed1
bally := bally + ballspeed2
if ballx >= 980 and bally >= paddle2pos - paddlesize and bally <= paddle2pos + paddlesize then
ballspeed1 := ballspeed1 * (- 1)
elsif ballx <= 20 and bally >= paddle1pos - paddlesize and bally <= paddle1pos + paddlesize then
ballspeed1 := ballspeed1 * (- 1)
elsif ballx >= 990 then
score1 := score1 + 1
ballx := 980
bally := paddle2pos
ballspeed1 := (- 2)
exit
elsif ballx <= 10 then
score2 := score2 + 1
ballx := 20
bally := paddle1pos
ballspeed1 := 2
exit
end if
if bally >= 440 then
ballspeed2 := ballspeed2 * (- 1)
elsif bally <= 10 then
ballspeed2 := ballspeed2 * (- 1)
end if
drawfillbox (0, paddle1pos - paddlesize, 10, paddle1pos + paddlesize, 0)
drawfillbox (990, paddle2pos - paddlesize, maxx, paddle2pos + paddlesize, 0)
drawfillbox (0, 450, maxx, 476, 0)
drawfillbox (maxx div 2 - 13, 475, maxx div 2 + 13, maxy, 0)
drawfillbox (maxx div 2 - 3, 0, maxx div 2 + 3, 450, 0)
drawfilloval (ballx, bally, 10, 10, 0)
drawoval (ballx, bally, 10, 10, 7)
View.Update
cls
end loop
cls
Font.Draw (intstr (score1 ), 100, 500, font, 0)
Font.Draw (intstr (score2 ), 800, 500, font, 0)
drawfillbox (0, paddle1pos - paddlesize, 10, paddle1pos + paddlesize, 0)
drawfillbox (990, paddle2pos - paddlesize, maxx, paddle2pos + paddlesize, 0)
drawfillbox (0, 450, maxx, 476, 0)
drawfillbox (maxx div 2 - 13, 475, maxx div 2 + 13, maxy, 0)
drawfillbox (maxx div 2 - 3, 0, maxx div 2 + 3, 450, 0)
drawfilloval (ballx, bally, 10, 10, 0)
drawoval (ballx, bally, 10, 10, 7)
View.Update
exit when score1 = 10 or score2 = 10
delay (1000)
end loop
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Aange10
|
Posted: Sun Dec 18, 2011 6:11 pm Post subject: RE:Pong by chipanpriest |
|
|
balls move entirely too fast, and the game breaks if you catch the ball |
|
|
|
|
|
|
|