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.

Newcomers DBPro Corner / loading included media in code

Author
Message
Paul08
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location: Oxford, UK
Posted: 22nd Feb 2008 21:47
Hi all,
another simple one (i dont want to appear to be spamming the forum but each question deserves a different title - at least i think so)

in dbpro if i include media in the exe on the right hand panel, how do i reference it in the code?

i thought it would be like my code here:


the bit where i say texture object 1,1 - i thought would select the media in position 1 in the included media area, so my question is, how do i JUST load from the included media, rather than referencing an external file to the exe?

i found a thread in the forum, but it didnt say how to do this, just that it was possible.

thanks again!
paul
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 23rd Feb 2008 02:17
Just use Load Image.

If the image is called Fred.bmp and is in the same folder as the .dba and .dbpro files then use:

Load Image "Fred.bmp",ImageNum

If you store all your media in a folder called (oddly enough) 'Media' in your project folder use:

Load Image "Media\Fred.bmp",ImageNum

The important thing is not to load media from different places scattered all over your hard drive. Copy what you need into the project folder.

TDK_Man

Paul08
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location: Oxford, UK
Posted: 23rd Feb 2008 09:34
So essentially including media into the exe file (i mean physically packing the files with the exe) is not a good idea and not possible is what you're saying??

or are you saying that by doing a

load image "image1.bmp",1

will look in the included media in the project area?

i tried that, but it still looks externally for the image rather than the one i've attached to the project in the media window.
Paul08
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location: Oxford, UK
Posted: 23rd Feb 2008 20:56
weird, it says last post TDK when its not?
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 25th Feb 2008 19:29
Quote: "or are you saying that by doing a

load image "image1.bmp",1

will look in the included media in the project area?"


Yes. Just think of the exe with included (embedded) media as being a copy of the file structure of your project directory - but excluding non-compatible files.

So, if your program loads MP3 files from the Music folder in your project directory using:

Load Sound "Music\MySong1.mp3",1

... then the Music folder will be inside the exe so the exact same command will still work. That's because the Music folder is inside the project folder and therefore a 'relative' path.

As I mentioned, the important thing is to avoid things like:

Load Sound "D:\Music\GameSongs\MySong1.mp3",1

..because that path won't exist on other people's machines.

TDK_Man

spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 25th Feb 2008 19:56
Don't forget to check the 'settings' pane aswell. Change from 'normal EXE' to 'EXE with Attached Media', optionally selecting to compress and encrypt.

Boo!
Paul08
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location: Oxford, UK
Posted: 25th Feb 2008 21:44
excellent, you nailed it TDK, and cheers for that spooky - that would of caught me out further down the line
John Y
Synergy Editor Developer
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: UK
Posted: 26th Feb 2008 16:12
If you do change the exe type from normal to media then you must ensure that your media is in a directory below your project, otherwise it won't be added.

If your project is

C:\my Project

then your media must be somewhere like

C:\my Project\
C:\my Project\media\
C:\my Project\media\sounds\
etc..

If you use Synergy Editor it will make sure this is done for you.

Synergy Editor - Available for free HERE!

Login to post a reply

Server time is: 2024-09-27 12:24:37
Your offset time is: 2024-09-27 12:24:37