Page 1 of 1

IncludeBinary Tip

Posted: Mon Aug 30, 2010 8:55 pm
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)

Re: IncludeBinary Tip

Posted: Tue Aug 31, 2010 11:44 pm
by marc_256
Hey J.Baker,

Thanks, this is very useful for me also,
I just loaded about 50 files by hand ... so ...


Marc

Re: IncludeBinary Tip

Posted: Tue Aug 31, 2010 11:47 pm
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. ;)

Re: IncludeBinary Tip

Posted: Wed Sep 01, 2010 5:13 am
by J. Baker
I've updated the code so it also debugs the CatchSprite(). Modify as needed. ;)