'COVID-19 in QB64
'By Ashish
'1 Jun, 2020
'
'WARNING:Use mask. Apply santizer after closing the program.
' 2 Jun, 2020 added a little son of COVID-19 TDB
' 2 Jun, 2020 modularizing the _GL actions TDB
'2 Jun, 2020 an array of virus and a continuous restarting by Enter and quit by Space TDB
'2 Jun, 2020 made the viruses rotate on its axis.
_TITLE "We are all Covid-19 :-)"
Initialize
LOCATE 1, 1:
PRINT "Space to quit, Enter to change viruses" END ' a logical end to the flow
'------------ SUBs and FUNCTIONs----------------------------
virus
(z
).r
= 0.1 + (RND / 5) virus
(z
).
POS.y
= 1 - (RND * 2) virus
(z
).
POS.x
= 1 - (RND * 2) virus
(z
).
POS.z
= 1 - (RND * 2) 'virus(z).POS.z = 0 virus
(z
).Vxz
= 20 - (RND * 10) virus
(z
).Vyz
= 20 - (RND * 10) virus
(z
).C.R
= 1 - (RND * 1) virus
(z
).C.G
= 1 - (RND * 1) virus
(z
).C.B
= 1 - (RND * 1) virus
(z
).C.A
= 1 - (RND * 1) glAllow = -1
in = 1
SUB DrawLines
(viru
AS COVID19
)
SUB DrawPoints
(viru
AS COVID19
)
SUB DrawVirus
(v
AS COVID19
) ' setting position and rotation
v.rotY = v.rotY + 2
_glMaterialfv _GL_FRONT_AND_BACK
, _GL_DIFFUSE
, glVec4
(v.C.R
, v.C.G
, v.C.B
, v.C.A
)
' make the sphere
glutSolidSphere v.r, v.Vxz, v.Vyz
' make lines
DrawLines v
' make points
DrawPoints v
InitGL init, aspect
_glLightfv _GL_LIGHT0
, _GL_AMBIENT
, glVec4
(0.0, 0.0, 0.0, 1) _glLightfv _GL_LIGHT0
, _GL_DIFFUSE
, glVec4
(0.8, 0.8, 0.8, 1) _glLightfv _GL_LIGHT0
, _GL_SPECULAR
, glVec4
(1, 1, 1, 1) _glLightfv _GL_LIGHT0
, _GL_POSITION
, glVec4
(0, 0, 10, 1)
gluLookAt 0, 0, 3, 0, 0, 0, 0, 1, 0
DrawVirus virus(z)
FUNCTION glVec4%&
(x
, y
, z
, w
) 'give the offset of the given vector internal_vec4(0) = x
internal_vec4(1) = y
internal_vec4(2) = z
internal_vec4(3) = w
glVec4%&
= _OFFSET(internal_vec4
())