'--- Création à partir d'un autre programme et modifier légèrement.---
'--- Pris sur QbasicNews.com mais reste en anglais. ---
'--- Fonctionne très bien sur QuickBasic 4.5 fr Windows XP. ---
DIM picture(1000), sprite(1000), spritesh(1000)
SCREEN 13
CIRCLE (10, 10), 10, 4
PAINT (10, 10), 1, 4
CIRCLE (10, 10), 6, 4
PAINT (10, 10), 0, 4
GET (0, 0)-(20, 20), sprite
LINE (0, 0)-(20, 20), 255, BF
CIRCLE (10, 10), 10, 4
PAINT (10, 10), 1, 4
CIRCLE (10, 10), 6, 4
PAINT (10, 10), 255, 4
GET (0, 0)-(20, 20), spritesh
CLS
FOR i = 0 TO 5555 STEP .1
Cc = 0 + INT(RND * 4)
IF Cc = 0 THEN Cc = 0
IF Cc = 1 THEN Cc = 6
IF Cc = 2 THEN Cc = 8
IF Cc = 3 THEN Cc = 2
PSET ((RND * 320), (RND * 200)), Cc
NEXT i
FOR y = 1 TO 200 STEP 16
FOR x = 1 TO 320 STEP 16
LINE (x, y)-(320 - x, 200 - y), (RND * 15)
NEXT: NEXT
x = 1: y = 1 'Sprite X and Y coords
xadj = 1: yadj = 1 'Moves the ball
delay = 40000 'Adjust this for speed...
GET (x, y)-(x + 20, y + 20), picture 'Get the background
'---=============================================================---
DO 'Start loop
press$ = INKEY$ 'get ready for key presses...
PUT (x, y), spritesh, AND ' put the sprite down
PUT (x, y), sprite, OR
oldx = x 'Record old position
oldy = y
x = x + xadj 'Move the ball
y = y + yadj
WAIT &H3DA, 8 'This just keeps things clean, don't worry about it...
PUT (oldx, oldy), picture, PSET 'Put the old background down...
GET (x, y)-(x + 20, y + 20), picture 'Get The new background
'PUT (x, y), sprite, PSET 'Finally, put the sprite down...
PUT (x, y), spritesh, AND ' put the sprite down
PUT (x, y), sprite, OR
IF y > 170 THEN yadj = -1 'This is if it hits the walls...
IF y < 10 THEN yadj = 1
IF x > 290 THEN xadj = -1
IF x < 10 THEN xadj = 1
FOR i = 1 TO delay: NEXT 'This adds a delay, If its to fast or slow...
LOOP UNTIL press$ = CHR$(27) 'Loop until Escape is pressed...