A game created for the Godot Wild Jam #21
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

47 lines
1.3KB

  1. extends Sprite
  2. export var liquid_body_color:Color setget _set_liquid_body_color, _get_liquid_body_color
  3. export var liquid_surface_color:Color setget _set_liquid_surface_color, _get_liquid_surface_color
  4. func _set_liquid_body_color(c):
  5. material.set_shader_param("liquid_color_main", c)
  6. func _get_liquid_body_color():
  7. return material.get_shader_param("liquid_color_main")
  8. func _set_liquid_surface_color(c):
  9. material.set_shader_param("liquid_color_surface", c)
  10. $Splash.process_material.color = c
  11. func _get_liquid_surface_color():
  12. return material.get_shader_param("liquid_color_surface")
  13. func _ready():
  14. material.set_shader_param("sprite_scale", scale)
  15. #$Splash.process_material.color = material.get_shader_param("liquid_color_surface")
  16. if scale.x != 0 and scale.y != 0:
  17. $Splash.scale = Vector2(1/scale.x, 1/scale.y)
  18. set_process(true)
  19. func _process(delta):
  20. pass
  21. func _on_Trigger_body_entered(body):
  22. if scale.x != 0:
  23. var bpos = body.get_global_transform().origin
  24. var spos = get_global_transform().origin
  25. var delta = bpos.x - spos.x
  26. $Splash.position.x = (delta * (1/scale.x))
  27. $Splash.emitting = true
  28. if (body.has_method("set_colors")):
  29. body.set_colors(
  30. material.get_shader_param("liquid_color_main"),
  31. material.get_shader_param("liquid_color_surface")
  32. )