Ball& = _NEWIMAGE(640, 480, 32)SCREEN Ball&CONST Left = 1CONST right = -1CONST YDecay = 1.8CONST Drag = .03CONST Gravity = .5DIM SHARED DirectionDirection = 1DIM SHARED XMotionXMotion = 8DIM SHARED xx = 20DIM SHARED yy = 0DIM SHARED DropDrop = 0LINE (0, 200)-(639, 480), _RGB(0, 200, 0), BFDO _LIMIT 40 CIRCLE (x, y), 10, _RGB(0, 0, 0) PAINT (x, y), _RGB(0, 0, 0) Roll Fall CIRCLE (x, y), 10, _RGB(255, 0, 0) PAINT (x, y), _RGB(255, 0, 0) _DISPLAYLOOP UNTIL INKEY$ = "q"SYSTEM'--------------------------------------------SUB FallDrop = Drop + Gravity: y = y + DropIF y > 189 THEN y = 189: Drop = -Drop: Drop = Drop + YDecayEND SUB'--------------------------------------------SUB Roll' --------- ball hit right wall so bounce backIF x > 630 THEN x = 630: Direction = -1IF Direction = right THEN x = x - XMotion: XMotion = XMotion - Drag' --------- ball hit left wall so bounce backIF x < 5 THEN x = 5: Direction = 1IF Direction = Left THEN x = x + XMotion: XMotion = XMotion - Drag' --------- Ball stopped so throw ball again randomlyIF XMotion < 0 AND y = 189 THEN XMotion = INT(RND * 6) + 4 y = INT(RND * 80) + 20 Drop = INT(RND * 8) + 1 Drop = -Drop_DELAY .5 ' ----- Just to put a little pause before the ball gets throw again.END IFEND SUB
REMDEFINT A-ZDIM Ball%(540)DIM Mask%(540)DIM Background%(540)DIM PaddleBak%(102) '10x40SCREEN 12_FULLSCREENPRINT "HELLO WORLD"PLAY "ageba"PRINT "Can anyone tell me who owns this code ? "CX = 20: CY = 10: oldcx = CX: oldcy = CYpx = 420: py = 440: oldpx = px: oldpy = pyGOSUB MakBallGOSUB MakMaskCLSGOSUB MakBackgroundHorizontal = 4: Vertical = 4DO Past! = TIMER GOSUB GetKey PUT (oldpx, oldpy), PaddleBak%(0), PSET PUT (oldcx, oldcy), Background%(0), PSET GET (px, py)-(px + 39, py + 9), PaddleBak%(0) GET (CX, CY)-(CX + 19, CY + 19), Background%(0) LINE (px, py)-(px + 39, py + 9), 3, BF PUT (CX, CY), Mask%(0), AND 'draw ball PUT (CX, CY), Ball%(0), XOR 'draw ball GOSUB Movement GOSUB Boundary WHILE Past! = TIMER: WENDLOOP WHILE INKEY$ <> CHR$(27)SYSTEM'-GOSUBSGetKey:a% = 0a$ = INKEY$a$ = RIGHT$(a$, 1)IF LEN(a$) > 0 THEN a% = ASC(a$)RETURNMakBall:CIRCLE (9, 9), 9, 12PAINT (9, 9), 2, 12GET (0, 0)-(19, 19), Ball%(0)RETURNMakMask:FOR x = 0 TO 19 FOR y = 0 TO 19 z = POINT(x, y) IF z <> 0 THEN PSET (x, y), 0 ELSE PSET (x, y), 8 NEXT yNEXT xGET (0, 0)-(19, 19), Mask%(0)RETURNMakBackground:FOR x = 0 TO 699 STEP 3 LINE (x, 10)-(x - 50, 470), 7NEXT xGET (CX, CY)-(CX + 19, CY + 19), Background%(0)GET (px, py)-(px + 39, py + 9), PaddleBak%(0)RETURNMovement:oldcx = CX: oldcy = CYCX = CX + HorizontalCY = CY + Verticaloldpx = px: oldpy = pyIF a% = 75 THEN px = px - 4 IF px < 10 THEN px = 10END IFIF a% = 77 THEN px = px + 4 IF px > 590 THEN px = 590END IFRETURNBoundary:IF CX <= 10 THEN CX = 10 Horizontal = -HorizontalEND IFIF CX >= 620 THEN CX = 620 Horizontal = -HorizontalEND IFIF CY <= 10 THEN CY = 10 Vertical = -VerticalEND IFIF CY >= 420 THEN IF CX >= px AND CX <= px + 39 THEN CY = 420 Vertical = -Vertical END IFEND IFIF CY > 460 THEN ENDRETURN
'Don't use INKEY$ if you want to control 2 players:SCREEN 12' Set aside enough space to hold the sprite' Draw a filled circle for our spriteON ERROR GOTO errorhandleDIM ball%(1000000)CIRCLE (4, 3), 4, 4PAINT (4, 3), 12, 4' Get the sprite into the Ball% arrayGET (0, 0)-(8, 7), ball%(0)ponescore = 0ptwoscore = 0begin:char = char + 1numb = numb + 38CLSxmin = 10ymin = 10xmax = 630ymax = 470x = 25y = 25dx = 1dy = 1curpos = 50curtpos = 50DO: _LIMIT 100 'adjust higher for faster CLS ' program or game loop IF ScanKey%(17) THEN curpos = curpos - 1 IF ScanKey%(31) THEN curpos = curpos + 1 IF ScanKey%(72) THEN curtpos = curtpos - 1 IF ScanKey%(80) THEN curtpos = curtpos + 1 zerocodes% = ScanKey%(0) 'reset all array values to zero for next part of program PRINT "Player 1 : "; ponescore; " Player 2 : "; ptwoscore / 10 IF x > xmax - 15 AND y >= curtpos AND y <= curtpos + 100 THEN dx = -1 ELSEIF x > xmax THEN ponescore = ponescore + 1 END IF IF x < xmin + 15 AND y >= curpos AND y <= curpos + 100 THEN dx = 1 ELSEIF x < xmin THEN ptwoscore = ptwoscore + 1 END IF IF y > ymax - 5 THEN dy = -1 IF y < ymin + 5 THEN dy = 1 ' Display the sprite elsewhere on the screen x = x + dx y = y + dy PUT (x, y), ball%(0) LINE (20, curpos)-(20, curpos + 100) LINE (620, curtpos)-(620, curtpos + 100) _DISPLAY 'shows completed screen every callLOOPerrorhandle:RESUME beginFUNCTION ScanKey% (scancode%)STATIC Ready%, keyflags%()IF NOT Ready% THEN REDIM keyflags%(0 TO 127): Ready% = -1i% = INP(&H60) 'read keyboard statesIF (i% AND 128) THEN keyflags%(i% XOR 128) = 0IF (i% AND 128) = 0 THEN keyflags%(i%) = -1K$ = INKEY$ScanKey% = keyflags%(scancode%)IF scancode% = 0 THEN Ready% = 0 'allows program to reset all values to 0 with a REDIMEND FUNCTION