IonicWind Software

IWBasic => General Questions => Topic started by: J B Wood (Zumwalt) on December 05, 2006, 09:33:09 PM

Title: LoadSprite with Resource
Post by: J B Wood (Zumwalt) on December 05, 2006, 09:33:09 PM
Doesn't work.
I add a resource, in this case a bitmap file and call the resource Background for the ID.
Then I use:

backgroundsprite = LoadSprite("Background",800,600)

I test with the IF backgroundsprite<>NULL, and it skips the rest of the code since backgroundsprite=null
However, if I use the LoadSprite("full path to bmp",800,600) it works.
Just thought I would mention it since my project uses resources heavily.
Title: Re: LoadSprite with Resource
Post by: Ionic Wind Support Team on December 05, 2006, 09:37:29 PM
Nope.  The 2D sprites are file based only at the moment.  I can change it to check for resources though,
Title: Re: LoadSprite with Resource
Post by: J B Wood (Zumwalt) on December 05, 2006, 09:38:44 PM
Good to know.
I would like for them to be in the resource, but no rush.
Title: Re: LoadSprite with Resource
Post by: Ionic Wind Support Team on December 05, 2006, 09:40:27 PM
Actually they do work from resources, but have to be a scalable image type, which supports gif, jpg and bitmap.  Just looked at my conversion of DDLoadImage.
Title: Re: LoadSprite with Resource
Post by: J B Wood (Zumwalt) on December 05, 2006, 09:42:16 PM
It is a bitmap. I made them all bitmaps because of Aurora.
Grab the background.bmp from within the img folder of the zip you got from me.
That is the one I am using.

Another quick question, multiple source files, all in the same project, nothing special is needed to use subs in the other source files right?
Title: Re: LoadSprite with Resource
Post by: Ionic Wind Support Team on December 05, 2006, 09:44:03 PM
'in defining file
global sub mysub(),int
{
}

'in file using the sub from the defining file
declare extern mysub(),int

You're too spoiled by OOP now so probably aren't used to having to do that ;)
Title: Re: LoadSprite with Resource
Post by: J B Wood (Zumwalt) on December 05, 2006, 09:48:19 PM
Thats Aurora code Paul :)


In seperate source:

SUB mySub()
RETURN
ENDSUB

So in my main source I still have to call declare extern in EBasic?
Title: Re: LoadSprite with Resource
Post by: Ionic Wind Support Team on December 05, 2006, 09:51:52 PM
sorry.  Half asleep at the moment ;)

globa sub mysub(),int
return 0
endsub

declare extern mysub(),int

Quote
So in my main source I still have to call declare extern in EBasic?

Yes it tells the linker the subroutine is external to the source file using it.  Same as in Aurora.
Title: Re: LoadSprite with Resource
Post by: J B Wood (Zumwalt) on December 05, 2006, 09:53:53 PM
Thanks, that takes care of that question in this thread.
Title: Re: LoadSprite with Resource
Post by: Ionic Wind Support Team on December 05, 2006, 09:54:59 PM
Quote from: Jonathan (zumwalt) Wood on December 05, 2006, 09:42:16 PM
It is a bitmap. I made them all bitmaps because of Aurora.
Grab the background.bmp from within the img folder of the zip you got from me.
That is the one I am using.

Like I said it has to be in the resource dialog as a "scalable image" type, not a "bitmap" type in order to work with loadsprite
Title: Re: LoadSprite with Resource
Post by: J B Wood (Zumwalt) on December 05, 2006, 09:59:03 PM
Ah ok, I'll mess around with this some more.
Title: Re: LoadSprite with Resource
Post by: J B Wood (Zumwalt) on December 06, 2006, 06:48:39 AM
Paul, why bother with having any other type in the Resoures but scalable image?
Is there a purpose in having a bitmap category?
Title: Re: LoadSprite with Resource
Post by: Ionic Wind Support Team on December 06, 2006, 09:46:03 AM
Yes.  They are all windows resource types, not something we invented ;)

The native Windows GDI functions only work with bitmaps or metafiles.  You can't use RTIMAGE types with them.  RTIMAGE, what we call a scalable image, uses the IPicture COM interface.  So for example a bitmap button, a functionality provided by Windows, only accepts a handle to a bitmap image. 
Title: Re: LoadSprite with Resource
Post by: J B Wood (Zumwalt) on December 06, 2006, 09:58:03 AM
Ok, so for all of my game images, its best to use nothing but scalable images as the resource selection.
I tried what you suggested and it worked for the background, although still have scaling issues, not that I care about that since I am reworking all of the images and doing up some new ones for animation.

I figured every game loop I will pass a new image id through for which image to show in the animation sequence. Long way to go still, but should have something by next weekend hopefully if time permits.
Title: Re: LoadSprite with Resource
Post by: Ionic Wind Support Team on December 06, 2006, 10:04:23 AM
Sprites support frame based animation natively.  You only need to specify the number of frames when loading, and change the frame number to change the image.

Frame based sprites have been around for ages.  Just use an image editor and create a bitmap containing all of the frames of animation. See the included image file chomper.bmp and mouth.bmp to see what I mean.
Title: Re: LoadSprite with Resource
Post by: J B Wood (Zumwalt) on December 06, 2006, 10:29:57 AM
*nods*
I got a few utilities now that I purchased that takes an animated 3d mesh as an X file and converts it into a working image map. (renders it to a single file for games)
Really cool effect.