Skip to content

Instantly share code, notes, and snippets.

@timsonner
Last active April 4, 2023 14:24
Show Gist options
  • Select an option

  • Save timsonner/98ee661c6b0383326372aea5a7bc3317 to your computer and use it in GitHub Desktop.

Select an option

Save timsonner/98ee661c6b0383326372aea5a7bc3317 to your computer and use it in GitHub Desktop.
QBasic. Draw random circle at random coordinate with random radius and fill color.
SCREEN 12 ' Set screen mode to 640x480, 32-bit color
DO ' Infinite loop
RANDOMIZE TIMER ' initialize the random number generator
' Generate random circle properties
x = INT(RND * 641) ' Random x-coordinate 0 to 640
y = INT(RND * 481) ' Random y-coordinate 0 to 480
r = INT(RND * 101) ' Random radius 0 to 100
c = INT(RND * 16) ' Random color 0 to 15
' Possible colors
' 0:black, 1:blue, 2:green, 3:cyan, 4:red, 5:magenta, 6:brown, 7:light gray,
' 8:dark gray, 9:light blue, 10:light green, 11:light cyan, 12:light red,
' 13:light magenta, 14:yellow, 15:white
COLOR c, 0 ' Set Color to c, background color to black
CIRCLE (x, y), r ' Draw circle with center at coordinate (x, y) with radius r
PAINT (x, y), c ' Fill shape at coordinate with color c
LOOP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment