Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Background Loading?

Author
Message
Broken_Code
15
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 8th Sep 2010 02:52
Background loading, how is it done? Basically I want to be able to load the game's level and set up the game variables etc. but allow the players to communicate with each other (it's a net game) while the game's loading as it takes a while, how would I go about doing this?

Thanks,
Broken_Code
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 8th Sep 2010 16:16
The easiest way would be to have the chat screen update several times during the loading process, so it appears to be doing the loading and allowing the chat at the same time. Your still gonna have delays when loading big files, but it all depends on how you handle it.

For example, say your chat screen was wrapped up in a function called chat()...

chat()
load image "test.png",1
chat()
load object "test.x",1
chat()
open to read "test.dat",1
for x=0 to 100
for y=0 to 100
read byte 1,b
map(x,y)=b
next y
chat()
next x

That's untidy of course, I would suggest having a custom function for loading media that executes the chat function as well as some error trapping - you could even share a console screen, so you get error messages in amongst the chat.

The chat function would need to be pretty quick at checking for keyboard input, and new incoming messages, like in and out as quickly as it can. It will also slow down the loading process - but I say 30 seconds of chat is far better than 10 seconds of loading.

Health, Ammo, and bacon and eggs!
Broken_Code
15
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 15th Sep 2010 03:48
Thanks for that Van B, that's kind of what I was thinking. At the moment my chat function uses input via the entry buffer and memblocks to send/receive strings.

Is there a way to run the chat (or any program for that matter) as a separate program alongside the game that's loading? That way there'd be fast chat and it wouldn't interrupt loading (especially on multi-core machines).

Thanks,
Broken_Code

Login to post a reply

Server time is: 2026-07-22 12:41:33
Your offset time is: 2026-07-22 12:41:33