mirror of https://github.com/profan/ld-39-jam.git
draw missiles in minimap
This commit is contained in:
parent
4ec4375b66
commit
3842379181
|
@ -36,4 +36,6 @@ func _draw():
|
||||||
elif ent.type() == "PowerStation":
|
elif ent.type() == "PowerStation":
|
||||||
draw_rect(Rect2(s_x, s_y, 4, 4), Color(0, 0, 1))
|
draw_rect(Rect2(s_x, s_y, 4, 4), Color(0, 0, 1))
|
||||||
elif ent.type() == "Enemy":
|
elif ent.type() == "Enemy":
|
||||||
draw_rect(Rect2(s_x, s_y, 2, 2), Color(1, 0, 0))
|
draw_rect(Rect2(s_x, s_y, 2, 2), Color(1, 0, 0))
|
||||||
|
elif ent.type() == "Missile":
|
||||||
|
draw_rect(Rect2(s_x, s_y, 2, 2), Color(0, 1, 0))
|
|
@ -6,18 +6,28 @@ var launch_timer = 0
|
||||||
var launch_delay = 5 # 5 seconds
|
var launch_delay = 5 # 5 seconds
|
||||||
var velocity = Vector2(0, 0)
|
var velocity = Vector2(0, 0)
|
||||||
|
|
||||||
|
onready var map = get_tree().get_root().get_node("Game/MinimapControl")
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
set_process(true)
|
set_process(true)
|
||||||
|
|
||||||
func set_velocity(vel):
|
func set_velocity(vel):
|
||||||
velocity = vel
|
velocity = vel
|
||||||
|
|
||||||
|
func launch_missile():
|
||||||
|
|
||||||
|
# create
|
||||||
|
var new_missile = Missile.instance()
|
||||||
|
var missile_pos = get_global_pos()
|
||||||
|
new_missile.set_global_pos(missile_pos)
|
||||||
|
get_tree().get_root().add_child(new_missile)
|
||||||
|
new_missile.set_velocity(velocity)
|
||||||
|
|
||||||
|
# register with minimap
|
||||||
|
map.register_entity(new_missile)
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
launch_timer += delta
|
launch_timer += delta
|
||||||
if launch_timer >= launch_delay:
|
if launch_timer >= launch_delay:
|
||||||
var new_missile = Missile.instance()
|
launch_missile()
|
||||||
var missile_pos = get_global_pos()
|
|
||||||
new_missile.set_global_pos(missile_pos)
|
|
||||||
get_tree().get_root().add_child(new_missile)
|
|
||||||
new_missile.set_velocity(velocity)
|
|
||||||
launch_timer = 0
|
launch_timer = 0
|
Loading…
Reference in New Issue