06-07-2022, 10:45 AM
vroom
Code: (Select All)
'Moving hex grid
SCREEN _NEWIMAGE(480, 480, 32)
s = 35
sb = s / 2
ho = s + (s * COS(_D2R(60)))
vo = 2 * (s * SIN(_D2R(60)))
ymax = 20
DO
CLS
k = k - 1
IF k MOD vo = 0 THEN k = 0
FOR x = -10 TO 10
FOR y = 0 TO ymax
IF x MOD 2 = 0 THEN b = vo / 2 ELSE b = 0
x11 = x * ho - sb
y11 = y * vo + b + k
x12 = x * ho + s - sb
y12 = y * vo + b + k
p1 = 240 + x11 * 700 / (y11 + 250)
q1 = 200 * 700 / (y11 + 250)
p2 = 240 + x12 * 700 / (y12 + 250)
q2 = 200 * 700 / (y12 + 250)
'LINE (x11, y11)-(x12, y12)
LINE (p1, q1)-(p2, q2)
x21 = x * ho + s - sb
y21 = y * vo + b + k
x22 = x * ho + s + ho - s - sb
y22 = y * vo + b - (vo / 2) + k
p1 = 240 + x21 * 700 / (y21 + 250)
q1 = 200 * 700 / (y21 + 250)
p2 = 240 + x22 * 700 / (y22 + 250)
q2 = 200 * 700 / (y22 + 250)
'LINE (x21, y21)-(x22, y22)
LINE (p1, q1)-(p2, q2)
x31 = x * ho + s - sb
y31 = y * vo + b + k
x32 = x * ho + s + ho - s - sb
y32 = y * vo + b + (vo / 2) + k
p1 = 240 + x31 * 700 / (y31 + 250)
q1 = 200 * 700 / (y31 + 250)
p2 = 240 + x32 * 700 / (y32 + 250)
q2 = 200 * 700 / (y32 + 250)
'LINE (x31, y31)-(x32, y32)
LINE (p1, q1)-(p2, q2)
NEXT y
NEXT x
LINE (0, 0)-(480, 100), _RGB(0, 0, 0), BF
LINE (0, 101)-(480, 101)
_LIMIT 50
_DISPLAY
LOOP UNTIL _KEYDOWN(27)
SYSTEM