...
 
Commits (17)
[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.15491, 4.97379 )
[sub_resource type="CircleShape2D" id=2]
radius = 123.824
[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_margin = 0.0
[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="Collision_bola" type="CollisionShape2D" parent="."]
position = Vector2( 0.429199, -18.0681 )
scale = Vector2( 0.1, 0.1 )
shape = SubResource( 2 )
[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
......@@ -23,6 +25,12 @@ signal died
#Atributos
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()
......@@ -38,13 +46,39 @@ 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") and has_ball:
has_ball = false
#desabilitando colisão da bola
$"Collision_bola".disabled = true
#removendo ligação do player com a bola
#a fim de não possibilitar movimento
#conjunto após lançamento
var pai = self.get_parent()
var ball_pos = bola.global_position
self.remove_child(bola)
bola.position = ball_pos
pai.add_child(bola)
#chamando função de lançamento da bola
#e transformando ângulo em vetor
# "1.5" é necessário pois embora comece
#de um ângulo 0, o player não inicia virado
#para a direita, mas para cima
var direction = Vector2(cos(rotation-1.5), sin(rotation-1.5))
bola.launch_ball(direction)
#ligando o timer
$Timer.start()
#Actions released
elif event.is_action_released("ui_right"):
rotation_state = turning.none
......@@ -55,6 +89,7 @@ func _input(event):
elif event.is_action_released("ui_down"):
state = direction.none
#warning-ignore:unused_argument
func _process(delta):
#Lida com os estados
if rotation_state == turning.right:
......@@ -90,13 +125,31 @@ func _physics_process(delta):
move_direction.y = speed
#Movimenta o personagem
#warning-ignore:return_value_discarded
move_and_slide(move_direction.rotated(rotation))
#Coleção de entulho
func _pegou_entulho(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():
$"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.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():
emit_signal("died")
......@@ -109,8 +162,8 @@ func _toma_dano(valor):
vida = 0
_die()
else:
timer.start()
timer.start()
#Cura
func _cura(valor):
vida = vida + valor
......
[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 )
......
......@@ -3,16 +3,24 @@ 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
var launched = false
var hits = 0
var speed = 300
var direction = Vector2(0,-1)
var direction
func _physics_process(delta):
func get_radius():
return RADIUS*get_scale().x/0.1
func launch_ball(dir):
direction = dir.normalized()
launched = true
$CollisionShape2D.disabled = false
func _physics_process(delta):
if(launched == true):
var velocity = direction * speed
var collision = move_and_collide(velocity * delta)
......@@ -45,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
......@@ -79,5 +87,3 @@ func _entulho_pego(tamanho):
current_scale += add_scale
set_scale(current_scale)
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()
[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" index="0" instance=ExtResource( 1 )]
......@@ -10,3 +11,4 @@ tile_data = PoolIntArray( 0, 0, 6, 1, 0, 196609, 2, 0, 196609, 3, 0, 196609, 4,
[node name="Node2D" parent="Players" index="0" instance=ExtResource( 2 )]
position = Vector2( 250, 320 )
[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" instance=ExtResource( 1 )]
[node name="Mapa_Exemplo2" 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, 196620, 0, 6, 196621, 0, 196609, 196622, 0, 196609, 196623, 0, 196610, 196625, 0, 196608, 196626, 0, 196609, 196627, 0, 196609, 196628, 0, 7, 196639, 0, 65541, 262144, 0, 65541, 262156, 0, 65541, 262164, 0, 65541, 262175, 0, 65541, 327680, 0, 65541, 327692, 0, 65541, 327700, 0, 65541, 327711, 0, 65541, 393216, 0, 65541, 393228, 0, 65541, 393236, 0, 65541, 393247, 0, 65541, 458752, 0, 65541, 458764, 0, 65541, 458772, 0, 65541, 458783, 0, 65541, 524288, 0, 65541, 524300, 0, 131077, 524308, 0, 131077, 524319, 0, 65541, 589824, 0, 65541, 589855, 0, 65541, 655360, 0, 65541, 655372, 0, 5, 655380, 0, 5, 655391, 0, 65541, 720896, 0, 65541, 720908, 0, 65541, 720916, 0, 65541, 720927, 0, 65541, 786432, 0, 65541, 786444, 0, 65541, 786452, 0, 65541, 786463, 0, 65541, 851968, 0, 65541, 851980, 0, 65541, 851988, 0, 65541, 851999, 0, 65541, 917504, 0, 65541, 917516, 0, 65541, 917524, 0, 65541, 917535, 0, 65541, 983040, 0, 65541, 983052, 0, 65542, 983053, 0, 196609, 983054, 0, 196609, 983055, 0, 196610, 983057, 0, 196608, 983058, 0, 196609, 983059, 0, 196609, 983060, 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 )
[node name="Node2D" parent="Players" index="0" instance=ExtResource( 2 )]
position = Vector2( 250, 320 )