Changing a bmap for a sprite?

Posted By: Scramasax

Changing a bmap for a sprite? - 06/07/07 20:16

I'm trying to change the bmap on a sprite. Here's what I've done. What am I doing wrong? Thanx.

Code:
  
bmap testBMAP =<rooidle_west0000.pcx>;


function changeMap()
{
my.bmap =testBMAP;
}


Posted By: Scorpion

Re: Changing a bmap for a sprite? - 06/07/07 20:20

the bmap for th sprite is also a skin, so you have to use bmap_for_entity to get the bmap pointer to the texture and then you can replace it
Posted By: Scramasax

Re: Changing a bmap for a sprite? - 06/07/07 21:43

I tried using bmap_for_entity, but no luck. Am I doing this right? Or is there a pointer conversion I'm screwing up on?
Code:
  
bmap testBMAP =<rooidle_west0000.pcx>;
bmap* ptr;

function changeBMap()
{
ptr =bmap_for_entity(my,0);
bmap_unlock(ptr);
ptr =testBMAP;
}


Posted By: xXxGuitar511

Re: Changing a bmap for a sprite? - 06/08/07 05:02

You don't need the bmap_unlock()

Even then, I don't kow if copying the image will work that way.

Here's another idea using bmap_blit() to copy the image:
Code:

bmap testBMAP = <rooidle_west0000.pcx>;
bmap* ptr;
function changeBMap()
{
ptr = bmap_for_entity(my,0);
bmap_blit(ptr, testBMAP, 0, 0);
}


Posted By: Xarthor

Re: Changing a bmap for a sprite? - 06/08/07 05:59

Well what about the good old "ent_morph(entity, string);" ?

If you have a pointer to your sprite just do something like this:
Code:

function changeSprite(_ent,_file)
{
ent_morph(_ent, _file);
}

//call like this:
changeSprite(mySprite_Pointer,"new_bitmap.pcx");


Not tested but should work.

EDIT:
Now that I've read Scorpion's response I guess that you could give "ent_morphskin(ENTITY* entity, STRING* filename);" a shot too.
Posted By: Scorpion

Re: Changing a bmap for a sprite? - 06/08/07 10:57

yep everyhting should work, if you can change the skin of an entity, you can also change it by a sprite :]
Posted By: Scramasax

Re: Changing a bmap for a sprite? - 06/08/07 16:37

bmap_blit is what I need, but I don't see it in the manual and it doesn't like it in the script editor. Is it in the beta?

The real code looks like this. I'm using a link list in a .dll to push out various BMAPs so I need it to be a bmap and not the name of one.

Code:

function animNorth_entSprite()
{
var animRate =60;
var numFrames =0;
numFrames =GetNumAnimBMap(my.northKeyIdle);
var animFrame =0;
while(1)
{
animFrame +=GetSeconds();
if(animFrame>=numFrames)
{
animFrame =0;
}
my.bmap =GetAnimBMap(my.northKeyIdle,int(animFrame));

my.scale_x =1;
my.scale_y =1;

wait(1);
}
}



Guess I'll write a c++ function for now.
© 2024 lite-C Forums