2 dimensional dynamic grid effect (QB64 code)

This is the basic code for the 2 dimensional grid function that will end up being the main radar effect in Critical Domain.

Posted by on - Intermediate Client Side Coding

SCREEN _NEWIMAGE(1024, 768, 32), 0, 1, 0

DIM gridx(33, 33)
DIM gridy(33, 33)
DIM gridxm(33, 33)
DIM gridym(33, 33)

FOR b = 0 TO 32
FOR a = 0 TO 32
gridx(a, b) = a * 32
gridy(a, b) = b * 32
NEXT
NEXT

test1 = 1
RANDOMIZE TIMER

originx = 512
originy = 768 / 2

DO
FOR b = 1 TO 32
FOR a = 1 TO 32

LINE (gridx(a, b), gridy(a, b))-(gridx(a, b - 1), gridy(a, b - 1)), _RGB(a * 8, 0, b * 8)
LINE (gridx(a, b), gridy(a, b))-(gridx(a - 1, b), gridy(a - 1, b)), _RGB(a * 8, 0, b * 8)
NEXT
NEXT

FOR b = 1 TO 32
FOR a = 1 TO 32
IF gridx(a, b) > wellx - 200 AND gridx(a, b) < wellx + 200 THEN
IF gridy(a, b) > welly - 200 AND gridy(a, b) < welly + 200 THEN
gridx(a, b) = gridx(a, b) + ((wellx - gridx(a, b)) * .02)
gridy(a, b) = gridy(a, b) + ((welly - gridy(a, b)) * .02)
END IF
END IF

gridx(a, b) = gridx(a, b) + ((a * 32 - gridx(a, b)) * .01)
gridy(a, b) = gridy(a, b) + ((b * 32 - gridy(a, b)) * .01)

NEXT
NEXT

timez = timez + .05

IF diamode = 0 THEN
diameter = diameter + 1
IF diameter > 500 THEN diamode = 1
END IF
IF diamode = 1 THEN
diameter = diameter - 1
IF diameter < 1 THEN diamode = 0
END IF

wellx = originx - (diameter * (SIN(timez)))
welly = originy - (diameter * (COS(timez)))

IF timez > 6.2 THEN timez = 0
_LIMIT 60

PCOPY 1, 0
CLS 1
LOOP WHILE INKEY\$ = ""