...
 
Commits (4)
......@@ -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"]
......@@ -5,10 +5,10 @@
[ext_resource path="res://Player_inicial/char1.png" type="Texture" id=3]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 7.65549, 5.07303 )
extents = Vector2( 7.15491, 4.97379 )
[sub_resource type="CircleShape2D" id=2]
radius = 116.617
radius = 123.824
[node name="Player" type="KinematicBody2D"]
position = Vector2( 450, 290 )
......@@ -20,27 +20,24 @@ script = ExtResource( 1 )
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-005 )
[node name="char1" type="Sprite" parent="."]
position = Vector2( 0.131989, -0.395813 )
scale = Vector2( 1.25, 1.25 )
texture = ExtResource( 3 )
[node name="Collision_corpo" type="CollisionShape2D" parent="."]
position = Vector2( 0, -3.05176e-05 )
shape = SubResource( 1 )
[node name="Colisão_Bola" type="CollisionShape2D" parent="."]
[node name="Collision_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 )
[node name="Timer" type="Timer" parent="."]
one_shot = true
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
[editable path="bola"]
......@@ -4,6 +4,7 @@ extends KinematicBody2D
const ROTATION_SPEED = 1
const ROTATION_LIMIT = 5
const SPEED_LIMIT = 300
onready var RADIUS = get_node("Collision_bola").shape.radius
#Velocidade do personagem
var speed = 0
......@@ -14,6 +15,7 @@ enum turning {none, right, left}
enum direction {none, up, down}
var state = direction.none
var rotation_state = turning.none
var has_ball = true
#Vida do personagem
const MAX_HEALTH = 100
......@@ -26,25 +28,32 @@ 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())
func _ready():
pass
func _input(event):
#Actions pressed
if event.is_action_pressed("ui_right"):
rotation_state = turning.right
elif event.is_action_pressed("ui_left"):
rotation_state = turning.left
elif event.is_action_pressed("ui_up"):
state = direction.up
elif event.is_action_pressed("ui_down"):
state = direction.down
elif event.is_action_pressed("ui_select"):
elif event.is_action_pressed("ui_select") and has_ball:
has_ball = false
#desabilitando colisão da bola
$"Colisão_Bola".disabled = true
$"Collision_bola".disabled = true
#removendo ligação do player com a bola
#a fim de não possibilitar movimento
#conjunto após lançamento
......@@ -61,7 +70,7 @@ func _input(event):
var direction = Vector2(cos(rotation-1.5), sin(rotation-1.5))
bola.launch_ball(direction)
#ligando o timer
$Timer.start()
$Timer.start()
#Actions released
elif event.is_action_released("ui_right"):
......@@ -113,18 +122,27 @@ func _physics_process(delta):
move_and_slide(move_direction.rotated(rotation))
#Coleção de entulho
func _pegou_entulho(tamanho):
if($bola._entulho_pego(tamanho)):
func _pegou_entulho(tamanho):
if $bola._entulho_pego(tamanho):
bola.set_position(Vector2(0, ball_dist()))
$"Collision_bola".set_position(Vector2(0, ball_dist()))
$"Collision_bola".get_shape().set_radius(bola.get_radius()*10)
return true
func _on_Timer_timeout():
$"Colisão_Bola".disabled = false
$"Collision_bola".disabled = false
var nova_bola = preload("res://bolainicial/bolainicial.tscn")
#preload retorna uma PackedScene
#quando uso instance(), retorno o root
bola = nova_bola.instance()
bola.position = Vector2(0, -50)
bola.set_position(Vector2(0, ball_dist() ))
$"Collision_bola".set_position(Vector2(0, ball_dist()))
$"Collision_bola".get_shape().set_radius(bola.get_radius()*10)
self.add_child(bola)
has_ball = true
#Morte do jogador
func _die():
......@@ -142,4 +160,4 @@ func _toma_dano(valor):
func _cura(valor):
vida = vida + valor
if vida > MAX_HEALTH:
vida = MAX_HEALTH
\ No newline at end of file
vida = MAX_HEALTH
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Player_inicial/Player.tscn" type="PackedScene" id=1]
[ext_resource path="res://Player.tscn" type="PackedScene" id=1]
[ext_resource path="res://Player_inicial/Mapa.tscn" type="PackedScene" id=2]
[ext_resource path="res://coletaveis/Entulho/entulho.tscn" type="PackedScene" id=3]
[node name="Teste" type="Node2D"]
position = Vector2( 480, 270 )
......
extends KinematicBody2D
extends KinematicBody2D
var current_scale = get_scale()
const size = Vector2(0.1,0.1)
const RADIUS = 11
const MAX_SPEED = 200
const MAX_BOUNCES = 3
......@@ -11,6 +12,9 @@ var hits = 0
var speed = 300
var direction
func get_radius():
return RADIUS*get_scale().x/0.1
func launch_ball(dir):
direction = dir.normalized()
launched = true
......@@ -49,7 +53,7 @@ func diminui_bola(item):
current_scale = size
set_scale(current_scale)
return current_scale
#Função que volta a bola para seu tamanho original
......@@ -82,4 +86,4 @@ func _entulho_pego(tamanho):
else:
current_scale += add_scale
set_scale(current_scale)
return true
\ No newline at end of file
return true
......@@ -23,7 +23,7 @@ __meta__ = {
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 1 )
disabled = true
__meta__ = {
"_edit_lock_": true
}
......@@ -4,7 +4,7 @@
[ext_resource path="res://coletaveis/fruit_banana.png" type="Texture" id=2]
[ext_resource path="res://coletaveis/comida.gd" type="Script" id=3]
[node name="COLETAVEL" instance=ExtResource( 1 )]
[node name="COLETAVEL" index="0" instance=ExtResource( 1 )]
[node name="Sprite" parent="CollisionShape2D" index="0"]
texture = ExtResource( 2 )
......
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Player_inicial/Mapa.tscn" type="PackedScene" id=1]
[ext_resource path="res://Player_inicial/Player.tscn" type="PackedScene" id=2]
[ext_resource path="res://Player.tscn" type="PackedScene" id=2]
[ext_resource path="res://coletaveis/Entulho/entulho.tscn" type="PackedScene" id=3]
[node name="Node2D" type="Node2D"]
......@@ -17,4 +17,3 @@ position = Vector2( 691, 183 )
[node name="COLETAVEL2" parent="." instance=ExtResource( 3 )]
position = Vector2( 198, 163 )
......@@ -5,4 +5,4 @@ signal is_collected(quem) #quem coletou
func _on_AREA2d_body_entered(body):
if body.is_in_group("Player"):
emit_signal("is_collected", body)
#queue_free()
\ No newline at end of file
#queue_free()
......@@ -5,4 +5,3 @@
[resource]
background_mode = 2
background_sky = SubResource( 1 )
[gd_scene load_steps=3 format=2]
[ext_resource path="res://mapas/Mapa_Base.tscn" type="PackedScene" id=1]
[ext_resource path="res://Player_inicial/Player.tscn" type="PackedScene" id=2]
[ext_resource path="res://Player.tscn" type="PackedScene" id=2]
[node name="Mapa_Exemplo" instance=ExtResource( 1 )]
[node name="Mapa_Exemplo" index="0" instance=ExtResource( 1 )]
[node name="Paredes" parent="." index="0"]
tile_data = PoolIntArray( 0, 0, 6, 1, 0, 196609, 2, 0, 196609, 3, 0, 196609, 4, 0, 196609, 5, 0, 196609, 6, 0, 196609, 7, 0, 196609, 8, 0, 196609, 9, 0, 196609, 10, 0, 196609, 11, 0, 196609, 12, 0, 196609, 13, 0, 196609, 14, 0, 196609, 15, 0, 196609, 16, 0, 196609, 17, 0, 196609, 18, 0, 196609, 19, 0, 196609, 20, 0, 196609, 21, 0, 196609, 22, 0, 196609, 23, 0, 196609, 24, 0, 196609, 25, 0, 196609, 26, 0, 196609, 27, 0, 196609, 28, 0, 196609, 29, 0, 196609, 30, 0, 196609, 31, 0, 7, 65536, 0, 65541, 65567, 0, 65541, 131072, 0, 65541, 131103, 0, 65541, 196608, 0, 65541, 196611, 0, 6, 196612, 0, 196609, 196613, 0, 196609, 196614, 0, 196609, 196615, 0, 196609, 196616, 0, 196609, 196617, 0, 196609, 196618, 0, 196609, 196619, 0, 196609, 196620, 0, 7, 196628, 0, 6, 196629, 0, 196609, 196630, 0, 196609, 196631, 0, 196609, 196632, 0, 196609, 196633, 0, 196609, 196634, 0, 196609, 196635, 0, 196609, 196636, 0, 7, 196639, 0, 65541, 262144, 0, 65541, 262147, 0, 65541, 262156, 0, 65541, 262164, 0, 65541, 262172, 0, 65541, 262175, 0, 65541, 327680, 0, 65541, 327683, 0, 65541, 327692, 0, 65541, 327700, 0, 65541, 327708, 0, 65541, 327711, 0, 65541, 393216, 0, 65541, 393219, 0, 65541, 393228, 0, 131077, 393236, 0, 131077, 393244, 0, 65541, 393247, 0, 65541, 458752, 0, 65541, 458755, 0, 131077, 458780, 0, 131077, 458783, 0, 65541, 524288, 0, 65541, 524319, 0, 65541, 589824, 0, 65541, 589855, 0, 65541, 655360, 0, 65541, 655391, 0, 65541, 720896, 0, 65541, 720899, 0, 5, 720924, 0, 5, 720927, 0, 65541, 786432, 0, 65541, 786435, 0, 65541, 786444, 0, 5, 786452, 0, 5, 786460, 0, 65541, 786463, 0, 65541, 851968, 0, 65541, 851971, 0, 65541, 851980, 0, 65541, 851988, 0, 65541, 851996, 0, 65541, 851999, 0, 65541, 917504, 0, 65541, 917507, 0, 65541, 917516, 0, 65541, 917524, 0, 65541, 917532, 0, 65541, 917535, 0, 65541, 983040, 0, 65541, 983043, 0, 65542, 983044, 0, 196609, 983045, 0, 196609, 983046, 0, 196609, 983047, 0, 196609, 983048, 0, 196609, 983049, 0, 196609, 983050, 0, 196609, 983051, 0, 196609, 983052, 0, 65543, 983060, 0, 65542, 983061, 0, 196609, 983062, 0, 196609, 983063, 0, 196609, 983064, 0, 196609, 983065, 0, 196609, 983066, 0, 196609, 983067, 0, 196609, 983068, 0, 65543, 983071, 0, 65541, 1048576, 0, 65541, 1048607, 0, 65541, 1114112, 0, 65541, 1114143, 0, 65541, 1179648, 0, 65542, 1179649, 0, 196609, 1179650, 0, 196609, 1179651, 0, 196609, 1179652, 0, 196609, 1179653, 0, 196609, 1179654, 0, 196609, 1179655, 0, 196609, 1179656, 0, 196609, 1179657, 0, 196609, 1179658, 0, 196609, 1179659, 0, 196609, 1179660, 0, 196609, 1179661, 0, 196609, 1179662, 0, 196609, 1179663, 0, 196609, 1179664, 0, 196609, 1179665, 0, 196609, 1179666, 0, 196609, 1179667, 0, 196609, 1179668, 0, 196609, 1179669, 0, 196609, 1179670, 0, 196609, 1179671, 0, 196609, 1179672, 0, 196609, 1179673, 0, 196609, 1179674, 0, 196609, 1179675, 0, 196609, 1179676, 0, 196609, 1179677, 0, 196609, 1179678, 0, 196609, 1179679, 0, 65543 )
......
[gd_scene load_steps=3 format=2]
[ext_resource path="res://mapas/Mapa_Base.tscn" type="PackedScene" id=1]
[ext_resource path="res://Player_inicial/Player.tscn" type="PackedScene" id=2]
[ext_resource path="res://Player.tscn" type="PackedScene" id=2]
[node name="Mapa_Exemplo2" index="0" instance=ExtResource( 1 )]
......