adm melhorado

parent eb788294
......@@ -8,18 +8,21 @@ const MAX_PLAYER = 4
var numPlayer = 0
var dead = 0
func _create_player():
func _ready():
randomize()
func _create_player():
var vector = Vector2(rand_range(50, 961), rand_range(50, 571))
var GrabbedInstance = PLAYER.instance()
GrabbedInstance.position = vector
add_child(GrabbedInstance)
numPlayer += 1
GrabbedInstance._toma_dano(1)
print("PLAYER CREATED")
# Recebe o sinal "dead"
GrabbedInstance.connect("dead", self, "_is_over")
GrabbedInstance.connect("died", self, "_is_over")
func _input(event):
if event.is_action_pressed("new_player") and numPlayer < 4:
......@@ -31,4 +34,4 @@ func _is_over():
if dead == numPlayer - 1:
print("GAME OVER")
get_tree().paused = true
\ No newline at end of file
......@@ -2,7 +2,5 @@
[ext_resource path="res://Admin/Admin.gd" type="Script" id=1]
[node name="Admin" type="Node2D"]
script = ExtResource( 1 )
......@@ -4,4 +4,4 @@ func _on_Start_game_pressed():
get_tree().change_scene("res://Menus/Selecao_Mapas/Selecao_Mapas.tscn")
func _on_Exit_pressed():
get_tree().quit()
\ No newline at end of file
get_tree().quit()
......@@ -52,6 +52,5 @@ margin_top = 35.0
margin_right = 150.0
margin_bottom = 69.0
texture_normal = ExtResource( 4 )
[connection signal="pressed" from="MarginContainer/VBoxContainer/VBoxContainer/Start_game" to="." method="_on_Start_game_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/VBoxContainer/Exit" to="." method="_on_Exit_pressed"]
......@@ -15,6 +15,11 @@ enum direction {none, up, down}
var state = direction.none
var rotation_state = turning.none
#Vida do personagem
const MAX_HEALTH = 100
var vida = 100
signal died
#Atributos
var move_direction = Vector2(0, 0)
......@@ -24,15 +29,11 @@ var timer = Timer.new()
func _ready():
timer = Timer.new()
timer.wait_time = 2
timer.wait_time = 1
add_child(timer)
timer.connect("timeout", self, "_dead_player")
timer.connect("timeout", self, "_toma_dano", [10])
timer.start()
func _dead_player():
timer.stop()
emit_signal("dead")
func _input(event):
#Actions pressed
if event.is_action_pressed("ui_right"):
......@@ -94,4 +95,24 @@ func _physics_process(delta):
#Coleção de entulho
func _pegou_entulho(tamanho):
if $bola._entulho_pego(tamanho):
return true
\ No newline at end of file
return true
#Morte do jogador
func _die():
emit_signal("died")
queue_free()
#Dano
func _toma_dano(valor):
vida -= valor
if vida <= 0:
vida = 0
_die()
else:
timer.start()
#Cura
func _cura(valor):
vida = vida + valor
if vida > MAX_HEALTH:
vida = MAX_HEALTH
......@@ -24,7 +24,7 @@ one_way_collision = true
one_way_collision_margin = 0.0
[node name="Colisão_Corpo" type="CollisionShape2D" parent="."]
position = Vector2( 0, -3.05176e-005 )
position = Vector2( 0, -3.05176e-05 )
shape = SubResource( 1 )
[node name="Colisão_Bola" type="CollisionShape2D" parent="."]
......@@ -38,5 +38,4 @@ position = Vector2( 0.131966, -0.395817 )
scale = Vector2( 1.25, 1.25 )
texture = ExtResource( 3 )
[editable path="bola"]
......@@ -5,4 +5,3 @@
[resource]
background_mode = 2
background_sky = SubResource( 1 )
......@@ -55,7 +55,7 @@ ui_down={
}
new_player={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":true,"control":false,"meta":false,"command":false,"pressed":false,"scancode":61,"unicode":0,"echo":false,"script":null)
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":true,"meta":false,"command":true,"pressed":false,"scancode":89,"unicode":0,"echo":false,"script":null)
]
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment