question about sprites

Blitz3D Forums/Blitz3D Beginners Area/question about sprites

Duckstab[o](Posted 2004) [#1]
hello all

im currently making a card game similar to one done in FF8
yet mine will have a least a thousand cards
this makes the image need for my game huge

each card contains at least a background and four numeric values at each side

for my game i want to use sprites but can you draw straight to sprites or do you create imagebuffer and load
that into a sprite

i want to be able to change the background or any value at anytime in any sprite

since i will only ever need access to 120 sprites max at any one timei can free and load to save memory

any input would be great thanks
[o]duckstab

also variables passed through functions do they have to be global :0


CS_TBL(Posted 2004) [#2]
the last question: no


WolRon(Posted 2004) [#3]
Last question: No point in passing them to the function if they are global.


Matty(Posted 2004) [#4]
A number of easy ways to do what you are suggesting:

I am not sure if you mean 2d or 3d so I will answer for both.

In 3d, a sprite can be given a texture (entitytexture command). Use an animated texture, basically a set of images within the main image, and when you need to change the image on the sprite simply call the entitytexture command with the appropriate frame.

In 2d a sprite/image can be drawn using a similar technique by using the loadanimimage() command. The number of 2d images that can be drawn on the screen at one time shouldn't be a problem at all, and all you have to do is change the particular frame of the image which is drawn.

Also, in answering that last question:

Variables passed through functions do not have to be global as they are accessible everywhere throughout your program. However, if your parameter in the function declaration has the same name as a global variable then changing the value of that variable within the function will not affect the global variable.


WolRon(Posted 2004) [#5]
However, if your parameter in the function declaration has the same name as a global variable then changing the value of that variable within the function will not affect the global variable
Which in my opinion is confusing, so it's best to use different names.


Duckstab[o](Posted 2004) [#6]
thanks for your help

I want to create 3d sprites and each sprite will have 6 layers to keep these seperate or merge them? me is a noob and aint sure what to do

I tried creating a imagebuffer and drawing all info to this
then creating a sprite from the imagebuffer but dont have any real idea how to do this

my problem
ten cards can have the same background
so i create ten diffent texturebuffers and loadin the background yet when i edit any texturebuffers after that it effects all texturebuffers with the same background is there any way around this

my plan is to have a background bottom layer
picture layer above
foursection layer above that

to be able to draw these to one image ingame would save the need for 1000+ saved pngs
could create these using 60 to 65 images in a fast time

I made a programme in blitzbasic some years ago to create cards sets this way but creating the card you need is quicker than looking at thousands to find the one i want

me is one messed up Duck :)


Sunteam Software(Posted 2004) [#7]
The problem with texture buffers is that it works on a 1 to many relationship with the surfaces that use it. Therefore if you use 1 texture buffer for many surfaces, then when you edit that texture buffer all surfaces will show the changes. The ONLY way around this afaik is to create a seperate texture buffer for each instance.

However in your case you wouldn't necessarily need to load all the imagery as textures. You could create an arbitrary number of texture buffers for the predicted amount of cards you require on screen at one time. Then assemble the pieces of each card, i.e. paste each part onto the buffer where required to make the final image.

So to do this, I presume a little detail would help, you would do the following:

1. create a texture buffer
2. load in your background layer and paste it onto the texture buffer
3. load in your picture layer and paste it over the background already on the texture buffer
4. paste your 4-section layer over the rest

You could create a function that takes the texture buffer, and filenames (or lookup data depending on how you work best) for each component and then it draws the card onto the texture buffer.

The relevant commands you'll need will be:

CreateTexture, TextureBuffer, DrawImage and maybe MaskImage.

If you need any further help, i.e. with specifics then do ask, however you'll learn more from reading the command help and working out the details yourself. Give it a go and post back if you get stuck.


Duckstab[o](Posted 2004) [#8]
thankyou all got it sorted hope ill be posting the demo soon just a bit more AI and textures to do

wish you all luck in your projects

:) [o]duckstab


Duckstab[o](Posted 2004) [#9]
hello again:)

built a prog to draw relevant cards and save them as bmps as the game progresses as loading premade cards gives 400+fps yet multitex cards gives around 100+mark on high pc

I have been looking if there is a way to convert these into jpg as the final total card file will be nearly 2gig in bmp compared to max of 120mb in jpg
wondering it you know of any routine or free plugin to do so.
i could pack premade cards yet this would give a large dl time