Computer Science Canada Pong |
Author: | king202 [ 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? |
Author: | Delos [ Fri May 21, 2004 12:10 pm ] | ||
Post 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:
|
Author: | king202 [ Sat May 22, 2004 9:51 am ] |
Post subject: | |
That is great put i still cant solve my problem can someone please help |
Author: | guruguru [ Sat May 22, 2004 11:22 am ] |
Post 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. |