Computer Science Canada better pong game |
Author: | Wallace [ Tue Jan 23, 2007 9:08 am ] |
Post subject: | better pong game |
var downLine := 1 var x, y : int var dx, dy := 1 var player1, player2 : string var ok : boolean := false var background := green var menuFont := 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 := 10 var ballSpeed := -15 x := 70 y := 313 setscreen ("cursor") process DrawText loop for i : 0 .. 255 Draw.Text ("JEFF'S PONG GAME", maxx div 2 - 150, maxy div 2,menuFont, i) end for exit when ok = true end loop end DrawText procedure MainMenu drawfillbox (0, 0, maxx, maxy, yellow) fork DrawText colorback (yellow) locate (17, 25) put " Player 1's Name: " .. get player1 : * locate (18, 25) put " Player 2's Name: " .. get player2 : * put " Player 1 uses the arrow keys, and Player 2 uses the W,S,A,D keys" delay (1300) 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) 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) 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) 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) end MoveDown2P procedure Pause end Pause process Ball loop locate (1, 1) colorback (yellow) 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) if (x = 40) and (y >= dir and y <= dir2) then dx := -dx elsif (x < 40) then score2P += 1 x := 550 y := 300 elsif (x >= maxx - 40) and (y >= dir3 and y <= dir4) then dx := -dx elsif (x > maxx - 40) then score1P += 1 x := 70 y := 300 elsif (y = 0) or (y = maxy - 20) then dy := -dy end if end loop end Ball fork Ball 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 quit MainMenu end if % Player 1 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 % Player 2 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 |
Author: | Wallace [ Tue Jan 23, 2007 9:09 am ] |
Post subject: | Re: better pong game |
can you guys rate my game from 1 to 10, and give it improvements, plz |
Author: | Windsurfer [ Tue Jan 23, 2007 9:22 am ] | ||
Post subject: | RE:better pong game | ||
I can't rate it, because I'm not on computer with turing... but I REALLY wish people could use code tags. Like this:
Also, you double posted. Shun the double poster! Shuuun! Shuuuuuuuuuuuuuunnnnnnnnnnned! |
Author: | StealthArcher [ Tue Jan 23, 2007 11:52 am ] | ||
Post subject: | Re: better pong game | ||
There now we can get a better look. |
Author: | War_Caymore [ Tue Jan 23, 2007 2:41 pm ] |
Post subject: | RE:better pong game |
Goddamn! Either do one of two things: 1) slow down the ball or 2) speed up the paddles. also, the "jeff's pong game" seems to erase when the ball moves through it. no glitches with the ball, thought (which seems to be my problem right now) other than taht, it's palyable, good job. Edit: sry, 6/10. final word: could be improved. |
Author: | CodeMonkey2000 [ Tue Jan 23, 2007 4:38 pm ] |
Post subject: | RE:better pong game |
Dont use processes. Your collision looks a bit off. I would rate it 8/10, because i am a good person ![]() |