Hi there . I made a litle game about virus trying to kill us . This is a game where you can only run forward trying to avoid viruses .You have to try to get as much antidote to heal yourself . Let's see how many points you can get before the fatal outcome .
// Project: Coronavirus
// Created: 2020-03-31
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Coronavirus" )
SetWindowSize( 800, 600, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 640, 480 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 60, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
type virus
x as float
y as float
col as float
ang as float
size as float
endtype
dim bl[14] as virus
for i= 1 to 14
bl[i].x =10+ random(0,630)
bl[i].y =10+ random(0,430)
bl[i].col=makecolor(255,0,0)
bl[i].ang=random(0,360)
bl[i].size=5
next
`Antidot ------------------
bl[13].size=12
bl[13].col=makecolor(255,255,255)
bl[14].col=makecolor(0,255,0)
`player
bl[14].x=300
bl[14].y=400
bl[14].ang=-90
for i= 1 to 14
drawellipse(bl[i].x,bl[i].y,bl[i].size,bl[i].size ,bl[i].col,bl[i].col,1)
next
health#=100
do
w=makecolor(30,30,155)
drawbox(0,0,640,480,w,w,w,w,1)
for i= 1 to 14
drawellipse(bl[i].x,bl[i].y,bl[i].size,bl[i].size,bl[i].col,bl[i].col,1)
next
`screen limits
for i= 1 to 13
if bl[i].x<1
bl[i].x=1
bl[i].ang=random(0,360)
endif
if bl[i].y<1
bl[i].y=1
bl[i].ang=random(0,360)
endif
if bl[i].x>640
bl[i].x=640
bl[i].ang=random(0,360)
endif
if bl[i].y>480
bl[i].y=480
bl[i].ang=random(0,360)
endif
next
if bl[14].x<0 then bl[14].x=0
if bl[14].y<0 then bl[14].y=0
if bl[14].x>640 then bl[14].x=640
if bl[14].y>480 then bl[14].y=480
if ( GetRawKeyState( 37 ) ) then bl[14].ang = bl[14].ang-4
if ( GetRawKeyState( 39 ) ) then bl[14].ang = bl[14].ang+4
if health#>0
for i= 1 to 14
move(i,bl[i].ang)
next
endif
xx=bl[14].x+cos(bl[14].ang)*10
yy=bl[14].y+sin(bl[14].ang)*10
drawellipse(xx,yy,2,2,w,w,0)
drawline(xx,yy,bl[14].x,bl[14].y,bl[14].col,bl[14].col)
w=makecolor(255,0,0)
for i= 1 to 12
dx#=bl[i].x-bl[14].x
dz#=bl[i].y-bl[14].y
dist#=sqrt((dx#*dx#)+(dz#*dz#))
if dist#<20+bl[i].size
drawellipse(bl[14].x,bl[14].y,20,20,w,w,0)
if health#>0
health#=health#-0.4
bl[i].size=bl[i].size+0.3
endif
endif
next
`Dist to the antidot
dx#=bl[13].x-bl[14].x
dz#=bl[13].y-bl[14].y
dist2#=sqrt((dx#*dx#)+(dz#*dz#))
if dist2#<20
s=s+1
if s=2 then antidot=antidot+10
if s=2 then point=point+2
w=makecolor(255,255,255)
drawellipse(bl[14].x,bl[14].y,25,25,w,w,0)
else
s=0
endif
if antidot=30
health#=health#+30
antidot=0
point=point+10
for b= 1 to 12
bl[b].size=5
next
if health#>100 then health#=100
endif
if health#<1
for i=1 to 10
print("")
next
print(" G A M E O V E R " )
endif
drawbox(bl[13].x-8 ,bl[13].y-2,bl[13].x+8,bl[13].y+2,w,w,w,w,1)
drawbox(bl[13].x-2 ,bl[13].y-8,bl[13].x+2,bl[13].y+8,w,w,w,w,1)
print ( "Health "+str (trunc(health#)))
print ( "Antidot "+str(antidot))
print ( "Points "+str(point))
sync()
loop
function move(n,ang)
bl[n].x=bl[n].x+cos(bl[n].ang)*2
bl[n].y=bl[n].y+sin(bl[n].ang)*2
endfunction
Cheers.
I'm not a grumpy grandpa