Load Order Wrong
Blitz3D Forums/Blitz3D Programming/Load Order Wrong
| ||
Hi all, When I Run my game, the game loop start before load all media files into game, when this happen, the screen continue black and I can hear the sounds of the game running. Why this Happenning? Example of the code: Graphics3D 1024,768,32,1 HidePointer Const terr=1,pers=2 SeedRnd (MilliSecs()) Global Narra,passos Narra=LoadSound("sons\pessoas\N\narrafeira1.wav") passos=LoadSound("sons\pessoas\N\cav_7.wav") : SoundPitch passos,10000 Global ps ;Codigo para FPS Const FPS=30 Global period=1000/FPS Global time=MilliSecs()-period Global tempo=10000 terreno=LoadMesh("cenarios\feira\fi\fi.b3d") EntityType terreno,terr Global perso=LoadAnimMesh("soldado1\i\im\iniverml.b3d") Global texture=LoadTexture("soldado1\i\im\soldbranco.png") EntityTexture perso,texture ScaleEntity perso,.08,.08,.08 PositionEntity perso,10000,10000,10 Type Persons Field anda,corre Field mesh,cubo End Type For x=1 To 70 ami.persons = New persons ami\mesh=CopyEntity (perso) ami\anda=ExtractAnimSeq(ami\mesh,5,45) PositionEntity ami\mesh,Rnd(-20,5),0.01,Rnd(21,12) RotateEntity ami\mesh,0,180,0 Animate ami\mesh,1,1,ami\anda sombra=LoadSprite("imagens\ef\shadow.bmp",2,ami\mesh) EntityBlend sombra,2 ScaleSprite sombra,3,3 RotateEntity sombra,90,0,0 SpriteViewMode sombra,2 Next ami.persons=New persons ami\mesh=LoadAnimMesh("soldado1\k\k8a.b3d") ami\anda=ExtractAnimSeq(ami\mesh,1600,1640) PositionEntity ami\mesh,-5,0.01,9 ScaleEntity ami\mesh,.08,.08,.08 RotateEntity ami\mesh,0,180,0 Animate ami\mesh,1,1,ami\anda sombra=LoadSprite("imagens\ef\shadow.bmp",2,ami\mesh) EntityBlend sombra,2 ScaleSprite sombra,3,3 RotateEntity sombra,90,0,0 SpriteViewMode sombra,2 For x=1 To 5 ami.persons=New persons ami\mesh=LoadAnimMesh("soldado1\i\im\MBCav.b3d") ami\anda=ExtractAnimSeq(ami\mesh,60,100) PositionEntity ami\mesh,Rnd(-20,5),0.01,Rnd(12,10);Rnd(21,10) ScaleEntity ami\mesh,.08,.08,.08 RotateEntity ami\mesh,0,180,0 Animate ami\mesh,1,.7,ami\anda sombra=LoadSprite("imagens\ef\shadow.bmp",2,ami\mesh) EntityBlend sombra,2 ScaleSprite sombra,6,6 RotateEntity sombra,90,0,0 SpriteViewMode sombra,2 Next For x=1 To 5 ami.persons=New persons ami\mesh=LoadAnimMesh("soldado1\i\im\MCCav.b3d") ami\anda=ExtractAnimSeq(ami\mesh,60,100) PositionEntity ami\mesh,Rnd(-20,5),0.01,Rnd(12,10) ScaleEntity ami\mesh,.08,.08,.08 RotateEntity ami\mesh,0,180,0 Animate ami\mesh,1,.7,ami\anda sombra=LoadSprite("imagens\ef\shadow.bmp",2,ami\mesh) EntityBlend sombra,2 ScaleSprite sombra,6,6 RotateEntity sombra,90,0,0 SpriteViewMode sombra,2 Next Include "sky.bb" mesh_skybox = MakeSkyBox("imagens\ef\sk\sky") Global camera=CreateCamera() EntityType camera,pers PositionEntity camera,-13,1,7 RotateEntity camera,0,270,0 AmbientLight 200,200,200 Collisions pers,terr,2,3 While Not KeyDown(1) Repeat elapsed=MilliSecs()-time Until elapsed ticks=elapsed/period tween#=Float(elapsed Mod period)/Float(period) For k=1 To ticks time=time+period If k=ticks Then CaptureWorld ;FPS If Timer + 1000 <= MilliSecs() Timer = MilliSecs() FPSReal = FPSTemp FPSTemp = 0 EndIf FPSTemp = FPSTemp + 1 controlacamera() UpdateWorld Next RenderWorld tween# Flip Wend End The sounds are inside of the function "controlacamera()" called inside of the game loop. I've placed one counter inside loop to see how many times the loop is executed to open scene, the game loop pass 650 times before appear the objects in the screen. Can someone help-me? |
| ||
Have you tried taking out the frame tweening code? It's hard to assess that, with seeing the code running. Any chance you could zip up all the media and code and email me it? |
| ||
Thank's Ross C, I already understand what happenning, Is exactly because of Tweening, I'll make some changes to the game, to start after this process end. Thanks Again! |
| ||
After what process? You should know that blitz loads media on execution of the Load command, and does not continue until it is fully loaded :) |
| ||
There may be some DX problems. DirectX is using caching optimation and it may happen that your game will be paused several times in the first 10 or 20 seconds of the game, whenever the camera has to render things the very first time. So some people including me and halo developed a pre-caching function that will render the whole scene intially, with a high camera range and everything neccessary inside the field of view (kind of a satelite cam). This will make sure the game runs smoothly when the main loop is once entered. |