Log In  
Log In  

Cart [#54379#] | Code | 2018-07-24 | License: CC4-BY-NC-SA | Embed

Hi ^^

I was stunned by the light effects of Dank Tomb but I wasn't able to understand how it works. (Before I've seen the hackernoon site).

Here is an attempt to run something similar on jelpi, but with another logic. The pro is that it could run with several sources of light at the same time, the cons is that it is way less efficient and it uses most of the SFX memory.
Maybe some basic games could still run it at 30fps, and maybe we could improve it a little.

The first step is done once at the beginning: we create a hashmap for the 16 possible colors and a level of light (between 0 and 4), the level 0 gives the normal color and higher level gives darker colors.
As a peek in the memory gives 2 pixels at once. I've made a hashmap for the 1616 possible colors and the 44 levels of lights.

Then in the _draw function, I paint the light sources, I first paint the screen to the color 4, the darkest level, so all is in the complete dark. Then I draw some concentric circles with colors 3, 2, 1 and 0 at the position of the player.

Once it's done, I copy all the screen memory to the adress 0x3E00, it uses a big part of the SFX memory and all the user memory.

Finally, I do the normal drawing of Jelpi and as a post process I peek every pixel of the screen and the light level and poke it with the colors taken for the hashmap.
It gives what you could see in the screenshot.

I don't know if we could improve it more ? Maybe by restricting the loop on the pixel on a smaller area and painting the rest in black ?

P#54380 2018-07-24 09:50 ( Edited 2018-08-08 02:33)

:: dw817

This is really awesome, Mimick. I can see a Haunted House game, like for the Atari 2600 where something like this could be used to only light a short distance around the player.

After all, it's what you DON'T see that scares you. 🎃

https://youtu.be/lbjVffUGjxA?t=19

You were asking about a way to improve this without using up all of tile memory ?

Draw the filled circle in PICO, then transfer it to tiles, maybe no more than 7x7 area, and you have all the other tile space for your game.

P#54842 2018-08-07 22:33 ( Edited 2018-08-08 02:33)

[Please log in to post a comment]

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-05-22 08:12 | 0.027s | 4194k | Q:22