Fred Agbo
September 25, 2026
bR9RLT
from pgl import GWindow, GRect, GOval
import random
WIDTH = 800
HEIGHT = 800
SIZE = 700
DART_SIZE = 10
gw = GWindow(WIDTH, HEIGHT)
background = GRect(
WIDTH / 2 - SIZE / 2,
HEIGHT / 2 - SIZE / 2,
SIZE,
SIZE
)
background.set_filled(True)
background.set_color('gray')
gw.add(background)
target = GOval(
WIDTH / 2 - SIZE / 2,
HEIGHT / 2 - SIZE / 2,
SIZE,
SIZE
)
target.set_filled(True)
target.set_color('darkgray')
gw.add(target)
attempts = 1000
successful_strikes = 0
for i in range(attempts):
x = random.uniform(WIDTH / 2 - SIZE / 2, WIDTH / 2 + SIZE / 2)
y = random.uniform(HEIGHT / 2 - SIZE / 2, HEIGHT / 2 + SIZE / 2)
dart = GOval(
x - DART_SIZE / 2,
y - DART_SIZE / 2,
DART_SIZE,
DART_SIZE
)
dart.set_filled(True)
distance_to_center = (
(x - WIDTH / 2)**2 + (y - HEIGHT / 2)**2
) ** (1/2)
if distance_to_center < SIZE / 2:
dart.set_fill_color('red')
successful_strikes += 1
else:
dart.set_fill_color('blue')
gw.add(dart)
print(successful_strikes / attempts * 4 )
from pgl import GWindow, GLabel, GRect
import random
from english import ENGLISH_WORDS
WIDTH = 500
HEIGHT = 200
gw = GWindow(WIDTH, HEIGHT)
word = random.choice(ENGLISH_WORDS).capitalize()
size = random.randint(20, 100)
label = GLabel(word, 0, HEIGHT / 2)
label.set_font(f"{size}pt serif")
gw.add(label)
box = GRect(
label.get_x(),
label.get_y() - label.get_ascent(),
label.get_width(),
label.get_ascent() + label.get_descent()
)
box.set_color('red')
gw.add(box)

# Just continuing from the starting template...
temp = 10
for i in range(MARKER_START_Y, BASE - THERM_HEIGHT, -MARKER_STEP):
line = GLine(
WIDTH / 2 + THERM_WIDTH / 2,
i,
WIDTH / 2 - THERM_WIDTH / 4,
i
)
line.set_line_width(2)
gw.add(line)
lab = GLabel(f"{temp}", WIDTH / 2 + THERM_WIDTH, i)
gw.add(
lab,
WIDTH / 2 + THERM_WIDTH,
i + lab.get_ascent() / 2
)
temp += 10
