March 29, 2024, 05:09:36 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


LoadSprite with Resource

Started by J B Wood (Zumwalt), December 05, 2006, 09:33:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

J B Wood (Zumwalt)

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.

Ionic Wind Support Team

Nope.  The 2D sprites are file based only at the moment.  I can change it to check for resources though,
Ionic Wind Support Team

J B Wood (Zumwalt)

Good to know.
I would like for them to be in the resource, but no rush.

Ionic Wind Support Team

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.
Ionic Wind Support Team

J B Wood (Zumwalt)

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?

Ionic Wind Support Team

'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 ;)
Ionic Wind Support Team

J B Wood (Zumwalt)

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?

Ionic Wind Support Team

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.
Ionic Wind Support Team

J B Wood (Zumwalt)

Thanks, that takes care of that question in this thread.

Ionic Wind Support Team

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
Ionic Wind Support Team

J B Wood (Zumwalt)

Ah ok, I'll mess around with this some more.

J B Wood (Zumwalt)

Paul, why bother with having any other type in the Resoures but scalable image?
Is there a purpose in having a bitmap category?

Ionic Wind Support Team

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. 
Ionic Wind Support Team

J B Wood (Zumwalt)

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.

Ionic Wind Support Team

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.
Ionic Wind Support Team

J B Wood (Zumwalt)

*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.