Yue Posted July 26, 2017 Share Posted July 26, 2017 -- Loading Barr Progress Map. -- Yue Rexie -- Engine LeadWerks ventana = Window:Create("Test",0,0, 800,600, Window.Titlebar + Window.Center ) lienzo = Context:Create( ventana ) fuente = Font:Load("Fonts/space age.ttf",24) lienzo:SetFont(fuente) mundo = World:Create() local x = 0 mapa = 0 co = coroutine.create(function () mapa = Map:Load("Maps/start.map") end) while x <= 199 do -- Salir. if ventana:Closed() then return false end if ventana:KeyHit(Key.Escape ) then return false end x = x + 1 if x == 150 then coroutine.resume(co) end lienzo:SetBlendMode(Blend.Alpha) lienzo:SetColor(1,1,1) lienzo:DrawText("LOADING", lienzo:GetWidth()/2-fuente:GetTextWidth("LOADING")/2, lienzo:GetHeight()-75 ) lienzo:DrawRect(lienzo:GetWidth()/2-100, lienzo:GetHeight()-50, x, 25) lienzo:SetColor(0.5,0.5,0.5) lienzo:DrawRect(lienzo:GetWidth()/2-100, lienzo:GetHeight()-50,200, 25, 1 ) lienzo:Sync() end while true do if ventana:Closed() then return false end if ventana:KeyHit(Key.Escape ) then return false end Time:Update() mundo:Update() mundo:Render() lienzo:Sync() end 2 Quote Link to comment Share on other sites More sharing options...
Rick Posted July 26, 2017 Share Posted July 26, 2017 Im confused. Is this a fake loading bar? As far as I know Map:Load() is blocking as it loads the map from file. Why put it in the coroutine function? Quote Link to comment Share on other sites More sharing options...
Yue Posted July 26, 2017 Author Share Posted July 26, 2017 Hi, Rick. If it is a false load bar, because I understand that in Lua you can not work with threads. When a certain percentage is reached, the map is loaded and while the load is being loaded the progress bar is paused, and then continues its animation. I put it in a coroutine, because when the coroutine is loaded, it goes to a dead state and it does not run any more. I would like to find another alternative, but I see no other more feasible. Quote Link to comment Share on other sites More sharing options...
Rick Posted July 26, 2017 Share Posted July 26, 2017 Interesting use for coroutine. Never thought of a one time shot usage for that. Quote Link to comment Share on other sites More sharing options...
Yue Posted July 29, 2017 Author Share Posted July 29, 2017 Video Bar progress load map. Quote Link to comment Share on other sites More sharing options...
mdgunn Posted September 23, 2017 Share Posted September 23, 2017 If you tried this on a mechanical disk and also a SSD would the results vary a lot do you think? I think the SSD may load before 100% complete or the mechanical may say 100% for some time I think. I suppose you could first do a quick estimate of I/O speed by reading a small test file in and then adjusting the timer accordingly to better guess when 100% might hit. Maybe with a larger map you might want something more like a spinner where you are not saying how much is loaded but rather that loading is taking place? Neat example. Never tried co-routines but they seem like a nice easy way to get a simple loading screen going. Thanks! Quote Link to comment Share on other sites More sharing options...
gamecreator Posted September 23, 2017 Share Posted September 23, 2017 @mdgunn, I posted this in another thread but you can just pre-load all the models (trees, rocks, grass, etc.) yourself and show the progress bar at that time. Then, when you load the map, it should load very quickly since all of the models are already loaded and in memory. Not to take anything away from Yue's work; I can't speak to it as I haven't tried it. This is just another option. 1 Quote Link to comment Share on other sites More sharing options...
mdgunn Posted September 25, 2017 Share Posted September 25, 2017 OK thanks I try to search that out. Quote Link to comment Share on other sites More sharing options...
gamecreator Posted September 25, 2017 Share Posted September 25, 2017 Sorry, I wasn't clear. I didn't post the code but just what I mentioned above. You can just load models one by one and increment your loading progress bar. Then you load the map after. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.