using timer to change levels
Blitz3D Forums/Blitz3D Programming/using timer to change levels
| ||
Help! I am unable to get a timer to work as I need it to, and would really appreciate some help, as I have to put this in an exhibition in two days! I expect it is something simple that I am missing. At present, running If KeyHit(28) PastCycle() or If KeyHit(57) CleanupScene() within the ChangeBirdState() function do what I want, but I need to run these functions using a timer instead, I need to run PastCycle() every 30 secs for 6 cases within case select, and then run CleanUpScene(). Can anyone help me figure out how to get this to happen? Seems so simple, and I have done similar things with other pieces... +++++++++++++++++++++++++++++++++++++++++++++++ ;variables Global light Global light2 Global tmrFPS = CreateTimer(40) Global prevtime Global curtime Global FPS Global mdlBlack Global mdlBlack2 Global worldstate = 0 ;0 no birds loaded, 1 birds loaded Global birdstate = 0 ;0 past, 1 present, can add more states Global titleFont,subtitleFont Global listen,bluHeron,vireo,junco,amfinch,mdove,cardinal,NightHawk Global ScTana,RNPheasant,BWBB,RTHawk,HFinch,PWood,NBob,Killdeer,GHSparrow,DWood,Whip Global CWarb,Bobo,YBCuckoo,BBCuckoo,Robin,AmKest,BJ,Crow,Grackle,BlueBird,Flycatcher Global time ;sound stuff bluHeron=Load3DSound("sounds/greatblueheron_mono.wav") ; Load 3D sound vireo=Load3DSound("sounds/White-eyedVireo_mono.wav") junco =Load3DSound("sounds/Dark-eyedJunco_mono.wav") amfinch =Load3DSound("sounds/americanGoldFinch_mono.wav") mdove =Load3DSound("sounds/mourningDove_mono.wav") cardinal =Load3DSound("sounds/cardinal_mono.wav") NightHawk =Load3DSound("sounds/commonNighthawk_mono.wav") ScTana =Load3DSound("sounds/ScarletTanager_mono.wav") RNPheasant=Load3DSound("sounds/Ring-neckedPheasant_mono.wav") BWBB=Load3DSound("sounds/Red-wingedBlackbird_mono.wav") RTHawk=Load3DSound("sounds/RedTailedHawk_mono.wav") HFinch=Load3DSound("sounds/HouseFinch_mono.wav") PWood=Load3DSound("sounds/PileatedWoodpecker_mono.wav") NBob=Load3DSound("sounds/NorthernBobwhite_mono.wav") Killdeer=Load3DSound("sounds/Killdeer_mono.wav") GHSparrow=Load3DSound("sounds/GrasshopperSparrow_mono.wav") DWood=Load3DSound("sounds/Downywoodpecker_mono.wav") Whip=Load3DSound("sounds/whipporwill_mono.wav") CWarb=Load3DSound("sounds/CeruleanWarbler_mono.wav") Bobo=Load3DSound("sounds/Bobolink_mono.wav") YBCuckoo=Load3DSound("sounds/YellowBilledCuckoo_mono.wav") BBCuckoo=Load3DSound("sounds/BlackBilledCuckoo_mono.wav") Robin=Load3DSound("sounds/robin_mono.wav") AmKest=Load3DSound("sounds/AmericanKestrel_mono.wav") BJ=Load3DSound("sounds/blueJay_mono.wav") Crow=Load3DSound("sounds/crow_mono.wav") Grackle=Load3DSound("sounds/CommonGrackle_mono.wav") BlueBird=Load3DSound("sounds/EasternBluebird_mono.wav") Flycatcher=Load3DSound("sounds/AcadianFlycatcher_mono1.wav") SoundVolume Flycatcher,1 SoundVolume vireo,1 SoundVolume BlueBird,1 SoundVolume bluHeron,1 SoundVolume BJ,1 SoundVolume Crow,1 SoundVolume Grackle,1 SoundVolume AmKest,1 SoundVolume Robin,1 SoundVolume BBCuckoo,1 SoundVolume YBCuckoo,1 SoundVolume Bobo,1 SoundVolume CWarb,1 SoundVolume Whip,1 SoundVolume DWood,1 SoundVolume GHSparrow,1 SoundVolume Killdeer,1 SoundVolume NBob,1 Global dateTXT$ Type birds Field mesh Field speed# Field sing End Type ;initialize the scene Graphics3D 1440,900,32,1 ;Graphics3D 800,600,32,2 SetBuffer BackBuffer() SeedRnd (MilliSecs()) Global cam = CreateCamera() PositionEntity cam,0,0,-25 CameraViewport cam,0,0,GraphicsWidth(),GraphicsHeight() CameraZoom cam,.5 CameraFogMode cam,1 CameraFogRange cam,28,160 listen=CreateListener(cam) ;CameraClsColor cam,Rand(100,120),Rand(0,80),Rand(200,255) ;Global cam2 = CreateCamera() ;PositionEntity cam2,1000,0,-25 ;CameraViewport cam2,720,0,GraphicsWidth()/2,GraphicsHeight() ;CameraClsColor cam2,100,100,100 mdlBlack = CreateCube(cam) FlipMesh mdlBlack ScaleEntity mdlBlack, 3.1, 3.1, 3.1 EntityColor mdlBlack, 0, 0, 0 ;mdlBlack2 = CreateCube(cam2) ;FlipMesh mdlBlack2 ;ScaleEntity mdlBlack2, 1.1, 1.1, 1.1 ;EntityColor mdlBlack2, 0, 0, 0 light=CreateLight(1) RotateEntity light,90,0,0 LightColor light,0,0,255 LightRange light,200 light2=CreateLight(1) RotateEntity light2,-90,0,0 LightColor light2,222,222,222 AmbientLight 100,100,100 ; Splash Screen imgTech = LoadImage("images/4thebirds_splash.jpg") DrawImage imgTech, 0, 0 Flip t = MilliSecs() While (t > MilliSecs() - 3200) And (Not KeyDown(1)) WaitTimer tmrFPS Wend titleFont = LoadFont("Arial",32,True,False,False) subtitleFont= LoadFont("Arial",24,True,False,False) ;main loop While Not KeyDown(1) Select worldstate Case 0 LoadBirds() Case 1 UpdateScene() End Select Wend Function ChangeBirdState() time = 5000 If MilliSecs() < JumpTimer And worldstate = 0 Then JumpTimer=MilliSecs()+time;(1000 * 300);(1000+60+2);(1000+60+5) PastCycle() End If ; If MilliSecs() > 5000 And birdstate = 0 And birdstate < 6 Then ;; JumpTimer=MilliSecs()+time;(1000 * 300);(1000+60+2);(1000+60+5) ; PastCycle() ;; birdstate = birdstate + 1 ; End If If KeyHit(28) PastCycle() If KeyHit(57) CleanupScene() End Function ;fade from black Function FadeIn() Alpha# = 1.0 While Alpha# > 0 WaitTimer tmrFPS RenderWorld Flip EntityAlpha mdlBlack, Alpha# ;EntityAlpha mdlBlack2, Alpha# Alpha# = Alpha# - 0.05 Wend EntityAlpha mdlBlack, 0 ;EntityAlpha mdlBlack2, 0 End Function ;fade to black Function FadeOut() Alpha# = 0.0 While Alpha# < 1.0 WaitTimer tmrFPS RenderWorld Flip EntityAlpha mdlBlack, Alpha# ;EntityAlpha mdlBlack2, Alpha# Alpha# = Alpha# + 0.05 Wend EntityAlpha mdlBlack, 1 ;EntityAlpha mdlBlack2, 1 End Function ;draw borders around the text Function OutlineText(x, y, txt$, center_x = False, center_y = False) r = ColorRed() g = ColorGreen() b = ColorBlue() Color 0, 0, 0 Text(x+1, y, txt$, center_x, center_y) Text(x-1, y, txt$, center_x, center_y) Text(x, y+1, txt$, center_x, center_y) Text(x, y-1, txt$, center_x, center_y) Color r, g, b Text(x, y, txt$, center_x, center_y) End Function ;populate the scene Function LoadBirds() Select birdstate Case 0 ;first set of birds, Oberlin March 2 1908, White-eyed vireo, olive-sided flycatcher CameraFogColor cam,141,143,255 CameraClsColor cam,141,143,255 ;(Late February 1908 37F) LoopSound vireo LoopSound Flycatcher RotateEntity cam,0,0,0 For counter=0 To 70 bird.birds = New birds tmp = Rnd(1,2) Select tmp Case 1 bird\mesh = LoadAnimMesh("meshes/whiteEyedvireo.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 ;ScaleEntity bird\mesh,4.5,4.5,4.5 feathers = LoadTexture("textures/White-eyed_Vireo_masked_ind.bmp",5+8) EntityTexture bird\mesh,feathers bird\sing = EmitSound(vireo,bird\mesh) ;ChannelVolume vireo,1 Case 2 bird\mesh = LoadAnimMesh("meshes/oliveSidedFlycatcher.b3d") Animate bird\mesh,1,Rnd(.1,.2),0,0 feathers=LoadTexture("textures/Olive-sided Flycatcher_masked_ind.bmp",5+8) EntityTexture bird\mesh, feathers ;ScaleEntity bird\mesh,.5,.5,.5 EntityFX bird\mesh,16 bird\sing = EmitSound(Flycatcher,bird\mesh) End Select PositionEntity bird\mesh, Rnd(-200,200),Rnd(-200,200)+(fs#*0.5),Rnd(-200,200),True bird\speed# = Rnd(.1,1.5) Next dateTXT = "Oberlin Ohio, late February, 1908" Case 1 ;second set of birds, crow, robin, killdeer, larks CameraFogColor cam,110,135,244 CameraClsColor cam,110,135,244 ;March 1908 45.5 F LoopSound Crow LoopSound Robin LoopSound Killdeer LoopSound amfinch LoopSound cardinal For counter=0 To 200 bird.birds = New birds tmp = Rnd(1,6) Select tmp Case 1 ;crow bird\mesh = LoadAnimMesh("meshes/raven-anim.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 feathers=LoadTexture("textures/raven_textmask_ind.bmp",5+8) EntityTexture bird\mesh,feathers bird\sing = EmitSound(Crow,bird\mesh) Case 2 bird\mesh=LoadAnimMesh("meshes/bird_anim-1.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 EntityFX bird\mesh, 16 feathers=LoadTexture("textures/robin.bmp",5+8) EntityTexture bird\mesh,feathers bird\sing = EmitSound(Robin,bird\mesh) Case 3 bird\mesh = LoadAnimMesh("meshes/killdeer-anim.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 feathers=LoadTexture("textures/Killdeer_masked_ind.bmp",5+8) EntityTexture bird\mesh, feathers bird\sing = EmitSound(Killdeer,bird\mesh) Case 4 ;lark bird\mesh = LoadMesh("cardinal.b3d") feathers=LoadTexture("textures/Cardinal_textmask_ind.bmp",5+8) EntityTexture bird\mesh, feathers ScaleEntity bird\mesh,1.5,1.5,1.5 EntityFX bird\mesh,16 bird\sing = EmitSound(cardinal,bird\mesh) Case 5 bird\mesh = LoadAnimMesh("meshes/common_nighthawk-anim.b3d") ;bird\mesh = LoadAnimMesh("meshes/whiteeyed_vireo-anim.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 ;ScaleEntity bird\mesh,4.5,4.5,4.5 feathers = LoadTexture("textures/nighthawk_textmask_ind.bmp",5+8) ;feathers = LoadTexture("textures/vireo_textmask_ind.bmp",5+8) EntityTexture bird\mesh,feathers ; Case 6 bird\mesh = LoadAnimMesh("meshes/yellow_billed_cuckoo-anim.b3d") ;bird\mesh = LoadAnimMesh("meshes/olivesided_flycatcher-anim.b3d") Animate bird\mesh,1,Rnd(.1,.2),0,0 feathers=LoadTexture("textures/YellowBilled_Cuckoo_masked_ind.bmp",5+8) ;feathers=LoadTexture("textures/olivesided_masked_ind.bmp",5+8) EntityTexture bird\mesh, feathers ;ScaleEntity bird\mesh,.5,.5,.5 EntityFX bird\mesh,16 bird\sing = EmitSound(amfinch,bird\mesh) End Select PositionEntity bird\mesh, Rnd(-200,200),Rnd(-200,200)+(fs#*0.5),Rnd(-200,200),True bird\speed# = Rnd(.1,1.5) Next dateTXT = "Oberlin Ohio, March 2-9 1908" Case 2 ;third set of birds, rwblackbird,bluebirds,grackle,rusty blackbird CameraFogColor cam,80,128,245 CameraClsColor cam,80,128,245 ;March 45.5 LoopSound BWBB LoopSound BlueBird LoopSound Grackle For counter=0 To 250 bird.birds = New birds tmp = Rnd(1,10) Select tmp Case 1 ;bluebirds bird\mesh = LoadMesh("meshes/grasshopperSparrow.b3d") ;Animate bird\mesh,1,Rnd(.6,1.3),0,0 feathers=LoadTexture("textures/grasshopper_textmask_ind.bmp",5+8) EntityTexture bird\mesh,feathers bird\sing = EmitSound(BlueBird,bird\mesh) Case 2 ;rwblackbirds bird\mesh=LoadAnimMesh("meshes/blackBilledCuckoo.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 EntityFX bird\mesh, 16 feathers=LoadTexture("textures/BlackBilled_Cuckoo_masked_ind.bmp",5+8) ;Animate bird\mesh,1,Rnd(.6,1.3),0,0 EntityTexture bird\mesh,feathers bird\sing = EmitSound(Grackle,bird\mesh) Case 3 ;rustyblackbird bird\mesh = LoadAnimMesh("meshes/chuckwillsWidow.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 feathers=LoadTexture("textures/ChuckWillsWidow_masked_ind.bmp",5+8) EntityTexture bird\mesh, feathers bird\sing = EmitSound(BWBB,bird\mesh) Case 4 ;grackle bird\mesh = LoadAnimMesh("meshes/raven-anim.b3d") Animate bird\mesh,Rand(1,3),Rnd(.1,.7),0,0 ScaleEntity bird\mesh,2,2,2 feathers = LoadTexture("textures/raven_textmask_ind.bmp",5+8) EntityTexture bird\mesh,feathers bird\sing = EmitSound(Grackle,bird\mesh) Case 5 ;crow bird\mesh = LoadAnimMesh("meshes/raven-anim.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 feathers=LoadTexture("textures/raven_textmask_ind.bmp",5+8) EntityTexture bird\mesh,feathers Case 6 bird\mesh=LoadAnimMesh("meshes/bird_anim-1.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 EntityFX bird\mesh, 16 feathers=LoadTexture("textures/robin.bmp",5+8) EntityTexture bird\mesh,feathers Case 7 bird\mesh = LoadAnimMesh("meshes/killdeer-anim.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 feathers=LoadTexture("textures/Killdeer_masked_ind.bmp",5+8) EntityTexture bird\mesh, feathers Case 8 ;lark bird\mesh = LoadMesh("cardinal.b3d") feathers=LoadTexture("textures/Cardinal_textmask_ind.bmp",5+8) EntityTexture bird\mesh, feathers ScaleEntity bird\mesh,1.5,1.5,1.5 EntityFX bird\mesh,16 Case 9 bird\mesh = LoadAnimMesh("meshes/common_nighthawk-anim.b3d") ;bird\mesh = LoadAnimMesh("meshes/whiteeyed_vireo-anim.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 ;ScaleEntity bird\mesh,4.5,4.5,4.5 feathers = LoadTexture("textures/nighthawk_textmask_ind.bmp",5+8) ;feathers = LoadTexture("textures/vireo_textmask_ind.bmp",5+8) EntityTexture bird\mesh,feathers ; EmitSound(bluHeron,bird\mesh) Case 10 bird\mesh = LoadAnimMesh("meshes/yellow_billed_cuckoo-anim.b3d") ;bird\mesh = LoadAnimMesh("meshes/olivesided_flycatcher-anim.b3d") Animate bird\mesh,1,Rnd(.1,.2),0,0 feathers=LoadTexture("textures/YellowBilled_Cuckoo_masked_ind.bmp",5+8) ;feathers=LoadTexture("textures/olivesided_masked_ind.bmp",5+8) EntityTexture bird\mesh, feathers ;ScaleEntity bird\mesh,.5,.5,.5 EntityFX bird\mesh,16 End Select PositionEntity bird\mesh, Rnd(-200,200),Rnd(-200,200)+(fs#*0.5),Rnd(-200,200),True bird\speed# = Rnd(.1,1.5) Next dateTXT = "Oberlin Ohio, March 16 1908" Case 3 ;forth set of birds, Great Blue Heron,American Bittern CameraFogColor cam,60,120,255 CameraClsColor cam,60,120,255 LoopSound bluHeron LoopSound GHSparrow LoopSound BBCuckoo LoopSound YBCuckoo LoopSound Killdeer LoopSound NightHawk LoopSound cardinal ;ChannelVolume bird\sing,1 For counter=0 To 300 bird.birds = New birds tmp = Rnd(1,12) Select tmp Case 1 ;bluebirds bird\mesh = LoadMesh("meshes/grasshopperSparrow.b3d") ;Animate bird\mesh,1,Rnd(.6,1.3),0,0 feathers=LoadTexture("textures/grasshopper_textmask_ind.bmp",5+8) EntityTexture bird\mesh,feathers bird\sing = EmitSound(GHSparrow,bird\mesh) Case 2 ;rwblackbirds bird\mesh=LoadAnimMesh("meshes/blackBilledCuckoo.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 EntityFX bird\mesh, 16 feathers=LoadTexture("textures/BlackBilled_Cuckoo_masked_ind.bmp",5+8) ;Animate bird\mesh,1,Rnd(.6,1.3),0,0 EntityTexture bird\mesh,feathers bird\sing = EmitSound(BBCuckoo,bird\mesh) Case 3 ;rustyblackbird bird\mesh = LoadAnimMesh("meshes/chuckwillsWidow.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 feathers=LoadTexture("textures/ChuckWillsWidow_masked_ind.bmp",5+8) EntityTexture bird\mesh, feathers Case 4 ;grackle bird\mesh = LoadAnimMesh("meshes/raven-anim.b3d") Animate bird\mesh,Rand(1,3),Rnd(.1,.7),0,0 ScaleEntity bird\mesh,2,2,2 feathers = LoadTexture("textures/raven_textmask_ind.bmp",5+8) EntityTexture bird\mesh,feathers Case 5 ;crow bird\mesh = LoadAnimMesh("meshes/raven-anim.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 feathers=LoadTexture("textures/raven_textmask_ind.bmp",5+8) EntityTexture bird\mesh,feathers Case 6 bird\mesh=LoadAnimMesh("meshes/bird_anim-1.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 EntityFX bird\mesh, 16 feathers=LoadTexture("textures/robin.bmp",5+8) EntityTexture bird\mesh,feathers Case 7 bird\mesh = LoadAnimMesh("meshes/killdeer-anim.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 feathers=LoadTexture("textures/Killdeer_masked_ind.bmp",5+8) EntityTexture bird\mesh, feathers bird\sing = EmitSound(Killdeer,bird\mesh) Case 8 ;lark bird\mesh = LoadMesh("cardinal.b3d") feathers=LoadTexture("textures/Cardinal_textmask_ind.bmp",5+8) EntityTexture bird\mesh, feathers ScaleEntity bird\mesh,1.5,1.5,1.5 EntityFX bird\mesh,16 bird\sing = EmitSound(cardinal,bird\mesh) Case 9 bird\mesh = LoadAnimMesh("meshes/common_nighthawk-anim.b3d") ;bird\mesh = LoadAnimMesh("meshes/whiteeyed_vireo-anim.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 ;ScaleEntity bird\mesh,4.5,4.5,4.5 feathers = LoadTexture("textures/nighthawk_textmask_ind.bmp",5+8) ;feathers = LoadTexture("textures/vireo_textmask_ind.bmp",5+8) EntityTexture bird\mesh,feathers ; EmitSound(bluHeron,bird\mesh) Case 10 bird\mesh = LoadAnimMesh("meshes/yellow_billed_cuckoo-anim.b3d") ;bird\mesh = LoadAnimMesh("meshes/olivesided_flycatcher-anim.b3d") Animate bird\mesh,1,Rnd(.1,.2),0,0 feathers=LoadTexture("textures/YellowBilled_Cuckoo_masked_ind.bmp",5+8) ;feathers=LoadTexture("textures/olivesided_masked_ind.bmp",5+8) EntityTexture bird\mesh, feathers ;ScaleEntity bird\mesh,.5,.5,.5 EntityFX bird\mesh,16 Case 11 ;Great Blue Heron bird\mesh = LoadAnimMesh("meshes/blueHeron_anim.b3d") Animate bird\mesh,2,Rnd(.6,1.3),0,0 feathers=LoadTexture("textures/Great_Blue_Heron_masked_ind.bmp",5+8) EntityTexture bird\mesh,feathers bird\sing = EmitSound(bluHeron,bird\mesh) Case 12 bird\mesh=LoadMesh("meshes/LeastBittern.b3d") ;Animate bird\mesh,1,Rnd(.6,1.3),0,0 EntityFX bird\mesh, 16 feathers=LoadTexture("textures/LeastBittern_textmask_ind.bmp",5+8) EntityTexture bird\mesh,feathers End Select PositionEntity bird\mesh, Rnd(-200,200),Rnd(-200,200)+(fs#*0.5),Rnd(-200,200),True bird\speed# = Rnd(.1,1.5) Next dateTXT = "Oberlin Ohio, March 28 1908" Case 4 ;fifth set of birds, Wood Duck, Green Heron, Loon,Grasshopper Sparrow, chimney Swift,Bobolink CameraClsColor cam,40,110,255 ;April 1908 51.7F CameraFogColor cam,40,110,255 LoopSound Bobo For counter=0 To 400 bird.birds = New birds tmp = Rnd(1,16) Select tmp Case 1 ;bluebirds bird\mesh = LoadMesh("meshes/loon-anim.b3d") ;Animate bird\mesh,1,Rnd(.6,1.3),0,0 feathers=LoadTexture("textures/loon_masked_ind.bmp",5+8) EntityTexture bird\mesh,feathers Case 2 ;rwblackbirds bird\mesh=LoadAnimMesh("meshes/woodDuck-anim.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 EntityFX bird\mesh, 16 feathers=LoadTexture("textures/woodDuck_textmask_ind.bmp",5+8) ;Animate bird\mesh,1,Rnd(.6,1.3),0,0 EntityTexture bird\mesh,feathers Case 3 ;rustyblackbird bird\mesh = LoadAnimMesh("meshes/greenHeron-anim.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 feathers=LoadTexture("textures/Green_Heron_masked_ind.bmp",5+8) EntityTexture bird\mesh, feathers Case 4 ;grackle bird\mesh = LoadAnimMesh("meshes/raven-anim.b3d") Animate bird\mesh,Rand(1,3),Rnd(.1,.7),0,0 ScaleEntity bird\mesh,2,2,2 feathers = LoadTexture("textures/raven_textmask_ind.bmp",5+8) EntityTexture bird\mesh,feathers Case 5 ;crow bird\mesh = LoadAnimMesh("meshes/raven-anim.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 feathers=LoadTexture("textures/raven_textmask_ind.bmp",5+8) EntityTexture bird\mesh,feathers Case 6 bird\mesh=LoadAnimMesh("meshes/bird_anim-1.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 EntityFX bird\mesh, 16 feathers=LoadTexture("textures/robin.bmp",5+8) EntityTexture bird\mesh,feathers Case 7 bird\mesh = LoadAnimMesh("meshes/killdeer-anim.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 feathers=LoadTexture("textures/Killdeer_masked_ind.bmp",5+8) EntityTexture bird\mesh, feathers Case 8 ;lark bird\mesh = LoadMesh("cardinal.b3d") feathers=LoadTexture("textures/Cardinal_textmask_ind.bmp",5+8) EntityTexture bird\mesh, feathers ScaleEntity bird\mesh,1.5,1.5,1.5 EntityFX bird\mesh,16 Case 9 bird\mesh = LoadAnimMesh("meshes/common_nighthawk-anim.b3d") ;bird\mesh = LoadAnimMesh("meshes/whiteeyed_vireo-anim.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 ;ScaleEntity bird\mesh,4.5,4.5,4.5 feathers = LoadTexture("textures/nighthawk_textmask_ind.bmp",5+8) ;feathers = LoadTexture("textures/vireo_textmask_ind.bmp",5+8) EntityTexture bird\mesh,feathers ; EmitSound(bluHeron,bird\mesh) Case 10 bird\mesh = LoadAnimMesh("meshes/yellow_billed_cuckoo-anim.b3d") ;bird\mesh = LoadAnimMesh("meshes/olivesided_flycatcher-anim.b3d") Animate bird\mesh,1,Rnd(.1,.2),0,0 feathers=LoadTexture("textures/YellowBilled_Cuckoo_masked_ind.bmp",5+8) ;feathers=LoadTexture("textures/olivesided_masked_ind.bmp",5+8) EntityTexture bird\mesh, feathers ;ScaleEntity bird\mesh,.5,.5,.5 EntityFX bird\mesh,16 Case 11 bird\mesh = LoadMesh("meshes/grasshopperSparrow.b3d") ;Animate bird\mesh,1,Rnd(.6,1.3),0,0 feathers=LoadTexture("textures/grasshopper_textmask_ind.bmp",5) EntityTexture bird\mesh,feathers Case 12 bird\mesh=LoadAnimMesh("meshes/woodDuck-anim.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 ;EntityFX bird\mesh, 16 feathers=LoadTexture("textures/woodDuck_textmask_ind.bmp",5) EntityTexture bird\mesh,feathers Case 13 bird\mesh = LoadAnimMesh("meshes/greenHeron-anim.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 feathers=LoadTexture("textures/Green_Heron_masked_ind.bmp",5) EntityTexture bird\mesh, feathers Case 14 ;loon bird\mesh = LoadAnimMesh("meshes/Turkey_VultureAnim.b3d") Animate bird\mesh,Rand(1,3),Rnd(.1,.7),0,0 ScaleEntity bird\mesh,2,2,2 feathers = LoadTexture("textures/TurkeyVulture_texture_indexed.bmp",5) EntityTexture bird\mesh,feathers Case 15 bird\mesh = LoadAnimMesh("meshes/bobolink.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 feathers=LoadTexture("textures/Bobolink_masked_ind.bmp",5+8) EntityTexture bird\mesh, feathers ScaleEntity bird\mesh,1.5,1.5,1.5 EntityFX bird\mesh,16 bird\sing = EmitSound(Bobo,bird\mesh) Case 16 ;chimney swift bird\mesh = LoadMesh("meshes/grasshopperSparrow.b3d") ;Animate bird\mesh,1,Rnd(.6,1.3),0,0 feathers=LoadTexture("textures/grasshopper_textmask_ind.bmp",5+8) EntityTexture bird\mesh, feathers ScaleEntity bird\mesh,1.5,1.5,1.5 EntityFX bird\mesh,16 End Select PositionEntity bird\mesh, Rnd(-200,200),Rnd(-200,200)+(fs#*0.5),Rnd(-200,200),True bird\speed# = Rnd(.1,1.5) Next dateTXT = "Oberlin Ohio, April 26 1908" Case 5 ;sixth set of birds, Caspian Tern, Least Bittern, Scarlet Tanager, Cerulean Warbler,Yellow-Billed Cuckoo CameraFogColor cam,31,100,255 CameraClsColor cam,31,100,255 ;May 62.2, June 69.2 For counter=0 To 90 bird.birds = New birds tmp = Rnd(1,6) Select tmp Case 1 bird\mesh = LoadMesh("meshes/Caspian_Tern.b3d") ;Animate bird\mesh,Rand(1,3),Rnd(.1,.7),0,0 feathers=LoadTexture("textures/CaspainTern_masked_ind.bmp",5+8) EntityTexture bird\mesh,feathers Case 2 bird\mesh=LoadAnimMesh("meshes/scarlet_tanager-anim.b3d") Animate bird\mesh,Rand(1,3),Rnd(.1,.7),0,0 EntityFX bird\mesh, 16 feathers=LoadTexture("textures/scarlet_textmask_ind.bmp",5+8) EntityTexture bird\mesh,feathers Case 3 bird\mesh = LoadMesh("meshes/LeastBittern.b3d") ;Animate bird\mesh,Rand(1,3),Rnd(.1,.7),0,0 feathers=LoadTexture("textures/LeastBittern_textmask_ind2.bmp",5+8) EntityTexture bird\mesh, feathers Case 4 bird\mesh = LoadAnimMesh("meshes/yellow_billed_cuckoo-anim.b3d") Animate bird\mesh,Rand(1,3),Rnd(.1,.7),0,0 ScaleEntity bird\mesh,2,2,2 feathers = LoadTexture("textures/YellowBilled_Cuckoo_masked_ind.bmp",5+8) EntityTexture bird\mesh,feathers Case 5 ;cerulean warbler bird\mesh = LoadAnimMesh("meshes/Cerulean_warbler-anim.b3d") Animate bird\mesh,Rand(1,3),Rnd(.1,.7),0,0 ScaleEntity bird\mesh,2,2,2 feathers = LoadTexture("textures/CeruleanWarbler_masked_ind.bmp",5+8) EntityTexture bird\mesh,feathers Case 6 bird\mesh = LoadAnimMesh("meshes/blackBilledCuckoo.b3d") Animate bird\mesh,Rand(1,3),Rnd(.1,.7),0,0 ScaleEntity bird\mesh,2,2,2 feathers = LoadTexture("textures/BlackBilled_Cuckoo_masked_ind.bmp",5+8) EntityTexture bird\mesh,feathers End Select PositionEntity bird\mesh, Rnd(-200,200),Rnd(-200,200)+(fs#*0.5),Rnd(-200,200),True bird\speed# = Rnd(.1,1.5) Next dateTXT = "Oberlin Ohio, May 25, 1908, 188 species reported" Case 6 ;Oberlin 2008 BackYard Bird Count CameraFogColor cam,31,100,255 CameraClsColor cam,31,100,255 ;(mean temp during breeding season 64F) RotateEntity cam,0,90,0 For counter=0 To 100 bird.birds = New birds tmp = Rnd(1,11) Select tmp ;canada goose, red-tailed hawk,mourning dove,downy woodpecker,blue jay,crow,robin,raven,starling,dark-eyed junco,cardinal,goldfinch,house sparrow Case 1 bird\mesh = LoadAnimMesh("meshes/canada_gooseAnim.b3d") ;bird\mesh = LoadAnimMesh("meshes/whiteeyed_vireo-anim.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 ;ScaleEntity bird\mesh,4.5,4.5,4.5 feathers = LoadTexture("textures/CanadianGoose_texture_indexed.bmp",5+8) ;feathers = LoadTexture("textures/vireo_textmask_ind.bmp",5+8) EntityTexture bird\mesh,feathers ; EmitSound(bluHeron,bird\mesh) Case 2 bird\mesh = LoadAnimMesh("meshes/red_tailed_hawk-anim.b3d") ;bird\mesh = LoadAnimMesh("meshes/olivesided_flycatcher-anim.b3d") Animate bird\mesh,1,Rnd(.1,.2),0,0 feathers=LoadTexture("textures/Red_tail_hawk_masked_ind.bmp",5+8) ;feathers=LoadTexture("textures/olivesided_masked_ind.bmp",5+8) EntityTexture bird\mesh, feathers ;ScaleEntity bird\mesh,.5,.5,.5 EntityFX bird\mesh,16 Case 3 bird\mesh = LoadAnimMesh("meshes/mourningDove-anim.b3d") ;bird\mesh = LoadAnimMesh("meshes/whiteeyed_vireo-anim.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 ;ScaleEntity bird\mesh,4.5,4.5,4.5 feathers = LoadTexture("textures/Mourning_Dove_masked_ind.bmp",5+8) ;feathers = LoadTexture("textures/vireo_textmask_ind.bmp",5+8) EntityTexture bird\mesh,feathers ; EmitSound(bluHeron,bird\mesh) Case 4 bird\mesh = LoadAnimMesh("meshes/downyWoodpecker-anim.b3d") ;bird\mesh = LoadAnimMesh("meshes/olivesided_flycatcher-anim.b3d") Animate bird\mesh,1,Rnd(.1,.2),0,0 feathers=LoadTexture("textures/Downy_Woodpecker_masked_ind.bmp",5+8) ;feathers=LoadTexture("textures/olivesided_masked_ind.bmp",5+8) EntityTexture bird\mesh, feathers ;ScaleEntity bird\mesh,.5,.5,.5 EntityFX bird\mesh,16 Case 5 bird\mesh = LoadMesh("meshes/blueJay.b3d") ;bird\mesh = LoadAnimMesh("meshes/whiteeyed_vireo-anim.b3d") ;Animate bird\mesh,1,Rnd(.6,1.3),0,0 ;ScaleEntity bird\mesh,4.5,4.5,4.5 feathers = LoadTexture("textures/blueJay_textmask_ind.bmp",5+8) ;feathers = LoadTexture("textures/vireo_textmask_ind.bmp",5+8) EntityTexture bird\mesh,feathers ; EmitSound(bluHeron,bird\mesh) Case 6 ;crow bird\mesh = LoadAnimMesh("meshes/raven-anim.b3d") ;bird\mesh = LoadAnimMesh("meshes/olivesided_flycatcher-anim.b3d") Animate bird\mesh,1,Rnd(.1,.2),0,0 feathers=LoadTexture("textures/raven_textmask_ind.bmp",5+8) ;feathers=LoadTexture("textures/olivesided_masked_ind.bmp",5+8) EntityTexture bird\mesh, feathers ;ScaleEntity bird\mesh,.5,.5,.5 EntityFX bird\mesh,16 Case 7 bird\mesh = LoadAnimMesh("meshes/raven-anim.b3d") ;bird\mesh = LoadAnimMesh("meshes/whiteeyed_vireo-anim.b3d") Animate bird\mesh,1,Rnd(.6,1.3),0,0 ScaleEntity bird\mesh,4.5,4.5,4.5 feathers = LoadTexture("textures/raven_textmask_ind.bmp",5+8) ;feathers = LoadTexture("textures/vireo_textmask_ind.bmp",5+8) EntityTexture bird\mesh,feathers ; EmitSound(bluHeron,bird\mesh) Case 8 ;starling bird\mesh = LoadAnimMesh("meshes/raven-anim.b3d") ;bird\mesh = LoadAnimMesh("meshes/olivesided_flycatcher-anim.b3d") Animate bird\mesh,1,Rnd(.1,.2),0,0 feathers=LoadTexture("textures/raven_textmask_ind.bmp",5+8) ;feathers=LoadTexture("textures/olivesided_masked_ind.bmp",5+8) EntityTexture bird\mesh, feathers ScaleEntity bird\mesh,.8,.8,1.2 EntityFX bird\mesh,16 Case 9 bird\mesh = LoadMesh("meshes/cardinal.b3d") ;bird\mesh = LoadAnimMesh("meshes/whiteeyed_vireo-anim.b3d") ;Animate bird\mesh,1,Rnd(.6,1.3),0,0 ;ScaleEntity bird\mesh,4.5,4.5,4.5 feathers = LoadTexture("textures/Cardinal_textmask_ind.bmp",5+8) ;feathers = LoadTexture("textures/vireo_textmask_ind.bmp",5+8) EntityTexture bird\mesh,feathers ; EmitSound(bluHeron,bird\mesh) Case 10 bird\mesh = LoadAnimMesh("meshes/canada_gooseAnim.b3d") ;bird\mesh = LoadAnimMesh("meshes/whiteeyed_vireo-anim.b3d") Animate bird\mesh,1,Rnd(.1,.3),0,0 ;ScaleEntity bird\mesh,4.5,4.5,4.5 feathers = LoadTexture("textures/CanadianGoose_texture_indexed.bmp",5+8) ;feathers = LoadTexture("textures/vireo_textmask_ind.bmp",5+8) EntityTexture bird\mesh,feathers ; EmitSound(bluHeron,bird\mesh) ; Case 11 ; ;goldfinch ; bird\mesh = LoadAnimMesh("meshes/common_nighthawk-anim.b3d") ; ;bird\mesh = LoadAnimMesh("meshes/whiteeyed_vireo-anim.b3d") ; Animate bird\mesh,1,Rnd(.6,1.3),0,0 ; ;ScaleEntity bird\mesh,4.5,4.5,4.5 ; feathers = LoadTexture("textures/nighthawk_textmask_ind.bmp",5+8) ; ;feathers = LoadTexture("textures/vireo_textmask_ind.bmp",5+8) ; EntityTexture bird\mesh,feathers ;; EmitSound(bluHeron,bird\mesh) ; Case 12 ; ;house sparrow ; bird\mesh = LoadAnimMesh("meshes/yellow_billed_cuckoo-anim.b3d") ; ;bird\mesh = LoadAnimMesh("meshes/olivesided_flycatcher-anim.b3d") ; Animate bird\mesh,1,Rnd(.1,.2),0,0 ; feathers=LoadTexture("textures/YellowBilled_Cuckoo_masked_ind.bmp",5+8) ; ;feathers=LoadTexture("textures/olivesided_masked_ind.bmp",5+8) ; EntityTexture bird\mesh, feathers ; ;ScaleEntity bird\mesh,.5,.5,.5 ; EntityFX bird\mesh,16 Case 11 ;starling bird\mesh = LoadAnimMesh("meshes/raven-anim.b3d") ;bird\mesh = LoadAnimMesh("meshes/olivesided_flycatcher-anim.b3d") Animate bird\mesh,1,Rnd(.1,.2),0,0 feathers=LoadTexture("textures/raven_textmask_ind.bmp",5+8) ;feathers=LoadTexture("textures/olivesided_masked_ind.bmp",5+8) EntityTexture bird\mesh, feathers ScaleEntity bird\mesh,.8,.8,1.2 EntityFX bird\mesh,16 ; Case 14 ;dark-eyed junko ; bird\mesh = LoadAnimMesh("meshes/yellow_billed_cuckoo-anim.b3d") ; ;bird\mesh = LoadAnimMesh("meshes/olivesided_flycatcher-anim.b3d") ; Animate bird\mesh,1,Rnd(.1,.2),0,0 ; feathers=LoadTexture("textures/YellowBilled_Cuckoo_masked_ind.bmp",5+8) ; ;feathers=LoadTexture("textures/olivesided_masked_ind.bmp",5+8) ; EntityTexture bird\mesh, feathers ; ;ScaleEntity bird\mesh,.5,.5,.5 ; EntityFX bird\mesh,16 End Select PositionEntity bird\mesh, Rnd(-200,200),Rnd(-200,200)+(fs#*0.5),Rnd(-200,200),True bird\speed# = Rnd(.1,1.5) Next dateTXT = "BackYard Bird Count,Oberlin Ohio,Spring Migration 2008,28 species reported " End Select worldstate = 1 ;startup the scene FadeIn() End Function Function UpdateSound() If EntityDistance (cam,birds) > 300 For bird.birds = Each birds StopChannel bird\sing FreeSound bird\sing Next End If End Function ;main mechanics of bird simulation Function UpdateScene() navigate() UpdateBirds() ChangeBirdState() UpdateWorld RenderWorld curtime=MilliSecs() FPS=1000/(curtime - prevtime) prevtime=curtime SetFont titleFont Color 150,150,150 OutlineText (GraphicsWidth()/2,90,"Species Bird Count, Lake Erie Basin, Black-Rocky Watershed" ,True,False) SetFont subtitleFont OutlineText(GraphicsWidth()/2,150, dateTXT, True,False) Color 255,255,255 ; Text 10,40,"Hit escape key to quit," ; Text 10,70,"Hit Space to unload previous birds and load new set of birds" ; Text 10,100,"Hit enter key to add new set of birds to previous birds" Text 10,860,"FPS:"+FPS ; Text 10,320,"Camera Z="+EntityZ(cam,True) Flip WaitTimer tmrFPS ; While (time > MilliSecs() - 3200) And (Not KeyDown(1)) And birdstate = 0 ; PastCycle ; Wend ; If MilliSecs() > 10000 And birdstate = 0 Then ;; JumpTimer=MilliSecs()+time;(1000 * 300);(1000+60+2);(1000+60+5) ; PastCycle() ;; birdstate = birdstate + 1 ; ; End If ; If MilliSecs() > 40000 And birdstate = 1 Then ; JumpTimer=MilliSecs()+time;(1000 * 300);(1000+60+2);(1000+60+5) ; PastCycle() ;; birdstate = birdstate + 1 ; ; End If ; If KeyHit(28) PastCycle() ; If KeyHit(57) CleanupScene() End Function ;move birds in the scene Function UpdateBirds() For bird.birds = Each birds If EntityX(cam,True)-EntityX(bird\mesh,True) > 300 HideEntity bird\mesh PositionEntity bird\mesh, EntityX(bird\mesh,True)+400,EntityY(bird\mesh,True),EntityZ(bird\mesh,True),True ShowEntity bird\mesh Else If EntityX(cam,True)-EntityX(bird\mesh,True) < -300 HideEntity bird\mesh PositionEntity bird\mesh, EntityX(bird\mesh,True)-400,EntityY(bird\mesh,True),EntityZ(bird\mesh,True),True ShowEntity bird\mesh EndIf If EntityZ(cam,True)-EntityZ(bird\mesh,True) > 300 HideEntity bird\mesh PositionEntity bird\mesh, EntityX(bird\mesh,True),EntityY(bird\mesh,True),EntityZ(bird\mesh,True)+400,True ShowEntity bird\mesh Else If EntityZ(cam,True)-EntityZ(bird\mesh,True) < -300 HideEntity bird\mesh PositionEntity bird\mesh, EntityX(bird\mesh,True),EntityY(bird\mesh,True),EntityZ(bird\mesh,True)-400,True ShowEntity bird\mesh EndIf If EntityY(cam,True)-EntityY(bird\mesh,True) > 300 HideEntity bird\mesh PositionEntity bird\mesh, EntityX(bird\mesh,True),EntityY(bird\mesh,True)+400,EntityZ(bird\mesh,True),True ShowEntity bird\mesh EndIf MoveEntity bird\mesh, 0, 0 ,-bird\speed# *.5 Next End Function ;movement keys for camera Function navigate() If KeyDown (200) MoveEntity cam,0,0,1 EndIf If KeyDown (208) MoveEntity cam,0,0,-1 EndIf End Function ;additive cycle for past Oberlin counts Function PastCycle() FadeOut worldstate = 0 ;prepare to load next set of birds birdstate = birdstate + 1 If birdstate > 6 ;determines how many sets of birds to cycle through birdstate = 0 EndIf End Function ;remove all birds Function CleanupScene() FadeOut() For bird.birds = Each birds FreeEntity bird\mesh StopChannel bird\sing FreeSound bird\sing Delete bird Next worldstate = 0 ;prepare to load next set of birds birdstate = birdstate + 1 If birdstate > 6 ;determines how many sets of birds to cycle through birdstate = 0 EndIf End Function End |
| ||
You could try something along the lines of...Graphics 800,600,0,2 global selectedBird=1 ; this is the variable you feed your case statement with global startTime%=MilliSecs() While Not Keydown(1) ; just a loop to test Cls If MilliSecs()>startTime+30000 then ; check for 30 second since we last changed. selectedBird=selectedBird+1 if selectedBird>6 then selectedBird=1 ; loop back to 1 if we have reach the last bird endif Text 10,10,"Current Bird Is "+selectedBird Flip Wend |
| ||
thanks uncle, I will try it out. |