Alright i am new on this site but i need help with a turing program please. I need to make a pong program on turing for one of my computer classes in grade 11. If anyone knows how to do it or has it already could u maybe send it to my email or post it pleassssseÉ thnx so much if u can
peace
Archived topic from Iceteks, old topic ID:3976, old post ID:32653
Truing Pong program for school
Truing Pong program for school
Hey i got a -4 on this pong game i made for my grade 10 class hope you like it.
var x1, x2, x3, x4, x5 : int% lengths, x-axis
var xdir, ydir : int% keeps track of speed of ball
var y1 : int% height,y-axis
var key : string (1)% key board character
var num : int % stores ASCII numbers
var count : int% keeps track of score
% Title page
drawfill(10,10,255,255)
locate (10, 30)
colorback(255)
color (14)
put "Welcom To Curtis's Paddleball Game"..
locate (11, 30)
color (14)
put "*********************"..
locate (13, 30)
color(14)
put "Press any key to start"..
color(14)
locate(20,2)
put "Use the left and right arrows to direct the paddle. The point of the game is to try and keep the ball moving"
getch (key)
cls
View.Set ("offscreenonly")
loop
cls
count := 0
num := 0
x1 := 110
xdir := 3
ydir := 3
y1 := 110
x4 := 110
x5 := 160
x2 := 110
x3 := 160
loop
drawfill(10,10,255,255)% makes background black
locate (10, 2)
colorback (255)
color (14)
put "SCORE ", count ..
drawbox (110, -100, 635, 389, 14) % background
drawfillbox (x4, 0, x5, 10, 14) % paddle
drawfilloval (x1, y1, 5, 5, 14) % yellow ball
delay (10)
View.Update
exit when y1 = -10
drawfilloval (x1, y1, 5, 5, 255) % erasing yellow ball
drawfillbox (x4, 0, x5, 10, 255) % erasing paddle
if hasch then
getch (key) % get key pressed
num := ord (key) % find ASCII number for key
end if
if num = 203 and x4 >= 120 then % left arrow
x4 := x4 - 25
x5 := x5 - 25
elsif num = 205 and x5 <= 620 then % right arrow
x5 := x5 + 25
x4 := x4 + 25
end if
num := 0
if y1 >= 10 and y1 <= 15 and x1 >= x4 and x1 <= x5 then% makes ball bounce of paddle
count := count + 1 % adds 1 point to the score each time it hits paddle
ydir := 3
end if
if x1 <= 101 then % makes ball not go past 101 on x axis
xdir := 3
elsif x1 >= 620 then% makes ball not go past 620 on x axis
xdir := -3
elsif y1 >= 380 then% makes ball not go past 380 on y axis
ydir := -3
elsif y1 <= -60 then% makes ball not go past -60 on y axis
ydir := 3
end if
y1 := y1 + ydir
x1 := x1 + xdir
end loop
loop
locate (10, 20)
put "Play Again(y/n)" ..
View.Update
getch (key)
exit when key="n" or key="y"
cls
count:=0
end loop
exit when key="n"
end loop
View.Set("nooffscreenonly")
cls
locate(10,35)
put "Thanks For Playing"
Archived topic from Iceteks, old topic ID:3976, old post ID:33013
var x1, x2, x3, x4, x5 : int% lengths, x-axis
var xdir, ydir : int% keeps track of speed of ball
var y1 : int% height,y-axis
var key : string (1)% key board character
var num : int % stores ASCII numbers
var count : int% keeps track of score
% Title page
drawfill(10,10,255,255)
locate (10, 30)
colorback(255)
color (14)
put "Welcom To Curtis's Paddleball Game"..
locate (11, 30)
color (14)
put "*********************"..
locate (13, 30)
color(14)
put "Press any key to start"..
color(14)
locate(20,2)
put "Use the left and right arrows to direct the paddle. The point of the game is to try and keep the ball moving"
getch (key)
cls
View.Set ("offscreenonly")
loop
cls
count := 0
num := 0
x1 := 110
xdir := 3
ydir := 3
y1 := 110
x4 := 110
x5 := 160
x2 := 110
x3 := 160
loop
drawfill(10,10,255,255)% makes background black
locate (10, 2)
colorback (255)
color (14)
put "SCORE ", count ..
drawbox (110, -100, 635, 389, 14) % background
drawfillbox (x4, 0, x5, 10, 14) % paddle
drawfilloval (x1, y1, 5, 5, 14) % yellow ball
delay (10)
View.Update
exit when y1 = -10
drawfilloval (x1, y1, 5, 5, 255) % erasing yellow ball
drawfillbox (x4, 0, x5, 10, 255) % erasing paddle
if hasch then
getch (key) % get key pressed
num := ord (key) % find ASCII number for key
end if
if num = 203 and x4 >= 120 then % left arrow
x4 := x4 - 25
x5 := x5 - 25
elsif num = 205 and x5 <= 620 then % right arrow
x5 := x5 + 25
x4 := x4 + 25
end if
num := 0
if y1 >= 10 and y1 <= 15 and x1 >= x4 and x1 <= x5 then% makes ball bounce of paddle
count := count + 1 % adds 1 point to the score each time it hits paddle
ydir := 3
end if
if x1 <= 101 then % makes ball not go past 101 on x axis
xdir := 3
elsif x1 >= 620 then% makes ball not go past 620 on x axis
xdir := -3
elsif y1 >= 380 then% makes ball not go past 380 on y axis
ydir := -3
elsif y1 <= -60 then% makes ball not go past -60 on y axis
ydir := 3
end if
y1 := y1 + ydir
x1 := x1 + xdir
end loop
loop
locate (10, 20)
put "Play Again(y/n)" ..
View.Update
getch (key)
exit when key="n" or key="y"
cls
count:=0
end loop
exit when key="n"
end loop
View.Set("nooffscreenonly")
cls
locate(10,35)
put "Thanks For Playing"
Archived topic from Iceteks, old topic ID:3976, old post ID:33013
Truing Pong program for school
Code: Select all
% Drew Martell
% Pong
% This program will recreate the awesome Pong experience you once
% had as a young, young child.
% BUG : IF 2P TOUCHES ROOF, BALL PASSES THROUGH UNLESS TOUCHES BOTTOM
% Need to find out how to cancel a process
var scoresFile : int
var records : string
var downLine := 1
var x, y : int
var dx, dy := 1
var player1, player2 : string
var ok : boolean := false
var background := blue
var introFont := Font.New ("serif:25")
var scoreFont := Font.New ("serif:18")
var getKey : array char of boolean
var dir, dir3 := 100
var dir2, dir4 := 180
var score1P, score2P := 0
var stickSpeed := 3
var ballSpeed := 2
x := 70
y := 313
setscreen ("nocursor")
process DrawText
loop
for i : 0 .. 255
Draw.Text ("WELCOME TO PONG", maxx div 2 - 150, maxy div 2, introFont, i)
end for
exit when ok = true
end loop
end DrawText
procedure MainMenu
drawfillbox (0, 0, maxx, maxy, red)
fork DrawText
colorback (red)
locate (17, 25)
put "Enter Player 1's Name: " ..
get player1 : *
locate (18, 25)
put "Enter Player 2's Name: " ..
get player2 : *
if (player1 = "del") and (player2 = "del") then
if File.Exists ("High Scores.txt") then
File.Delete ("High Scores.txt")
locate (20, 33)
put "FILE DELETED"
else
locate (20, 30)
put "FILE DOESN'T EXIST"
end if
Input.Pause
player1 := "Player 1"
player2 := "Player 2"
elsif (player1 = "view") and (player2 = "high scores") then
open : scoresFile, "High Scores.txt", get
loop
if (scoresFile = -10) then
exit
end if
get : scoresFile, records : *
locate (downLine, 28)
put records
downLine += 1
exit when eof (scoresFile)
end loop
Input.Pause
player1 := "Player 1"
player2 := "Player 2"
end if
cls
score1P := 0
score2P := 0
ok := true
end MainMenu
MainMenu
View.Set ("offscreenonly")
drawfillbox (0, 0, maxx, maxy, background)
drawbox (0, 0, maxx, maxy, black)
drawfillbox (20, dir2, 30, dir, white)
drawbox (20, dir2, 30, dir, black)
drawfillbox (maxx - 20, dir4, maxx - 30, dir3, white)
drawbox (maxx - 20, dir4, maxx - 30, dir3, black)
procedure MoveUp1P
drawfillbox (20, dir2, 30, dir, background)
dir += 1
dir2 += 1
drawfillbox (20, dir2, 30, dir, white)
drawbox (20, dir2, 30, dir, black)
delay (stickSpeed)
%View.Update
end MoveUp1P
procedure MoveDown1P
drawfillbox (20, dir2, 30, dir, background)
dir -= 1
dir2 -= 1
drawfillbox (20, dir2, 30, dir, white)
drawbox (20, dir2, 30, dir, black)
delay (stickSpeed)
%View.Update
end MoveDown1P
procedure MoveUp2P
drawfillbox (maxx - 20, dir4, maxx - 30, dir3, background)
dir3 += 1
dir4 += 1
drawfillbox (maxx - 20, dir4, maxx - 30, dir3, white)
drawbox (maxx - 20, dir4, maxx - 30, dir3, black)
delay (stickSpeed)
%View.Update
end MoveUp2P
procedure MoveDown2P
drawfillbox (maxx - 20, dir4, maxx - 30, dir3, background)
dir3 -= 1
dir4 -= 1
drawfillbox (maxx - 20, dir4, maxx - 30, dir3, white)
drawbox (maxx - 20, dir4, maxx - 30, dir3, black)
delay (stickSpeed)
%View.Update
end MoveDown2P
procedure Pause
end Pause
process Sound
Music.Sound (100, 70)
Music.SoundOff
end Sound
process WriteScore
open : scoresFile, "High Scores.txt", put, mod
put : scoresFile, player1, " VS ", player2, " : ", score1P, " - ", score2P
close : scoresFile
end WriteScore
process BouncyBall
loop
locate (1, 1)
colorback (green)
%put " x ", x, " y ", y, " dir ", dir, " dir2 ", dir2, " dir3 ", dir3, " dir4 ", dir4
%Draw.Text ("1P Score = ", 0, maxy - 18, scoreFont, red)
put player1, ' ', score1P
locate (1, 43)
put player2, ' ', score2P
x += dx
y += dy
delay (ballSpeed) % Balls speed
drawfilloval (x, y, 5, 5, yellow)
drawoval (x, y, 5, 5, black)
drawfillbox ((maxx div 2) - 10, 0, (maxx div 2), maxy, white)
drawbox ((maxx div 2) - 10, 0, (maxx div 2), maxy, black)
View.Update
drawfilloval (x, y, 5, 5, background)
% BOUNDARIES
if (x = 40) and (y >= dir and y <= dir2) then
fork Sound
dx := -dx
elsif (x < 40) then
score2P += 1
fork DrawText
fork WriteScore
x := 550
y := 300
elsif (x >= maxx - 40) and (y >= dir3 and y <= dir4) then
fork Sound
dx := -dx
elsif (x > maxx - 40) then
score1P += 1
fork DrawText
fork WriteScore
x := 70
y := 300
elsif (y = 0) or (y = maxy - 20) then
fork Sound
dy := -dy
end if
end loop
end BouncyBall
fork BouncyBall
loop
Input.KeyDown (getKey)
if getKey ('w') then
MoveUp1P
end if
if getKey ('s') then
MoveDown1P
end if
if getKey (KEY_UP_ARROW) then
MoveUp2P
end if
if getKey (KEY_DOWN_ARROW) then
MoveDown2P
end if
if getKey (KEY_ENTER) then
Pause
end if
if getKey (KEY_ESC) then
% Need to find out how to cancel a process
% Take out fork writescore before you put this
% open : scoresFile, "High Scores.txt", put, seek, mod
% put : scoresFile, player1, " VS ", player2, " : ", score1P, " - ", score2P
% seek : scoresFile, *
% close : scoresFile
quit
MainMenu
end if
% 1P Boundaries
if (dir <= 0) and (dir2 <= 80) then
dir := 0
dir2 := 80
elsif (dir >= maxy - 80) and (dir2 >= maxy - 80) then
dir2 := maxy
dir := maxy - 80
end if
% 2P Boundaries
if (dir3 <= 0) and (dir4 <= 80) then
dir3 := 0
dir4 := 80
elsif (dir3 >= maxy - 80) and (dir4 >= maxy - 80) then
dir3 := maxy - 80
dir4 := maxy
end if
end loop
[code]
[color=#888888][size=85]Archived topic from Iceteks, old topic ID:3976, old post ID:35033[/size][/color]