> Quite BASIC
>
Welcome to the clubhouse!
User login
Username:
*
Password:
*
Create new account
Request new password
Navigation
Quite BASIC
Blog
Projects
Help
Forums
Pong with Scoring
Posted
July 7th, 2007
by
nikko
in
Games
Your vote:
Current rating:
1
2
3
4
5
Category
Games
Description
A version of the Ping Pong game that keeps the score
>> See More projects by nikko
Level
>> Open this project at the main Quite BASIC Page
1000 REM Pong 1010 REM Quite BASIC Game Project 1020 REM ------------------------ 1030 CLS 2010 REM P and Q are the vertical positions of the paddles 2020 REM R and S are the speeds of the paddles 2030 LET P = 11 2040 LET R = 0 2050 LET Q = 11 2060 LET S = 0 2070 REM Draw the paddles at their initial positions 2080 FOR I = 11 TO 14 2090 PLOT 0, I, "white" 2100 PLOT 24, I, "white" 2110 NEXT I 2200 REM A, B hold the scores 2210 LET A = 0 2220 LET B = 0 2500 REM A new ball 2510 CLT 2520 PRINT " " + A + " " + B 2530 PRINT 2550 PRINT "LEFT PLAYER RIGHT PLAYER" 2560 PRINT "UP: Q UP: P" 2570 PRINT "STOP: A STOP: L" 2580 PRINT "DOWN: Z DOWN: <" 2590 PRINT "****************************" 2600 REM X,Y hold the position of the ball 2610 LET X = 10 2620 LET Y = 3 2630 REM U,V hold the speed of the ball 2640 IF (A + B) % 2 THEN LET V = -1 ELSE LET V = 1 2650 LET U = 1 2660 REM W is a random component to the y-direction speed 2670 LET W = 1 3000 REM The keyboard input loop 3010 PAUSE 25 + 50 * (5 - LEVEL) 3020 REM Before moving ahead, we ensure we handle all of the keyboard buffer 3030 LET C = GETCHAR() 3040 IF C = "" THEN GOTO 4000 3050 IF C = "Q" OR C = "q" THEN LET R = 1 3060 IF C = "A" OR C = "a" THEN LET R = 0 3070 IF C = "Z" OR C = "z" THEN LET R = -1 3080 IF C = "P" OR C = "p" THEN LET S = 1 3090 IF C = "L" OR C = "l" THEN LET S = 0 3100 IF C = "<" OR C = "," THEN LET S = -1 3110 GOTO 3000 4000 REM Move the ball 4010 PLOT X, Y, "gray" 4020 LET X = X + V 4030 LET Y = Y + U * W 4040 PLOT X, Y, "white" 4050 REM Bounce off the top and bottom walls 4060 REM The plotted y-position is rounded so we round here 4070 REM when we are doing collision detection 4080 LET Z = ROUND(Y) 4090 IF Z <= 1 OR Z >= 23 THEN LET U = -U 4100 REM Check paddle position before bouncing 4110 IF X <> 1 AND X <> 23 THEN GOTO 5000 4120 IF X = 1 AND (Z < P - 1 OR Z > P + 4) THEN GOTO 6000 4130 IF X = 23 AND (Z < Q - 1 OR Z > Q + 4) THEN GOTO 6000 4140 REM Bounce on the paddle 4150 LET V = -V 4160 REM Change the random component of the y-speed 4170 LET W = 0.9 + RAND(0.6) 5000 REM Move the paddles 5010 IF P = 21 AND R = 1 THEN LET R = 0 5010 IF P = 0 AND R = -1 THEN LET R = 0 5010 IF Q = 21 AND S = 1 THEN LET S = 0 5010 IF Q = 0 AND S = -1 THEN LET S = 0 5100 IF R <> 1 THEN GOTO 5200 5110 PLOT 0, P, "gray" 5130 LET P = P + R 5140 PLOT 0, P + 3, "white" 5200 IF R <> -1 THEN GOTO 5300 5210 PLOT 0, P + 3, "gray" 5230 LET P = P + R 5240 PLOT 0, P, "white" 5300 IF S <> 1 THEN GOTO 5400 5310 PLOT 24, Q, "gray" 5330 LET Q = Q + S 5340 PLOT 24, Q + 3, "white" 5400 IF S <> -1 THEN GOTO 5500 5410 PLOT 24, Q + 3, "gray" 5430 LET Q = Q + S 5440 PLOT 24, Q, "white" 5500 GOTO 3000 6000 IF X > 10 THEN LET A = A + 1 ELSE LET B = B + 1 6010 PLOT X, Y, "gray" 6020 GOTO 2500
Login
or
register
to post comments
Popular Projects
Trebuchet II
New version with a mini story plus the popups are gone (yay!). And watch out for the dragon! The popup is replaced by pressing +/- to change the angle and pressing 1-9 to set the force.
Pong with Scoring
A version of the Ping Pong game that keeps the score
Snake Skin
A variant of the Snake game but with a snake skin that moves.
Countries Hangman
A version of the Hangman game where the words are all countries
Tool Name Hangman
A version of the Hangman game for tools.
more
Who's online
There are currently
0 users
and
0 guests
online.
Who's new
darylroy
sage sklar
masonsd
ace
JavaAnders
Active forum topics
Members
more
New forum topics
Members
more