• Stars
    star
    329
  • Rank 128,030 (Top 3 %)
  • Language GDScript
  • License
    MIT License
  • Created almost 6 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A 2D β˜€οΈ Day / πŸŒ” Night cycle using CanvasModulate and a moon light effect using Light2D.

Godot 3 2D Day/Night Cycle

Godot v3.x GitHub release (latest by date) GitHub license

A 2D β˜€οΈ Day / πŸŒ” Night cycle using CanvasModulate and a moon light effect using Light2D.

Godot 3 2D Day/Night Cycle Banner

Examples

Cycle without the moon light

Cycle without the moon light.

Cycle with the moon light static

Cycle with the moon light static.

Cycle with the moon light moving

Cycle with the moon light moving.

πŸ•ΉοΈ Demo

  • Clone the repository or download it in a ZIP file.
  • Open day_night_cycle/project.godot.
  • Play around πŸ™‚.

πŸ“‘ Documentation

πŸ› οΈ Setup

  • Clone the repository or download it in a ZIP file.
  • Copy the following files and folders to your project:
    • time.gd file (day_night_cycle/src/singletons/time.gd).
    • day_night_cycle folder (day_night_cycle/src/day_night_cycle).
    • moon_light folder (day_night_cycle/src/moon_light).
    • debug_overlay folder (day_night_cycle/src/debug_overlay).

πŸš€ Usage

Prerequisites

Add the Time singleton:

  • Go to Project -> Project Settings.
  • Go to the AutoLoad tab.
  • Add the time.gd file.
  • Enable it.

Enable the time.gd singleton

Change the Time parameters to your liking.

Add a simple cycle

Instance the DayNightCycle node in the root scene.

Node
β”œβ”€β”€ TileMap
β”œβ”€β”€ Player
β”œβ”€β”€ OtherStuff
└── DayNightCycle

Change the DayNightCycle parameters to your liking.

Add a cycle with a moon light

Instance the DayNightCycle node and the MoonLight node in the root scene.

Node
β”œβ”€β”€ TileMap
β”œβ”€β”€ Player
β”œβ”€β”€ OtherStuff
β”œβ”€β”€ DayNightCycle
└── MoonLight

Sync the MoonLight with the DayNightCycle.

The MoonLight can be static or moving in sync with a DayNightCycle.

Change the DayNightCycle parameters and the MoonLight parameters to your liking.

Add a delay between cycles

  • Create a CanvasLayer for the background and set its layer to -1.
  • Instance the DayNightCycle node in the background CanvasLayer previously created.
  • Instance another DayNightCycle node in the root scene and add a delay.
  • Instance the MoonLight in the root scene and sync it to the DayNightCycle node with a delay.

Something like this:

Node
β”œβ”€β”€ CanvasLayer (layer = -1)
β”‚   └── BackgroundSprite
β”‚   └── DayNightCycleBackground (delay = 0)
β”œβ”€β”€ TileMap
β”œβ”€β”€ Player
β”œβ”€β”€ OtherStuff
└── DayNightCycleForeground (delay = 1800)
└── MoonLight (cycle_sync_node_path = DayNightCycleForeground)

This will create the effect that the background starts changing before the foreground.

Add a debug overlay

Test the passing of time, the cycles and the moon light.

Debugg overlay example

  • Create a CanvasLayer and set its layer to 1.
  • Instance the DebugOverlay node.

Something like this:

Node
β”œβ”€β”€ TileMap
β”œβ”€β”€ Player
β”œβ”€β”€ OtherStuff
β”œβ”€β”€ DayNightCycle
β”œβ”€β”€ MoonLight
└── CanvasLayer (layer = 1)
    └── DebugOverlay

πŸ—’οΈ Changelog

See CHANGELOG.

πŸ‘€ Author

  • hiulit

🀝 Contributing

Feel free to:

πŸ™Œ Supporting this project

If you find this project helpful, please consider supporting it through any size donations to help make it better.

Become a patron

Suppor me on Ko-Fi

Buy me a coffee

Donate Paypal

If you can't, consider sharing it with the world...

... or giving it a star.

πŸ‘ Credits

Thanks to:

πŸ“ Licenses

More Repositories

1

Godot-3-2D-Destructible-Objects

A script that takes a sprite, divides it into blocks and makes them explode πŸ’₯!
GDScript
393
star
2

Godot-3-2D-CRT-Shader

A 2D shader for Godot 3 simulating a CRT
GLSL
299
star
3

Unofficial-Godot-Engine-Raspberry-Pi

Unofficial Godot Engine binaries for the Raspberry Pi.
281
star
4

Sassy-Gridlover

Super easy to use Sass mixins to establish a typographic system with modular scale and vertical rhythm. Based on the Gridlover app.
HTML
221
star
5

RetroPie-Godot-Engine-Emulator

A scriptmodule to install a Godot "emulator" for RetroPie.
Shell
91
star
6

Delaunator-GDScript

A GDScript port of Delaunator: A fast library for Delaunay triangulation of 2D points.
GDScript
80
star
7

GDScriptify

A magical documentation tool for GDScript.
JavaScript
48
star
8

Godot-Plugin-Particles-Renderer

A Godot plugin to render particles into a sprite sheet
GDScript
40
star
9

itchio-godot-scraper

A scraper for Godot games hosted on https://itch.io.
JavaScript
28
star
10

cross-compile-godot-raspberry-pi

A script to easily cross-compile Godot binaries for the Raspberry Pi from Linux x86_64 and an extra script to easily transfer the compiled Godot binaries to the Raspberry Pi using rsync
Shell
28
star
11

aseprite-to-godot-variables

A Lua script to create arrays of colors and indexes of those colors from an Aseprite sprite to be used in Godot.
Lua
23
star
12

Lospec-Palette-List

Browse through thousands of awesome Lospec palettes
GDScript
22
star
13

Murtop-Raspberry-Pi-Bartop-Arcade-Machine-Project

Personal project to create an actual playable Bartop Arcade Machine from scratch using a Raspberry Pi with RetroPie and lots of wood, paint and wires :)
20
star
14

Godot-3-2D-Fake-Explosion-Particles

A script to simulate exploding particles.
GDScript
18
star
15

Godot-3-2D-Fake-Snow-Particles

A script to simulate snow particles ❄️
GDScript
18
star
16

Godot-3-2D-Fake-Confetti-Particles

A script to simulate confetti particles πŸŽ‰
GDScript
14
star
17

RetroPie-Itchio-Godot-Scraper

A tool for RetroPie to scrape Godot games hosted on https://itch.io.
Shell
12
star
18

RetroPie-Convert-Videos

A tool for RetroPie to convert videos.
Shell
12
star
19

ppa

A PPA repository for my packages (Godot)
Shell
8
star
20

Godot-3-2D-Draw-Sprite

A script to create "sprites" using the _draw() function to easily create patterns, change the color palette, or change the pixel size.
GDScript
8
star
21

es-pixel-theme-extras

Script for RetroPie to install some extras for the EmulationStation's Pixel theme (Retropie menu icons, boot splashscreen and launching images)
Shell
5
star
22

RetroPie-Shell-Script-Boilerplate

A template for building shell scripts for RetroPie.
Shell
4
star
23

RetroPie-Fun-Facts-Splashscreens

A tool for RetroPie to generate splashscreens with random video game related Fun Facts!.
Shell
4
star
24

Godot-2D-Platformer-Test

GDScript
2
star
25

RetroPie-Limit-Last-Played-Games

A tool for RetroPie to limit the number of 'last played' games.
Shell
2
star
26

es-theme-extras

Script for RetroPie to install some extras for EmulationStation themes (icons, splashscreens and launching images)
Shell
1
star
27

Stylus-Mixins

A set of Stylus mixins
CSS
1
star
28

barcelona-bicycle-anchor-points

Find public bicycle anchor points near you in Barcelona!
JavaScript
1
star
29

RetroPie-Extras

A collection of my own scripts for RetroPie
1
star
30

lospec-api

An API for the Lospec Palette List
JavaScript
1
star
31

RetroPie-Murtop

A script to install Murtop on Retropie
Shell
1
star