§ Иллюстрация

Программа, которая рисует движущиеся звезды на QBasic

§ Код программы

1SCREEN 13
2
3TYPE Point3D
4  x AS INTEGER
5  y AS INTEGER
6  z AS INTEGER
7  c AS INTEGER
8END TYPE
9
10DIM star(0 TO 255) AS Point3D
11
12FOR i = 0 TO 255
13
14  star(i).x = RND * 256 - 128
15  star(i).y = RND * 256 - 128
16  star(i).z = RND * 128 + 16
17  star(i).c = RND * 15 + 16
18
19NEXT
20
21PPD = 100
22
23DO
24
25  FOR i = 0 TO 255
26
27    z = star(i).z
28    x = 160 + PPD * star(i).x / z
29    y = 100 - PPD * star(i).y / z
30    PSET (x, y), 0
31
32    z = z - 2
33    IF z < 16 THEN z = z + 128
34    star(i).z = z
35
36    x = 160 + PPD * star(i).x / z
37    y = 100 - PPD * star(i).y / z
38    PSET (x, y), star(i).c
39
40  NEXT
41
42LOOP WHILE INKEY$ = ""