Time Concept and Realization of Day and Night Projection





In order to simulate the real world, I decided to add the concept of time to the game.
HUD that expresses the passage of time
That is, the seasons of sunrise and sunset change.
Doing so can achieve a lot of interesting gameplay,
For example, adding an activity rule of sunrise and sunset to a group of creatures.
For example, at a certain point in time, some creatures will encounter some creatures and start a desperate battle.
To realize such an ecosystem, you must first realize the concept of time in the game.
First we can set the time period
24 segments are set here to achieve 24 hours
The time period can be 24 hours or 8 hours.
The so-called hour may be 60 minutes or any minute.
In this way, various planetary time zone definitions can be flexibly implemented.
time period data setting
a period of time
The first item is how many minutes
The second and third items are the sun position XY
The fourth item is the darkest and the fifth item is the brightest. Both are factors.
Then we'll make the entity's shadow respond to the current sun position.
Each time zone can be set individually Sun position information
set effect
After synchronizing the time to do time zone switching
In this way we can simulate the time of day performance, dark and bright.
Time lapse set to 60 times preview
The effect is basically satisfactory.
So how is the projection of the flashlight illuminated when it is dark?
As mentioned before (https://www.bilibili.com/read/cv9195764), ordinary projection is achieved by rotating the sprite image silhouette.
But the light projection after dark is very complicated.
First solve the problem of backlight, that is, to illuminate brighter!
Light entity occlusion relationship
Then came the backlit performance.
Judging the position of the light-emitting position with the bottom edge of the entity
Then there is the light occlusion performance inside the building.
Simulate building walls blocking light
Then comes the dynamic representation of light projection.
The position of the illuminant and the entity determines the projection rotation angle
Then there is the mixing effect of multiple light sources
Implementation of multiple light sources
After that, the light and shadow interaction of various entities
Not so perfect to be improved
Light and shadow entity changes
The last is the projection performance of multiple light sources.
This is a bit complicated. For example, there are three light sources illuminating the same entity at different positions.
Then the entity will have three projections.
My implementation method is to draw the current entity sprite silhouette obtained by drawing on the top layer of the screen to draw shadows according to multiple sets of lights.
(Deducting the physical performance area and leaving only the shadow) Finally, it is rendered on the top layer of all images!
Simply put, draw all projections based on the entity in the aperture area and deduct the entity sprite image. The resulting shadow image is drawn on top of the screen.
Performance of multiple light sources
I just went to imitate the performance of the light source. It's not perfect, I will gradually improve it.
Next time we will talk about the realization of entity linkage and the physical performance of application fire.
Test effect of fire spread
fire is dangerous
Please support and follow~
steamMaze
Open world, garbage picking, hunting cooking, train modification
Status | In development |
Author | LampStudio |
Genre | Adventure, Role Playing |
Tags | 2D, Horror, Open World, Pixel Art, Survival Horror |
Leave a comment
Log in with itch.io to leave a comment.