What am I doing wrong
Blitz3D Forums/Blitz3D Programming/What am I doing wrong
| ||
Ok, fellow blitzers what am I doing wrong with this code?Global cellB, cellR, cellY, blank ; main graphic images Global Screen_Width = 1024 Global Screen_Height = 768 Global Title ; handle for title graphic Global TmpDir$ = "C:\This PC\Documents\workspace\" I have set up cellB, cellR, cellY, and Title as Global variables so that ALL functions can see them. That way, when I get to the function LoadGraphics(), I can read the file life.jpg into the Title handle directly and retain the value like so Function LoadGraphics() Title = LoadImage(TmpDir$ + "media\life.jpg") cellB = LoadImage(TmpDir$ + "media\cell black.jpg") cellR = LoadImage(TmpDir$ + "media\cell red.jpg") cellY = LoadImage(TmpDir$ + "media\cell yellow.jpg") blank = LoadImage(TmpDir$ + "media\blank.jpg") Zero = LoadFont("Saved by Zero",18,False,True,False) SetFont Zero End Function However, when I get to the function DisplayTitle(), the line where it says DrawImage Title, CenterX, 0 it reports that the image does not exist. I made sure that TmpDir$ contains the proper Directory, and debug made sure that I use that! Function DisplayTitle() Iw = ImageWidth(Title) CenterX = Screen_Width/2 - Iw/2 DrawImage Title, CenterX, 0 Cpy$(1) = "Adapted by Amanda Dearheart" Cpy$(2) = "Based on Life by John Conway" Cpy$(3) = "(C) 2013 Crazy Scorpion" For M = 1 to 3 Tw = Len(Cpy$(M)) CenterX = Screen_Width/2 - Tw * 6 y3 = 400 + (M * 25) Text CenterX, y3, Cpy$(M) Next Flip d = TimerPause(5000, True) cls Return d End Function |
| ||
Could be because you've got spaces in the pathname and filenames. |
| ||
Be sure you are loading images AFTER setting the graphics mode. Otherwise the previously loaded images are cleared as part of the graphics initialization. |
| ||
I'm wondering.....what happens if you use relative paths....is it possible that the path you think exists is actually not the true path? (ie TmpDir) also...do you get a non zero value for Iw? The graphics mode thing that Floyd mentioned is another possibility. |
| ||
the 'Documents' path name can be a bit tricky on Winsdows OS - it sometimes gets resolved 'strangely'. Try using pathnames like "./this_directory/that.txt" |
| ||
Thanks for the hint Mr. 'plotter. I don't know if the 'Documents' name was the cause of my problem, but I did change TmpDir$ to the name of the external hard drive I just recently bought, and the program works like it did when i was developing it on my XP machine! |
| ||
Glad to be of help Ms Dearheart - interesting you mention dev between your XP and your latest dev OS - the front end of my current project is developed on an XP machine - which certainly has different ways of resolving the 'My Documents' folder compared to Windows 7 B3D complier machine - that took some figuring out I can tell you ;) |
| ||
Yeah, my current OS is Windows 8.1. Hopefully, the program files directory has remained unchanged since that is the final place I wish to install the program to when I'm finished. |