IncludeBinary Tip

Share your advanced PureBasic knowledge/code with the community.
User avatar
J. Baker
Addict
Addict
Posts: 2185
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

IncludeBinary Tip

Post by J. Baker »

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.
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
marc_256
Addict
Addict
Posts: 844
Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:

Re: IncludeBinary Tip

Post by marc_256 »

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 ...
User avatar
J. Baker
Addict
Addict
Posts: 2185
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: IncludeBinary Tip

Post by J. Baker »

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. ;)
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
J. Baker
Addict
Addict
Posts: 2185
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: IncludeBinary Tip

Post by J. Baker »

I've updated the code so it also debugs the CatchSprite(). Modify as needed. ;)
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
Post Reply