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 Discussion / Finals not working right

Author
Message
Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 26th Jan 2008 02:53
I have a question how come when I build finals some of the media files e.g. music don't play but when I build it as an exe and include the media files it works fine any ideas?

Windows Is better than everything
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 26th Jan 2008 03:20
Probably because you are using FULL filename paths instead of relative.

I only explained this in another post a couple of days ago, but can't remember where.

Copy all of your music into a folder called Music in your project folder.

The in your program, use Load Music "Music\Filename.mid",1 or whatever command you use.

TDK_Man

Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 26th Jan 2008 03:39 Edited at: 26th Jan 2008 03:41
its still the same after i make the final it works fine in the editor if you want heres the source code. i didn't include the media files

Windows Is better than everything

Attachments

Login to view attachments
Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 26th Jan 2008 03:47
ok this is what i got so far the final works fine as long as i have the media files in the same folder else it just includes the sprite and the first music. any ideas now?

Windows Is better than everything
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 26th Jan 2008 07:58
I had problems with finals, I think it was because I had two files with the same name but in different sub-folders.
TDK knows more about that kind of thing though.

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 26th Jan 2008 22:54
Relative paths can be difficult to get your head around at first, but I'll try and explain it in simple terms...

OK, imagine the following file and folder structure on your hard disk:

GFX File Located In: C:\Data\DB\Graphics\Background1.jpg
DB Project Directory: C:\Programming\Dark Basic\DBC\Projects\MyGames\Pong\

And in your program you have:

Load Image "C:\Data\DB\Graphics\Background1.jpg",1

This is a full path as it includes the drive letter and all subdirectories. If you give a normal exe (not a Build Final exe) of your program to someone else, Background1.jpg has to be on drive C: in that exact location for it to be found by your program. The chances are it's not, so your game will only run on your computer.

So, you use Build Final to include the image in your exe - but it still doesn't work. Why?

Well, your program is still trying to access the image using that specific path - even though it is now built into the exe. It still works on your machine because you still have the original image in the correct location...

With Build Final, think of your exe being turned into a new virtual hard disk drive with the root (C:\) being the current project folder - in the case of the above path example, the 'Pong' directory.

In this situation, the Projects folder (or anything before it in the path) does not exist.

However, any folders in the Pong directory will be sitting there on the 'virtual drive' - along with anything on them.

So, you create folders inside the Pong directory to hold all your media files and copy them all over, changing the Load commands to access the media in the folders within the Pong directory.

But, Build Final still doesn't work!

This is because your Load commands are still pointing to specific folders with full paths. Don't forget, your game exe might be run from C:\Games\Pong so:

Load Image "C:\Programming\Dark Basic\DBC\Projects\MyGames\Pong\Images\Background1.jpg",1

...isn't going to find that jpg image like it does when running it on your machine!

This is where 'relative' paths come in.

Take the path:

C:\Programming\Dark Basic\DBC\Projects\MyGames\Pong\Images\

If your dba file is in the Pong folder then the Images folder can be accessed directly - without all the preceding C:\ and all those folders. So, loading the image just needs:

Load Image "Images\Background1.jpg",1

As it's relative to the 'root' (the Pong folder in your exe), it doesn't matter where the exe is run from on another machine, the Images folder is always available.

You just need to do the same thing with everything that is loaded off disk.

Hope this helps clear up the confusion.

TDK_Man

Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 27th Jan 2008 00:14 Edited at: 27th Jan 2008 01:45
ok heres what i have to beggin with before i started asking the question all the media files were in the same folder so what your saying is if i want the finals to read the file i have to type the whole thing? like where its located and stuff? this is kind of confusing but i'll explain what i have right now ok to start off the dba file and all the media files are located in a folder called The Link game in the folder i have 3 New folders avi music pic

when loading i do what you say
ok but when i load the final this is what happens only some one the media files play i plays one song and loads sprite sheet and excutes the code now this is really confusing maybe if i sent you some screenies would that help?

[edit]

ok heres what i've done ive done what you said above and all the media files are in the same folder and when adding files in finals i think it adds all of them but it only plays the first media file i'm really getting ticked off now.


p.s. by media file i mean music

Windows Is better than everything
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 27th Jan 2008 02:59
In your first post you said:

Quote: "how come when I build finals some of the media files e.g. music don't play but when I build it as an exe and include the media files it works fine any ideas?"


Only now you mention something you didn't make clear in the first post:

Quote: "but it only plays the first media file"


The second sentence points us in a totally different direction with regard to the problem. I don't think it's anything to do with loading locations and paths (or it wouldn't find the first one either) but rather the way that DBC works with music files embedded into exe's created with Build Final.

I seem to remember coming across this problem a long, long time ago and if I remember correctly it's a bug which was never fixed.

I got round it at the time (I think) by not loading music 1, 2, 3 and so on, but just using music slot 1 over and over again, re-using the Load Music command as and when required.

So instead of:

load music "music/Mario.mp3" ,1
load music "music/Link.mp3" ,2
load music "music/train.mp3" ,3


you would have

load music "music/Mario.mp3" ,1
or...
load music "music/Link.mp3" ,1
or...
load music "music/train.mp3" ,1

...just before the Play Music 1 in your program.

TDK_Man

Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 27th Jan 2008 06:00
oh...thanks and how come this was never fixed?

Windows Is better than everything
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 27th Jan 2008 07:27
Quote: "how come this was never fixed?"


I don't know.

More importantly though, did the work-around fix the problem for you as I'm not 100% sure that it is the correct solution.

Let us know in case others come across this in the future.

TDK_Man

Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 27th Jan 2008 16:37
Yes it fixed my problem and sorry that my first question was misleading

Windows Is better than everything
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 27th Jan 2008 17:28
i hate the music commands they are so crappy!
I try to convert my music so i can use it as a sound instead

Login to post a reply

Server time is: 2025-06-04 02:10:26
Your offset time is: 2025-06-04 02:10:26