...
 
Commits (7)
extends Node2D
# Carrega Player_inicial
const PLAYER = preload("res://Player_inicial/Player.tscn")
const MAX_PLAYER = 4
var player_pos
var player_rot
# Contadores
var numPlayer = 0
var dead = 0
func _ready():
randomize()
func _create_player():
var vector = Vector2(rand_range(50, 961), rand_range(50, 571))
var GrabbedInstance = PLAYER.instance()
player_pos = get_child(numPlayer).position
player_rot = get_child(numPlayer).get_rotation()
GrabbedInstance.position = player_pos
GrabbedInstance.set_rotation(player_rot)
add_child(GrabbedInstance)
numPlayer += 1
print("PLAYER CREATED")
# Recebe o sinal "dead"
GrabbedInstance.connect("died", self, "_is_over")
func _input(event):
if event.is_action_pressed("new_player") and numPlayer < MAX_PLAYER:
_create_player()
func _is_over():
dead += 1
print("DEAD")
if dead == numPlayer - 1:
print("GAME OVER")
get_tree().paused = true
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Admin/Admin.gd" type="Script" id=1]
[node name="Admin" type="Node2D"]
script = ExtResource( 1 )
[node name="Node2D" type="Node2D" parent="."]
position = Vector2( 35, 35 )
rotation = 2.35619
[node name="Node2D2" type="Node2D" parent="."]
position = Vector2( 990, 35 )
rotation = -2.35619
[node name="Node2D3" type="Node2D" parent="."]
position = Vector2( 35, 570 )
rotation = 0.785398
[node name="Node2D4" type="Node2D" parent="."]
position = Vector2( 990, 570 )
rotation = -0.785398
......@@ -27,13 +27,20 @@ var move_direction = Vector2(0, 0)
#Bola instanciada no personagem
onready var bola = $bola
#Função auxiliar para pegar a distancia da bola
func ball_dist():
return -(8*(bola.scale.x+1)+bola.get_radius())
#Sinal e timer
signal dead
var timer = Timer.new()
func _ready():
pass
timer = Timer.new()
timer.wait_time = 1
add_child(timer)
timer.connect("timeout", self, "_toma_dano", [10])
timer.start()
func _input(event):
#Actions pressed
......@@ -123,7 +130,6 @@ func _physics_process(delta):
#Coleção de entulho
func _pegou_entulho(tamanho):
if $bola._entulho_pego(tamanho):
bola.set_position(Vector2(0, ball_dist()))
$"Collision_bola".set_position(Vector2(0, ball_dist()))
......@@ -146,16 +152,18 @@ func _on_Timer_timeout():
#Morte do jogador
func _die():
print("Morri")
emit_signal("died", self)
emit_signal("died")
queue_free()
#Dano
func _toma_dano(valor):
vida = vida - valor
vida -= valor
if vida <= 0:
vida = 0
_die()
else:
timer.start()
#Cura
func _cura(valor):
vida = vida + valor
......
[gd_scene load_steps=6 format=2]
[ext_resource path="res://Player_inicial/Player.gd" type="Script" id=1]
[ext_resource path="res://bolainicial/bolainicial.tscn" type="PackedScene" id=2]
[ext_resource path="res://Player_inicial/char1.png" type="Texture" id=3]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 7.65549, 5.07303 )
[sub_resource type="CircleShape2D" id=2]
radius = 116.617
[node name="Player" type="KinematicBody2D"]
position = Vector2( 450, 290 )
collision_layer = 8
collision_mask = 7
script = ExtResource( 1 )
[node name="bola" parent="." instance=ExtResource( 2 )]
position = Vector2( 0.429199, -18.0681 )
[node name="CollisionShape2D" parent="bola" index="1"]
one_way_collision = true
one_way_collision_margin = 0.0
[node name="Colisão_Corpo" type="CollisionShape2D" parent="."]
position = Vector2( 0, -3.05176e-05 )
shape = SubResource( 1 )
[node name="Colisão_Bola" type="CollisionShape2D" parent="."]
position = Vector2( 0.429199, -18.0681 )
scale = Vector2( 0.1, 0.1 )
shape = SubResource( 2 )
disabled = true
[node name="char1" type="Sprite" parent="."]
position = Vector2( 0.131966, -0.395817 )
scale = Vector2( 1.25, 1.25 )
texture = ExtResource( 3 )
[editable path="bola"]
......@@ -53,6 +53,11 @@ ui_down={
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
]
}
new_player={
"deadzone": 0.5,
"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)
]
}
[layer_names]
......