Multiple instances? (SOLVED)

Started by esper, Tue 23/01/2007 19:07:37

Previous topic - Next topic

esper

I'm making a first-person adventure game with some shooting elements. I am trying to make a bullet-hole as a "character" that, when you shoot something, will appear in the object. Is there any way to do this if, say for instance, the player decides he's feeling particularly sadistic and decides to unload twenty shots into something?
This Space Left Blank Intentionally.

GarageGothic

#1
I think it would be best to use RawDraw. If the object indeed has to be an object and can't be part of the background, you can use DynamicSprites to create a bullet riddled version of the object sprite.

1) RawClearScreen with RGB(255, 0, 255);
2) RawDraw the object to the background (this can be an already modified sprite that you are adding more holes to)
3) RawDraw bullet hole sprites on top of the RawDrawn object
4) Create the new sprite for the object using DynamicSprite.CreateFromBackground and supplying the coordinates/size of the object.
5) Assign the DynamicSprite to the object
6) RawRestoreScreen

If you DO need to apply them as a character, for some reason or another, this technique could just as well be used to create the graphic for that character to be overlaid the object.

esper

Thanks for the quick reply. I don't have enough time right now to try it, but I'll get on it as soon as I'm home from work. In the meantime, will this allow the bulletholes to be on top of everything, including objects, or will they be drawn behind?
This Space Left Blank Intentionally.

GarageGothic

No, since you're drawing them to the actual sprite which you use as an object, they would be on top of that object.

esper

Thanks again. I'll look into it, but it seems a bit more complicated than I expected. With multiple instances of a character, which I was hoping for, I could just put the new character on the screen at mouse.x,mouse.y whenever the player pulled the trigger, and then they would stay there if the character left the room and returned. But RawDraw might be my only hope...
This Space Left Blank Intentionally.

GarageGothic

It's not very advanced really. But if you want the bullet holes to stay, you can either keep the DynamicSprite in memory, OR store the x and y coordinates of the bullet holes in a struct and recreate the sprite on player_enters_room.

esper

All right, I'm back, I've tried it, and it's working swimmingly. Thanks very much, G.G..   Case closed :)
This Space Left Blank Intentionally.

SMF spam blocked by CleanTalk