Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: esper on Tue 23/01/2007 19:07:37

Title: Multiple instances? (SOLVED)
Post by: esper on Tue 23/01/2007 19:07:37
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?
Title: Re: Multiple instances?
Post by: GarageGothic on Tue 23/01/2007 19:20:44
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.
Title: Re: Multiple instances?
Post by: esper on Tue 23/01/2007 19:26:15
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?
Title: Re: Multiple instances?
Post by: GarageGothic on Tue 23/01/2007 19:27:46
No, since you're drawing them to the actual sprite which you use as an object, they would be on top of that object.
Title: Re: Multiple instances?
Post by: esper on Tue 23/01/2007 19:32:54
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...
Title: Re: Multiple instances?
Post by: GarageGothic on Tue 23/01/2007 20:11:39
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.
Title: Re: Multiple instances?
Post by: esper on Tue 23/01/2007 22:11:32
All right, I'm back, I've tried it, and it's working swimmingly. Thanks very much, G.G..   Case closed :)