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.

46 lines
1.1KB

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