Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Pong
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
king202




PostPosted: Fri May 21, 2004 11:10 am   Post subject: Pong

Ok I have a pong game and I need some help. Here is the code

setscreen ("graphics:450;400")

var pointx, pointy, level, difficult, psize, bouncer, bouncex, bouncey : int
:= 0
var centy, centx : int := 20
var reply:string
var mover : string (1)


var col, score, endscore : int := 0
var font1 : int
procedure start
var winID : int
winID := Window.Open ("postion:400;800,graphics:450;400")
put "Welcome to " ..
put "Pong "
Text.Color (brightblue)
put "! Enjoy."
put "Please the ball speed. (1 is fast, 5 is slow)"
get level
difficult := level * 5
put "Enter the paddle length in pixels."
get psize
put "Enter the ball bouncing style. (1, 2, or 3)"
get bouncer
if bouncer = 1 then
bouncex := 2
bouncey := 2
elsif bouncer = 2 then
bouncex := 2
bouncey := 3
elsif bouncer = 3 then
bouncex := 2
bouncey := 4
end if
Text.Locate (12, 18)
Text.Color (brightblue)
put "How many outs would you like?"
Text.Locate (13, 29)
Text.Color (brightred)
get endscore
cls
end start
process paddle
Draw.FillBox (5, col, 10, col + psize, blue)
loop
if hasch then
getch (mover)
if mover = chr (200) then
col := col + 10
elsif mover = chr (208) then
col := col - 10
end if
end if
Draw.FillBox (5, col, 10, col + psize, blue)

end loop
end paddle
process ball
loop
Draw.FillOval (centx, centy, 5, 5, red)
delay (difficult)
if centx > maxx then

pointx := 1
elsif centx < 0 then

score := score + 1
if score = endscore then
loop
Draw.FillBox (0, 0, maxx, maxy, red)
end loop
end if
pointx := 0
end if

if centy > maxy then

pointy := 1
elsif centy < 0 then

pointy := 0
end if

cls
if pointx = 0 then
centx := centx + bouncex
elsif pointx = 1 then
centx := centx - bouncex
end if

if pointy = 0 then
centy := centy + bouncey
elsif pointy = 1 then
centy := centy - bouncey
end if
end loop
end ball

process outer
loop
if centx - 5 < 10 then
if centy > col + psize or centy < col then
loop
Draw.FillOval (maxx div 2, maxy div 2, 100, 100,
brightred)
exit when hasch
end loop

else

pointx := 0
end if
end if
end loop
end outer

start
fork paddle
fork ball
fork outer

ok I I want it to say at the end You Lose.Do you want to play again?
when the program is done. How would you do that?
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Fri May 21, 2004 12:10 pm   Post subject: (No subject)

1) Use [ code] tags.
2) Don't post all of your code...just the problematic code, if it so exists. You are more likely to get useful help.
3) Don't use processes for simple games. You are better off using loops.
4) Simply use a loop for your question:
code:

loop
%...code
put "Play again?"
get response
if response = "n" then
exit
end if
end loop
king202




PostPosted: Sat May 22, 2004 9:51 am   Post subject: (No subject)

That is great put i still cant solve my problem can someone please help
guruguru




PostPosted: Sat May 22, 2004 11:22 am   Post subject: (No subject)

Quote:
1) Use [ code] tags.
2) Don't post all of your code...just the problematic code, if it so exists. You are more likely to get useful help.
3) Don't use processes for simple games. You are better off using loops.


Maybe you should listen to what delos said... you will get more help. Truthfully, i dont want to go through all you code to find your problem.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: