Add stylized sun and moon cycle

This commit is contained in:
Alexander Sellite 2026-08-02 13:23:12 -04:00
parent 58fb3d6605
commit cae120c532
8 changed files with 227 additions and 30 deletions

View file

@ -4,27 +4,41 @@ extends Control
const BUBBLE_COLOR := Color(0.025, 0.13, 0.19, 0.94)
const ICON_COLOR := Color(0.78, 0.91, 0.95)
const SUN_COLOR := Color(0.98, 0.82, 0.34)
const MOON_COLOR := Color(0.78, 0.88, 1.0)
const RAIN_COLOR := Color(0.28, 0.73, 0.82)
var _weather: WorldWeatherService.Weather = WorldWeatherService.Weather.SUNNY
var _is_nighttime: bool = false
func _ready() -> void:
mouse_filter = Control.MOUSE_FILTER_PASS
focus_mode = Control.FOCUS_NONE
custom_minimum_size = Vector2(34.0, 34.0)
tooltip_text = "sunny"
_update_tooltip()
queue_redraw()
func set_weather(weather: WorldWeatherService.Weather) -> void:
if _weather == weather:
_update_tooltip()
return
_weather = weather
tooltip_text = WorldWeatherService.weather_name(_weather)
_update_tooltip()
queue_redraw()
func set_nighttime(is_nighttime: bool) -> void:
if _is_nighttime == is_nighttime:
return
_is_nighttime = is_nighttime
queue_redraw()
func is_nighttime() -> bool:
return _is_nighttime
func get_weather() -> WorldWeatherService.Weather:
return _weather
@ -35,7 +49,10 @@ func _draw() -> void:
draw_circle(center, radius, BUBBLE_COLOR)
match _weather:
WorldWeatherService.Weather.SUNNY:
_draw_sun(center)
if _is_nighttime:
_draw_moon(center)
else:
_draw_sun(center)
WorldWeatherService.Weather.CLOUDY:
_draw_cloud(center + Vector2(0.0, 1.0))
WorldWeatherService.Weather.RAINY:
@ -73,6 +90,19 @@ func _draw_sun(center: Vector2) -> void:
)
func _draw_moon(center: Vector2) -> void:
draw_circle(center, 8.0, MOON_COLOR)
draw_circle(center + Vector2(4.0, -2.0), 7.0, BUBBLE_COLOR)
func _update_tooltip() -> void:
tooltip_text = (
"clear"
if _weather == WorldWeatherService.Weather.SUNNY
else WorldWeatherService.weather_name(_weather)
)
func _draw_cloud(center: Vector2) -> void:
draw_circle(center + Vector2(-5.0, 0.0), 5.0, ICON_COLOR)
draw_circle(center + Vector2(0.0, -3.0), 6.0, ICON_COLOR)