Share your advanced PureBasic knowledge/code with the community.
J. Baker
Addict
Posts: 2185 Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:
Post
by J. Baker » Mon Aug 30, 2010 8:55 pm
While working on a game I was including a lot of images. I figured why should I have to write them all out. See code below. Change "ImageNum" if you are adding to the DataSection.
Code: Select all
Dir$ = "Game Images\"
ImageNum = 0
ExamineDirectory(0, Dir$, "*.png")
Repeat
Result = NextDirectoryEntry(0)
ImageName$ = DirectoryEntryName(0)
ImageNum +1
If Result = 0
Break
EndIf
;Debug "Pic" + Str(ImageNum) + ": IncludeBinary " + Chr(34) + Dir$ + ImageName$ + Chr(34)
Debug "CatchSprite(" + Str(ImageNum) + ", " + "?Pic" + Str(ImageNum) + ", " + "#PB_Sprite_AlphaBlending | #PB_Sprite_Texture)" + " ;" + ImageName$
ForEver
FinishDirectory(0)
Last edited by
J. Baker on Wed Sep 01, 2010 5:12 am, edited 3 times in total.
marc_256
Addict
Posts: 844 Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:
Post
by marc_256 » Tue Aug 31, 2010 11:44 pm
Hey J.Baker,
Thanks, this is very useful for me also,
I just loaded about 50 files by hand ... so ...
Marc
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
J. Baker
Addict
Posts: 2185 Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:
Post
by J. Baker » Tue Aug 31, 2010 11:47 pm
marc_256 wrote: Hey J.Baker,
Thanks, this is very useful for me also,
I just loaded about 50 files by hand ... so ...
Marc
Your welcome. Repetitive coding is never fun.
J. Baker
Addict
Posts: 2185 Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:
Post
by J. Baker » Wed Sep 01, 2010 5:13 am
I've updated the code so it also debugs the CatchSprite(). Modify as needed.