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.

Dark GDK / Simple dbSprite question

Author
Message
Foz
16
Years of Service
User Offline
Joined: 18th Dec 2007
Location: California
Posted: 11th Jun 2008 22:17
This may prove to be my most embarrassing post yet. For some reason I'm experiencing incredible brain-collapse over the following kindergarten level code. I cannot get the image to appear as it should - I know the image is loaded because it appears for a split-second at a default (0,0). I've commented-out nearly every line of code at one point or another out of frustration with no result, so I know it's not a single line of code that's causing the problem.




Foz, I am.
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 11th Jun 2008 22:22
Worked fine for me, though I did substitute my own graphic which I specified as being at the root of my C: drive just in case.

FWIW, you don't have to put the dbSprite call inside the loop unless you're changing its position. I've run it both ways and I still get my graphic to show. Try giving a fully qualified path to the image file just to be sure.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 11th Jun 2008 22:45
looks fine to me too. though one question, why 16bit display instead of 32?

jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 11th Jun 2008 23:07
You could call dbImageExist(1) to make sure it loaded.
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 11th Jun 2008 23:43
I caught it but because he said that the image flashed up there for a moment I figured somehow the file didn't have an extension but DGDK was able to find the file, analyze the content and load it anyway.

That's what I get for assu.... uh,figuring.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Foz
16
Years of Service
User Offline
Joined: 18th Dec 2007
Location: California
Posted: 12th Jun 2008 00:44
After studying the 'image', I see that it's actually a section of a footpint left by a retreating window of some kind - one with almost the exact same aspect ratio as my image...

I've added the missing extension, and still nothing. the image is loose in the same folder as the solution - is that the problem?


Foz, I am.
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 12th Jun 2008 00:58
That's always been a question. It can be assumed that the images should be either in or relative to the directory the executable is in. However, when using an IDE it's not always certain what directory the IDE considers to be the current directory.

For the sake of getting things to work, just give a fully qualified path to the file. If and when you're ready to distribute the game, that's the time to start executing the program from Windows Explorer or a link and find where the files work.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 12th Jun 2008 01:03 Edited at: 12th Jun 2008 03:19
Yes, as a matter of fact it is the problem...now. If you are running a release build, put it in the release folder. If you arer running a debug build, put it in the debug folder.

For the record, I recommended that you check to see that it loaded properly by calling dbImageExist(1). GDK does not have any error reporting facility like DBPro does for things like bad filenames/paths.

The files need to be in the directory the executable is run from, unless you use the fully qualified pathname, or a relative one...but, those will not work the same when you take it out of your development system. It is BEST to get the current working directory on app light-off in any case.

You could use a define to do it....

#define MEDIAPATH "./"

Then, you can leave the file in the project directory, and it will work for debug and release. When you go to release it for real, just comment out the define, and load it from the current directory. (You will have to use strcat, or a similar approach until then...do you want code for that?)
SpaceMan Infinity
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location:
Posted: 12th Jun 2008 02:56
The name is wrong, it should be splash.png, they must include the extension of the image file
(I used PNG all the time)
Foz
16
Years of Service
User Offline
Joined: 18th Dec 2007
Location: California
Posted: 12th Jun 2008 05:33
Finally got it to work by moving the image into the projects folder. Don't know why it didn't occur to me try that earlier - must'a been spoiled by DBPro's single folder...

Thanks for the help.


Foz, I am.
Bishop
21
Years of Service
User Offline
Joined: 18th Dec 2002
Location: In my favorite chair...
Posted: 12th Jun 2008 07:37
I would suggest always putting in an error routine for programs. Things like corrupted files, bad filepath, etc. can all lead to immense frustration. Rather than just assuming it will work, it is pretty easy to put in an error routine. For instance, here is your code with an error routine;


This will exit the program with an exit code of '1' to indicate the program did not run. The std::cerr could then, with a little more work, be output to a log file should you so choose to see where the problem was.

It's a good habit to get into. You can use it for many different input methods;


Etc, etc, you get the idea =D

Cheers!


Tux is my guildmaster.
Foz
16
Years of Service
User Offline
Joined: 18th Dec 2007
Location: California
Posted: 13th Jun 2008 02:37
Yeah, that's actually all good advice. I went ahead and used 'SetCurrentDirectory("./Art")' so I could just dump all my artwork into an 'art' folder next to the project file. Would that also work for the release, or do I need to use a #define?


Foz, I am.
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 13th Jun 2008 18:03
No, that will cause problems outside of your build environment. In fact, here is the best answer for your problem, in my opinion:

1. Don't change the directory in your application.
2. Continue to use directories that are subdirectories of the project directory, and use (for example) "Art/splash.png"

In your project's property pages, under the Linker General options the first item is Output File. It should look something like this:

$(OutDir)/$(ProjectName).exe

This is where you tell the linker what to name your executable, and also...where to put it. That is why it ends up in Release, or Debug...depending on the build.

If you remove the $(OutDir)/ part, leaving $(ProjName).exe, it will get put into the project directory, and it will work the way you intended in the first place.

You must remember to do this for the Release and Debug configurations if you intend to use a Debug build at some point.
Foz
16
Years of Service
User Offline
Joined: 18th Dec 2007
Location: California
Posted: 15th Jun 2008 06:20
Thanks for the advise - I'll try it...


Foz, I am.

Login to post a reply

Server time is: 2024-09-29 23:26:02
Your offset time is: 2024-09-29 23:26:02