11-23-2022, 04:58 AM
Just a basic demo of the Qix 'entity'. I used to enjoy this arcade game back in the day.
Using the mouse, you control a circle that it either follows (blue) or avoids (red). The mouse wheel changes the circle size - larger has a stronger effect.
Cheers!
Using the mouse, you control a circle that it either follows (blue) or avoids (red). The mouse wheel changes the circle size - larger has a stronger effect.
Cheers!
Code: (Select All)
'Qix interactive demo
'james2464 - Nov 22 2022
'BLUE circle = follow
'RED circle = avoid
'scroll mouse wheel to increase / decrease
Screen _NewImage(800, 600, 32)
Const PI = 3.141592654#
Randomize Timer
'origin
xx = 400: yy = 300
Dim c(10) As Long
c(1) = _RGB(100, 100, 200)
c(2) = _RGB(200, 100, 100)
Type qix
dir As Single
x1 As Integer
x2 As Integer
y1 As Integer
y2 As Integer
xx As Single
yy As Single
len1 As Single
c1 As Integer
c2 As Integer
c3 As Integer
End Type
Dim Shared q(7) As qix
Dim Shared qixtot, qxv, qyv, qpath, f
Dim Shared mx%, my%
qixtot = 7: qpath = 0: f = 1
'start
For t = 1 To qixtot
q(t).xx = xx: q(t).yy = yy: q(t).len1 = 40
Next t
_MouseHide
Do
_Limit 20
Do While _MouseInput
f = f - _MouseWheel * .1
Loop
If f > 2 Then f = 2
If f < -2 Then f = -2
mx% = _MouseX: my% = _MouseY
If mx% < 0 Then mx% = 0
If mx% > 800 Then mx% = 800
If my% < 0 Then my% = 0
If my% > 600 Then my% = 600
If qpath < 1 Then
qpath = Rnd * 40 + 2: qxv = Rnd * 30 - 15: qyv = Rnd * 30 - 15
olddir = q(1).dir: q(1).dir = olddir + Rnd * 2 - 1
End If
qpath = qpath - 1
For t = 7 To 2 Step -1
q(t).xx = q(t - 1).xx: q(t).yy = q(t - 1).yy
q(t).x1 = q(t - 1).x1: q(t).x2 = q(t - 1).x2
q(t).y1 = q(t - 1).y1: q(t).y2 = q(t - 1).y2
q(t).len1 = q(t - 1).len1
q(t).c1 = q(t - 1).c1: q(t).c2 = q(t - 1).c2: q(t).c3 = q(t - 1).c3
Next t
mousepointerfollow
q(1).xx = q(1).xx + qxv
If q(1).xx > 750 Then q(1).xx = 750
If q(1).xx < 50 Then q(1).xx = 50
q(1).yy = q(1).yy + qyv
If q(1).yy > 550 Then q(1).yy = 550
If q(1).yy < 50 Then q(1).yy = 50
q(1).dir = q(1).dir + Rnd * .4 - .2
q(1).len1 = q(1).len1 + Rnd * 8 - 4
If q(1).len1 > 100 Then q(1).len1 = 100
If q(1).len1 < 20 Then q(1).len1 = 20
x = Cos(q(1).dir) * q(1).len1
y = Sin(q(1).dir) * q(1).len1
q(1).x1 = q(1).xx + x: q(1).x2 = q(1).xx - x
q(1).y1 = q(1).yy - y: q(1).y2 = q(1).yy + y
q(1).c1 = q(1).c1 + Rnd * 60 - 30
If q(1).c1 < 80 Then q(1).c1 = 80
If q(1).c1 > 255 Then q(1).c1 = 255
q(1).c2 = q(1).c2 + Rnd * 60 - 30
If q(1).c2 < 80 Then q(1).c2 = 80
If q(1).c2 > 255 Then q(1).c2 = 255
q(1).c3 = q(1).c3 + Rnd * 60 - 30
If q(1).c3 < 80 Then q(1).c3 = 80
If q(1).c3 > 255 Then q(1).c3 = 255
'-------------------------------------------------
Cls
For t = 1 To qixtot
c(9) = _RGB(q(t).c1, q(t).c2, q(t).c3)
Line (q(t).x1, q(t).y1)-(q(t).x2, q(t).y2), c(9)
Next t
If f > 0 Then
Circle (mx%, my%), f * 10, c(1)
Else
Circle (mx%, my%), f * 10, c(2)
End If
_Display
Loop
Sub mousepointerfollow
If mx% < q(1).xx Then qxv = qxv - f
If mx% > q(1).xx Then qxv = qxv + f
If my% < q(1).yy Then qyv = qyv - f
If my% > q(1).yy Then qyv = qyv + f
End Sub