randomize timer()
sync on
make object cube 1,1
delete object 1
lorry$="Lorry"
car$="Car"
log$="---Log---"
turtle$="--Turtle--"
line$="______________________________________________________________________________________________________________"
dash$="____        ____        ____        ____        ____        ____        ____        ____        ____        "
frog$="<^>"
numberofvehicles=10
dim vehiclex(numberofvehicles)
dim vehicley(numberofvehicles)
dim speed#(numberofvehicles)
dim typeofvehicle(numberofvehicles)
for vehicle=1 to numberofvehicles
typeofvehicle(vehicle)=rnd(1)
speed#(vehicle)=(rnd(10)/10.0)+1.0
vehiclex(vehicle)=rnd(screen width())
if vehicle*2<=numberofvehicles
  vehicley(vehicle)=screen height()/2.0+rnd((screen height()/4.0))-text height(car$)*2
else
  vehicley(vehicle)=3*screen height()/4.0+rnd((screen height()/4.0))-text height(car$)*2
endif
next vehicle
 
numberoffloaters=10
dim floaterx(numberoffloaters)
dim floatery(numberoffloaters)
dim speedf#(numberoffloaters)
dim typeoffloater(numberoffloaters)
for floater=1 to numberoffloaters
typeoffloater(floater)=rnd(1)
speedf#(floater)=(rnd(10)/10.0)+1.0
floaterx(floater)=rnd(screen width())
if floater*2<=numberoffloaters
  floatery(floater)=rnd((screen height()/4.0))-text height(log$)*2
else
  floatery(floater)=screen height()/4.0+rnd((screen height()/4.0))-text height(log$)*2
endif
next floater
 
frogx=screen width()/2
frogy=screen height()-text height(frog$)
do
 
 
text 0,screen height()/2-text height(car$)*2-text height(line$),line$
text 0,3*screen height()/4-text height(car$)*2-text height(dash$),dash$
text 0,screen height()-text height(car$)-text height(line$),line$
 
for vehicle=1 to numberofvehicles
if typeofvehicle(vehicle)=0
  ink rgb(255,0,0),0
  text vehiclex(vehicle),vehicley(vehicle),car$
else
  ink rgb(255,255,0),0
  text vehiclex(vehicle),vehicley(vehicle),lorry$
endif
if vehicle*2<=numberofvehicles
  inc vehiclex(vehicle),speed#(vehicle)
else
  dec vehiclex(vehicle),speed#(vehicle)
endif
if vehiclex(vehicle)>screen width() then vehiclex(vehicle)=0-text width(car$)
if vehiclex(vehicle)<0-text width(car$) then vehiclex(vehicle)=screen width()
next vehicle
for floater=1 to numberoffloaters
if typeoffloater(floater)=0
  ink rgb(255,0,0),0
  text floaterx(floater),floatery(floater),log$
else
  ink rgb(255,255,0),0
  text floaterx(floater),floatery(floater),turtle$
endif
if floater*2<=numberoffloaters
  inc floaterx(floater),speedf#(floater)
else
  dec floaterx(floater),speedf#(floater)
endif
if floaterx(floater)>screen width() then floaterx(floater)=-40
if floaterx(floater)<-40 then floaterx(floater)=screen width()
next floater
ink rgb(0,255,0),0
text frogx,frogy,frog$
if upkey()=1 then dec frogy
if downkey()=1 then inc frogy
if leftkey()=1 then dec frogx
if rightkey()=1 then inc frogx
 
sync
loop