Log In  

Cart #torchlit_view-3 | 2022-02-11 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
10

TO LOAD THIS CART in immediate mode, type load #torchlit_view

As shadows and circular shadows are still rather popular at the moment, back in the day when I was coding in GFA I was working on a massive project called Scenario 2 RPGMaker. If you're curious, Scenario 1 was written in QBasic 1.0 while S2 was in GFA. I wanted to have all the interesting elements that you could find in RPG 95 at the time. One of which was a torchlit view.

The early Torchlit view I had in S1 was quite primitive based on early Ultima 3 where the screen was 9x9 tiles and all it did was draw a rough circle in 5x5 tiles to the center keeping the others black.

So with S2 and the knowledge I was not limited to tile movement alone, I gave it some more thought fully knowing drawing circles are super-slow, but rectangles were not. So the idea was to fill the screen with a solid color, then draw a filled rectangle to match the edges of the solid base for the circle I would create inside.

While this effect can be done many different ways, to me this was the easiest. And what I did was to record this 'torchlit' mask image to a different _dc() or display channel for maximum speed. Then I could use AND to plot it where black was not drawn and white was drawn as black.

This is very similar to what I am doing here and because it is not just a series of circles that fill and extend beyond the entire screen but two intelligent rectangles drawn to first fill the screen and the 2nd to match the edges of the beginning edges of the completely transparent circle in the center.

It should also not use too much CPU for you.

If desired I could make this a single function for custom use.

. . .

? ? ?

I am just now thinking there is a helluva better way to do this and should be <1% CPU. Tomorrow I'll post my findings on that.

Well ... after coding it, it was a bit faster, clearly not less than 1%, but it doesn't have that kind of interesting lingering pattern effect. Here, compare for yourself.

Cart #torchlit_view_mark_2-0 | 2022-02-11 | Code ▽ | Embed ▽ | No License
10

I definitely like the first one better despite it using more CPU.

And yes, this can be helpful. We can always learn from our mistakes. That is encouragement for all of you, never ever delete any code you write. Always try to save absolutely everything you write. While 95% of the old code you wrote you feel you may not need at the time, there is that 5% you'll be glad when you do.

However this is an interesting area to experiment in, Torchlit View. If I find something better and faster, I'll let you know.

P#106686 2022-02-11 04:34 ( Edited 2022-02-11 21:11)


[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-18 23:20:09 | 0.020s | Q:14