I had an idea for a flashlight script, and I was wondering if I could get any pointers. I haven't scripted anything down yet, but the general idea I had is that the topmost layer on the map would be covered in "dark tiles" (pure black tiles). The player uses a flashlight, which generates a cone of light in the direction he's facing. To get this effect, I would have a script that edits the top layer to place transparent tiles in the direction the player is facing to create the cone of light, dark tiles everywhere else, and transitional tiles in between. Each time the player changes direction or takes a step, the top layer would be edited to keep up with him.
That was what I had in mind, at least. However, since I would just be editing tiles on the top layer, the cone of light would be following the player in a very clunky manner (i.e. the cone of light would jump 20 pixels in the direction the player was moving in one step while the player would move at a smooth pace). I was wondering if anyone knew of a possible way to make the cone of light move in a more smooth manner? If not, this is just my first idea anyway, and I'm open to any ideas anyone has.
Instead of using the tile layer, use slices.
If you don't want wall collision detection you could use something as simple as a backdrop (or 4 backdrops for each direction of the cone) that sits on top of the screen with black edges for the unseen area and transparency for where the light is.
If you DO want wall collision detection you could use a grid of walkabout sprites (or any other size of sprite- the bigger it is the less resource hogging this will be) with lit (transparent/dithered) and unlit (pure black) frames and set them as necessary. Much like the first method you just have them sit on top of the screen like normal GUI elements.
If you don't know how slices work well...I'll let someone else scrounge up a tutorial. But just messing with the slice editor and looking up the related hamsterspeak commands is a start.
If you don't want wall collision detection you could use something as simple as a backdrop (or 4 backdrops for each direction of the cone) that sits on top of the screen with black edges for the unseen area and transparency for where the light is.
If you DO want wall collision detection you could use a grid of walkabout sprites (or any other size of sprite- the bigger it is the less resource hogging this will be) with lit (transparent/dithered) and unlit (pure black) frames and set them as necessary. Much like the first method you just have them sit on top of the screen like normal GUI elements.
If you don't know how slices work well...I'll let someone else scrounge up a tutorial. But just messing with the slice editor and looking up the related hamsterspeak commands is a start.
SDHawk's method will work nicely. I suggest making your black flashlight mask out of one or more large enemy graphics, and then filling the space all around the sides of them with large black rectangle slices. This should be pretty easy to make in the slice collection editor.
Also, Valigarmander, have you played Ortega Colonies? It uses the tile layer method you were originally thinking of, and even though it is blocky, it actually looks and plays pretty nicely.
Also, Valigarmander, have you played Ortega Colonies? It uses the tile layer method you were originally thinking of, and even though it is blocky, it actually looks and plays pretty nicely.
Valigarmander wrote:
I'm kind of getting the hang of slices, but is it possible to remove/free an entire slice collection that you've loaded with the "load slice collection" command? Or do I have to load slices in a different way to be able to remove them?
when you free a slice, you free all of its children too. So yes, when you free a slice collection, the whole collection is freed (unless you reparented some of the child slices out of the collection using the "set parent" command)
There's little point to using a patchwork of multiple slices instead of a single backdrop slice covering the whole screen.
This wiki page: How can I draw a circle of light around the hero? is about using slices for this effect, especially in the tricky case that the map mode is set to 'Crop'.
If you want to try the tiles method, there's an article with scripts by Callahat in HamsterSpeak 24
This wiki page: How can I draw a circle of light around the hero? is about using slices for this effect, especially in the tricky case that the map mode is set to 'Crop'.
If you want to try the tiles method, there's an article with scripts by Callahat in HamsterSpeak 24



