sync on sync rate 0 set display mode 1024,768,32 color backdrop 0 cls autocam off set camera range 0.01,200 hide mouse global health=100 global highest_obj=0 level_floor=freeobj() make object box level_floor,100,1,100 position object level_floor,0,-0.5,0 position camera 0,0.5,0 global dummy dummy=freeobj() make object cube dummy,0 set text size 12 type weapon_type ammo img endtype dim prime(20) prime(1)=2 prime(2)=3 prime(3)=5 prime(4)=7 prime(5)=11 prime(6)=13 prime(7)=17 prime(8)=19 prime(9)=23 prime(10)=29 prime(11)=31 prime(12)=37 prime(13)=41 prime(14)=43 prime(15)=47 prime(16)=53 prime(17)=59 prime(18)=61 prime(19)=67 prime(20)=71 global last_shot_time dim weapon(20) as weapon_type health_img=freeimg() ink rgb(255,0,0),0 box 0,0,80,80 ink -1,0 center text 40,40-text height("X")*0.5,"Health" get image health_img,0,0,80,80,0 for n=1 to 20 ink rgb(0,255,0),0 box 0,0,40,40 ink 0,0 center text 20,20-text height("X")*0.5,str$(prime(n)) img=freeimg() get image img,0,0,40,40,0 weapon(n).img=img next n global selected_gun global level=1 selected_gun=1 weapon(1).ammo=50 type item_type value1 value2 typ obj endtype dim item(10) as item_type for n=1 to 10 item(n).obj=freeobj() make object sphere item(n).obj,1 position object item(n).obj,rnd(100)-50,0.5,rnd(100)-50 if rnd(4)=1 item(n).typ=1 item(n).value1=50 texture object item(n).obj,health_img else item(n).typ=0 item(n).value1=rnd(level-1)+1 item(n).value2=20 texture object item(n).obj,weapon(item(n).value1).img endif set object filter item(n).obj,0 next n move_speed#=15 timer0=timer() time#=0 type evil_number_type number prime obj angle as float endtype dim evil_number(100) as evil_number_type for n=1 to 20 evil_number(n).prime=prime(rnd(level-1)+1) evil_number(n).number=evil_number(n).prime*(prime(rnd(3)+1+level)) evil_number(n).obj=freeobj() ink rgb(0,0,255),0 box 0,0,40,40 ink -1,0 center text 20,20-text height("X")*0.5,str$(evil_number(n).number) img=freeimg() get image img,0,0,40,40,0 make object box evil_number(n).obj,1,1,1 texture object evil_number(n).obj,img position object evil_number(n).obj,rnd(100)-50,60+rnd(20),rnd(100)-50 yrotate object evil_number(n).obj,rnd(360) set object filter evil_number(n).obj,0 next n global detection_range#=20.0 global seperation_range#=8.0 set text size 36 ink 0,0 box 0,0,500,500 ink -1,0 for n=1 to 3000 x=rnd(500) y=rnd(500) box x,y,x+1,y+1 next n background_img=freeimg() get image background_img,0,0,500,500 level_skybox=freeobj() make object box level_skybox,200,200,200 set object cull level_skybox,0 set object light level_skybox,0 texture object level_skybox,background_img ink 0,0 box 0,0,500,500 ink -1,0 for n=1 to 3000 x=rnd(400) y=rnd(400) ink rgb(rnd(255),rnd(255),rnd(255)),0 box x,y,x+rnd(100),y+rnd(100) next n floor_img=freeimg() get image floor_img,0,0,500,500 texture object level_floor,floor_img vy#=0 global shot_amount=0 globaL score=0 do time#=(timer()-timer0)*0.001 timer0=timer() gosub ai gosub screen gosub control_camera gosub items gosub gun gosub end_of_level sync loop end_of_level: all_dead=1 for n=1 to 100 if evil_number(n).obj>0 if object exist(evil_number(n).obj) all_dead=0 exit endif endif next n if all_dead=1 t=timer() while timer()<t+500 ink rgb(rnd(255),rnd(255),rnd(255)),0 center text screen width()/2,screen height()/2-text height("X")/2.0,"LEVEL COMPLETE!" sync endwhile t=timer() while timer()<t+1000 ink rgb(rnd(255),rnd(255),rnd(255)),0 center text screen width()/2,screen height()/2-text height("X")/2.0-((timer()-t)*200/1000.0),"LEVEL COMPLETE!" sync endwhile t=timer() while timer()<t+3000 ink rgb(0,255,0),0 center text screen width()/2,screen height()/2-text height("X")/2.0-200,"LEVEL "+str$(level)+" COMPLETE!" ink rgb(255,0,0),0 center text screen width()/2,screen height()/2-text height("X")/2.0,"Accuracy: "+str$(2000.0/shot_amount)+"%" sync endwhile shot_amount=0 inc level set text size 12 for n=1 to 20 evil_number(n).prime=prime(rnd(level-1)+1) evil_number(n).number=evil_number(n).prime*(prime(rnd(3)+1+level)) evil_number(n).obj=freeobj() ink rgb(0,0,255),0 box 0,0,40,40 ink -1,0 center text 20,20-text height("X")*0.5,str$(evil_number(n).number) img=freeimg() get image img,0,0,40,40,0 make object box evil_number(n).obj,1,1,1 texture object evil_number(n).obj,img position object evil_number(n).obj,rnd(100)-50,60+rnd(20),rnd(100)-50 yrotate object evil_number(n).obj,rnd(360) set object filter evil_number(n).obj,0 next n set text size 36 timer0=timer() endif return items: for n=1 to 10 if item(n).obj>0 if object exist(item(n).obj) turn object right item(n).obj,180*time# dist2#=(object position x(item(n).obj)-camera position x())^2+(object position z(item(n).obj)-camera position z())^2 if dist2#<4 if item(n).typ=0 weapon(item(n).value1).ammo=weapon(item(n).value1).ammo+item(n).value2 endif if item(n).typ=1 health=health+item(n).value1 endif position object item(n).obj,rnd(100)-50,0.5,rnd(100)-50 if rnd(4)=1 item(n).typ=1 item(n).value1=50 texture object item(n).obj,health_img else item(n).typ=0 item(n).value1=rnd(level-1)+1 item(n).value2=20 texture object item(n).obj,weapon(item(n).value1).img endif endif endif endif next n return ai: for n=1 to 100 if evil_number(n).obj>0 if object exist(evil_number(n).obj) move object evil_number(n).obj,sqrt(evil_number(n).prime)*3*time# evil_number(n).angle=object angle y(evil_number(n).obj) if object position y(evil_number(n).obj)>0.5 position object evil_number(n).obj,object position x(evil_number(n).obj),object position y(evil_number(n).obj)-20*time#,object position z(evil_number(n).obj) endif if object position y(evil_number(n).obj)<0.5 position object evil_number(n).obj,object position x(evil_number(n).obj),0.5,object position z(evil_number(n).obj) endif endif endif next n for n=1 to 100 if evil_number(n).obj>0 if object exist(evil_number(n).obj) totalx#=0 totalz#=0 for n2=1 to 100 if evil_number(n2).obj>0 if object exist(evil_number(n2).obj) dist2#=(object position x(evil_number(n).obj)-object position x(evil_number(n2).obj))^2+(object position z(evil_number(n).obj)-object position z(evil_number(n2).obj))^2 if dist2#>seperation_range#^2 if dist2#<detection_range#^2 if evil_number(n).prime=evil_number(n2).prime totalx#=totalx#+sin(evil_number(n2).angle) totalz#=totalz#+cos(evil_number(n2).angle) else totalx#=totalx#-sin(evil_number(n2).angle)*0.1 totalz#=totalz#-cos(evil_number(n2).angle)*0.1 endif endif else ang#=atanfull(object position x(evil_number(n2).obj)-object position x(evil_number(n).obj),object position z(evil_number(n2).obj)-object position z(evil_number(n).obj)) totalx#=totalx#-seperation_range#*sin(ang#)/dist2# totalz#=totalz#-seperation_range#*cos(ang#)/dist2# endif endif endif next n2 dist2#=(object position x(evil_number(n).obj)-camera position x())^2+(object position z(evil_number(n).obj)-camera position z())^2 if dist2#<detection_range#^2 targetang#=atanfull(camera position x()-object position x(evil_number(n).obj),camera position z()-object position z(evil_number(n).obj)) totalx#=totalx#+evil_number(n).prime*3*sin(targetang#) totalz#=totalz#+evil_number(n).prime*3*cos(targetang#) endif totalx#=totalx#-object position x(evil_number(n).obj)*0.08 totalz#=totalz#-object position z(evil_number(n).obj)*0.08 yrotate object evil_number(n).obj,curveangle(atanfull(totalx#,totalz#)+rnd(20)-10,object angle y(evil_number(n).obj),60) endif endif next n return function line3d(x#,y#,z#,x2#,y2#,z2#) position object dummy,x#,y#,z# `if object in screen(dummy)=0 then exitfunction x=object screen x(dummy) y=object screen y(dummy) position object dummy,x2#,y2#,z2# `if object in screen(dummy) line x,y,object screen x(dummy),object screen y(dummy) `endif endfunction gun: mmz=mousemovez() if mmz>0 old_gun=selected_gun inc selected_gun while weapon(selected_gun).ammo<=0 inc selected_gun if selected_gun>20 selected_gun=1 endif if selected_gun=old_gun exit endif endwhile endif if mmz<0 old_gun=selected_gun dec selected_gun while weapon(selected_gun).ammo<=0 dec selected_gun if selected_gun<1 selected_gun=20 endif if selected_gun=old_gun exit endif endwhile endif if mouseclick()=1 shoot_weapon(selected_gun) endif return function shoot_weapon(weapon) if weapon(weapon).ammo>0 and timer()>last_shot_time+100 inc shot_amount last_shot_time=timer() weapon(weapon).ammo=weapon(weapon).ammo-1 obj=pick object(screen width()/2,screen height()/2,1, highest_obj) if obj>0 for n=1 to 100 if evil_number(n).obj=obj if object exist(evil_number(n).obj) if evil_number(n).number/prime(weapon)=(0.0+evil_number(n).number)/prime(weapon) delete object evil_number(n).obj evil_number(n).obj=0 endif endif endif next n endif endif endfunction screen: set cursor 0,0 ink -1,0 print "Level:",level print "Weapon:",prime(selected_gun) print "Ammo:",weapon(selected_gun).ammo print "Health:",health ink rgb(255,0,0),0 box screen width()/2,screen height()/2-20,screen width()/2+1,screen height()/2+20+1 box screen width()/2-20,screen height()/2,screen width()/2+20+1,screen height()/2+1 center text screen width()/2,screen height()/2-0.5*text height("X"),str$(prime(selected_gun)) ink rgb(55,55,55),0 text screen width()/2+30,screen height()/2-0.5*text height("X")+30,str$(weapon(selected_gun).ammo) return control_camera: rotate camera curveangle(camera_angle_x#,camera angle x(),8),curveangle(camera_angle_y#,camera angle y(),8),0 camera_angle_x#=camera_angle_x#+mousemovey() camera_angle_y#=camera_angle_y#+mousemovex() xr#=camera angle x() xrotate camera 0 move camera (keystate(17)-keystate(31))*move_speed#*time# yrotate camera camera angle y()+90 move camera (keystate(32)-keystate(30))*move_speed#*time# yrotate camera camera angle y()-90 xrotate camera xr# position object level_skybox,camera position x(),camera position y(),camera position z() for n=1 to 100 if evil_number(n).obj>0 if object exist(evil_number(n).obj) dx#=object position x(evil_number(n).obj)-camera position x() dy#=object position y(evil_number(n).obj)-camera position y() dz#=object position z(evil_number(n).obj)-camera position z() dist#=sqrt((dx#)^2+(dz#)^2+(dy#)^2) if dist#<1.1 nx#=dx#/dist# nz#=dz#/dist# move#=(1.1-dist#)*0.5 position camera camera position x()-nx#*move#,camera position y(),camera position z()-nz#*move# position object evil_number(n).obj,object position x(evil_number(n).obj)+nx#*move#,object position y(evil_number(n).obj),object position z(evil_number(n).obj)+nz#*move# endif endif endif next n if spacekey()=1 and jump<2 and sp=0 if jump>0 if abs(vy#)<5 inc jump vy#=6 endif else inc jump vy#=6 endif endif sp=spacekey() if jump>0 vy#=vy#-12.0*time# endif print jump if camera position y()<0.5 jump=0 position camera camera position x(),0.5,camera position z() vy#=0 endif position camera camera position x(),camera position y()+vy#*time#,camera position z() return function freeobj() o=1:while object exist(o):inc o:endwhile if o>highest_obj highest_obj=o endif endfunction o function freeimg() o=1:while image exist(o):inc o:endwhile endfunction o