mirror of
https://github.com/creyD/ludum_dare_46.git
synced 2026-06-12 13:32:23 +02:00
added barrel drops
This commit is contained in:
@@ -1,6 +1,37 @@
|
||||
extends StaticBody2D
|
||||
|
||||
var GreenDrop = 0.5
|
||||
var BlueDrop = 0.4
|
||||
var RedDrop = 0.2
|
||||
var Heart = 0.2
|
||||
|
||||
func offset_vec():
|
||||
var offset = 20
|
||||
return Vector2((randf()-0.5)*offset, (randf()-0.5)*offset)
|
||||
|
||||
func _on_Hurtbox_area_entered(area):
|
||||
queue_free()
|
||||
var GreenRubies = load("res://Objects/Rubies/Green.tscn")
|
||||
var BlueRubies = load("res://Objects/Rubies/Blue.tscn")
|
||||
var RedRubies = load("res://Objects/Rubies/Red.tscn")
|
||||
var Hearts = load("res://Objects/Heart/Heart.tscn")
|
||||
|
||||
#index of ysort
|
||||
var world = get_tree().current_scene.get_child(4)
|
||||
if(randf()<GreenDrop):
|
||||
var green = GreenRubies.instance()
|
||||
world.add_child(green)
|
||||
green.global_position = global_position+offset_vec()
|
||||
elif(randf()<BlueDrop):
|
||||
var blue = BlueRubies.instance()
|
||||
world.add_child(blue)
|
||||
blue.global_position = global_position+offset_vec()
|
||||
elif(randf()<RedDrop):
|
||||
var red = RedRubies.instance()
|
||||
world.add_child(red)
|
||||
red.global_position = global_position+offset_vec()
|
||||
if(randf()<Heart):
|
||||
var heart = Hearts.instance()
|
||||
world.add_child(heart)
|
||||
heart.global_position = global_position+offset_vec()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user