A game created for the Godot Wild Jam #21
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.3KB

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