This commit is contained in:
dariasteam 2017-07-29 19:27:00 +01:00
parent adfb2947ac
commit 39fdcc9bf9
33 changed files with 113 additions and 75 deletions

View file

@ -38,8 +38,6 @@ func _ready():
yield(t, "timeout")
set_fixed_process(true)
func _on_RigidBody2D_body_enter( body ):
if (body.is_in_group("enemy")):
body.decrease_life(1)

View file

@ -11,6 +11,8 @@ var v = Vector2(-velocity, 0)
onready var sprite = get_node("Sprite")
onready var area_head = get_node("area_head")
onready var hit_single = get_node("hit_ray_particle")
export(bool) var dir_left = true;
export(int) var life = 2
@ -27,28 +29,34 @@ func _ready():
reverse_direction()
set_fixed_process(true)
func die_by_jump():
life = 0
set_shape_as_trigger(0, true)
get_node("Sprite").set_opacity(0)
Input.action_press("ui_jump")
Input.action_release("ui_jump")
func dissapear():
sprite.set_opacity(0)
set_fixed_process(false)
set_layer_mask_bit(2,false)
var t = Timer.new()
t.set_wait_time(0.2)
t.set_wait_time(hit_single.get_lifetime())
t.set_one_shot(true)
self.add_child(t)
t.start()
yield(t, "timeout")
queue_free()
func die_by_jump():
life = 0
dissapear()
func die():
queue_free()
dissapear()
func decrease_life (value):
life -= value
if (life <= 0):
die()
hit_single.set_emitting(false)
hit_single.set_emitting(true)
if (life > 0):
life -= value
if (life <= 0):
die()
func _fixed_process(delta):
var motion = v * delta
@ -72,11 +80,10 @@ func _fixed_process(delta):
func _on_area_body_body_enter( body ):
if (body.is_in_group("player") and life > 0 and body.can_receive_damage()):
emit_signal("damage", damage)
print ("muerte")
func _on_area_head_body_enter( body ):
if (body.is_in_group("player") and body.can_receive_damage()):
if (body.foots.get_global_pos().y > area_head.get_global_pos().y):
if (body.foots.get_global_pos().y > area_head.get_global_pos().y and body.is_falling()):
print ("cabeza")
life = 0
die_by_jump()

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=20 format=1]
[gd_scene load_steps=21 format=1]
[ext_resource path="res://enemy_1.gd" type="Script" id=1]
[ext_resource path="res://malvado_caminando0000.tex" type="Texture" id=2]
@ -11,18 +11,19 @@
[ext_resource path="res://malvado_caminando0007.tex" type="Texture" id=9]
[ext_resource path="res://malvado_caminando0008.tex" type="Texture" id=10]
[ext_resource path="res://malvado_caminando0009.tex" type="Texture" id=11]
[ext_resource path="res://sangre.png" type="Texture" id=12]
[sub_resource type="ConvexPolygonShape2D" id=1]
[sub_resource type="ConvexPolygonShape2D" id=9]
custom_solver_bias = 0.0
points = Vector2Array( 8.90625, -8.09232, 8.57639, -19.4815, 26.3889, -19.4815, 26.7188, 8.39203 )
[sub_resource type="ConvexPolygonShape2D" id=2]
[sub_resource type="ConvexPolygonShape2D" id=10]
custom_solver_bias = 0.0
points = Vector2Array( 2.63889, -0.899147, 8.90625, -8.09232, 26.7188, 8.39203, 20.1215, 15.8849, 5.27778, 15.5852, 0.989584, 8.09231 )
[sub_resource type="ConvexPolygonShape2D" id=3]
[sub_resource type="ConvexPolygonShape2D" id=11]
custom_solver_bias = 0.0
points = Vector2Array( -3.29861, -5.99431, 2.63889, -0.899147, 0.989584, 8.09231, -7.91667, 2.09801, -8.24653, -3.59659 )
@ -32,17 +33,17 @@ points = Vector2Array( -3.29861, -5.99431, 2.63889, -0.899147, 0.989584, 8.09231
custom_solver_bias = 0.0
extents = Vector2( 13.0125, 38.3532 )
[sub_resource type="ConvexPolygonShape2D" id=5]
[sub_resource type="ConvexPolygonShape2D" id=12]
custom_solver_bias = 0.0
points = Vector2Array( 8.90625, -8.09232, 8.57639, -19.4815, 26.3889, -19.4815, 26.7188, 8.39203 )
[sub_resource type="ConvexPolygonShape2D" id=6]
[sub_resource type="ConvexPolygonShape2D" id=13]
custom_solver_bias = 0.0
points = Vector2Array( 2.63889, -0.899147, 8.90625, -8.09232, 26.7188, 8.39203, 20.1215, 15.8849, 5.27778, 15.5852, 0.989584, 8.09231 )
[sub_resource type="ConvexPolygonShape2D" id=7]
[sub_resource type="ConvexPolygonShape2D" id=14]
custom_solver_bias = 0.0
points = Vector2Array( -3.29861, -5.99431, 2.63889, -0.899147, 0.989584, 8.09231, -7.91667, 2.09801, -8.24653, -3.59659 )
@ -57,20 +58,20 @@ animations = [ {
} ]
[node name="KinematicBody2D 2" type="KinematicBody2D" groups=[
"enemy",
"enemy_1",
"enemy",
]]
transform/pos = Vector2( 64.3, -80 )
transform/scale = Vector2( 1.79062, 1.8 )
input/pickable = false
shapes/0/shape = SubResource( 1 )
shapes/0/shape = SubResource( 9 )
shapes/0/transform = Matrix32( 1.68421, 0, 0, 1.85361, -19.4444, 6.66667 )
shapes/0/trigger = false
shapes/1/shape = SubResource( 2 )
shapes/1/shape = SubResource( 10 )
shapes/1/transform = Matrix32( 1.68421, 0, 0, 1.85361, -19.4444, 6.66667 )
shapes/1/trigger = false
shapes/2/shape = SubResource( 3 )
shapes/2/shape = SubResource( 11 )
shapes/2/transform = Matrix32( 1.68421, 0, 0, 1.85361, -19.4444, 6.66667 )
shapes/2/trigger = false
collision/layers = 5
@ -120,21 +121,21 @@ _update_shape_index = 0
transform/pos = Vector2( -4.07679, 1.11111 )
transform/scale = Vector2( 0.9363, 1.08512 )
input/pickable = false
shapes/0/shape = SubResource( 5 )
shapes/0/shape = SubResource( 12 )
shapes/0/transform = Matrix32( 1.79879, 0, 0, 1.7082, -16.6219, 4.86533 )
shapes/0/trigger = false
shapes/1/shape = SubResource( 6 )
shapes/0/trigger = true
shapes/1/shape = SubResource( 13 )
shapes/1/transform = Matrix32( 1.79879, 0, 0, 1.7082, -16.6219, 4.86533 )
shapes/1/trigger = false
shapes/2/shape = SubResource( 7 )
shapes/1/trigger = true
shapes/2/shape = SubResource( 14 )
shapes/2/transform = Matrix32( 1.79879, 0, 0, 1.7082, -16.6219, 4.86533 )
shapes/2/trigger = false
shapes/2/trigger = true
gravity_vec = Vector2( 0, 1 )
gravity = 0.0
linear_damp = 0.1
angular_damp = 1.0
monitorable = false
collision/layers = 4
collision/layers = 0
collision/mask = 34
[node name="CollisionPolygon2D3" type="CollisionPolygon2D" parent="area_body"]
@ -144,16 +145,49 @@ transform/scale = Vector2( 1.79879, 1.7082 )
build_mode = 0
polygon = Vector2Array( 8.57639, -19.4815, 8.90625, -8.09232, 2.63889, -0.899147, -3.29861, -5.99431, -8.24653, -3.59659, -7.91667, 2.09801, 0.989584, 8.09231, 5.27778, 15.5852, 20.1215, 15.8849, 26.7188, 8.39203, 26.3889, -19.4815 )
shape_range = Vector2( 0, 2 )
trigger = false
trigger = true
[node name="Sprite" type="AnimatedSprite" parent="."]
transform/pos = Vector2( 3.8147e-06, 0 )
frames = SubResource( 8 )
animation = "walking"
frame = 3
frame = 7
playing = true
[node name="hit_ray_particle" type="Particles2D" parent="."]
transform/pos = Vector2( 7.65098, 1.11111 )
transform/scale = Vector2( 0.296685, 0.329861 )
config/amount = 100
config/lifetime = 1.0
config/emit_timeout = 0.2
config/emitting = false
config/process_mode = 1
config/half_extents = Vector2( 40, 40 )
config/local_space = false
config/explosiveness = 0.5
config/texture = ExtResource( 12 )
params/direction = 180.0
params/spread = 180.0
params/linear_velocity = 150.0
params/spin_velocity = 0.0
params/orbit_velocity = 0.0
params/gravity_direction = 0.0
params/gravity_strength = 400.0
params/radial_accel = 0.0
params/tangential_accel = 0.0
params/damping = 0.0
params/initial_angle = 0.0
params/initial_size = 1.0
params/final_size = 0.0
params/hue_variation = 0.0
params/anim_speed_scale = 1.0
params/anim_initial_pos = 0.0
randomness/direction = 0.29
randomness/spread = 0.8
randomness/linear_velocity = 0.45
[connection signal="body_enter" from="area_head" to="." method="_on_area_head_body_enter"]
[connection signal="body_enter" from="area_body" to="." method="_on_area_body_body_enter"]

View file

@ -1,7 +0,0 @@
[Dolphin]
PreviewsShown=true
Timestamp=2017,7,27,21,57,16
Version=4
[Settings]
HiddenFilesShown=true

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 B

View file

@ -1 +0,0 @@
repeat=true

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 391 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 391 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 391 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 356 B

View file

@ -22,7 +22,6 @@ onready var shooter = get_node("shooter")
onready var sprite = get_node("sprite")
onready var foots = get_node("foots")
var can_jump = true
var jumping = false
var velocity = Vector2()
@ -161,24 +160,27 @@ func _fixed_process(delta):
# Control de colisiones
if (is_colliding()):
var normal = get_collision_normal()
if (normal.y > 0.5 and jumping):
# Está chocandose contra el techo
jumping = false
can_jump = false
jump_time = 0
else:
# Está en el suelo
# Está en el suelo
if (normal.y < -0.25):
can_jump = true
jumping = false
motion = normal.slide(motion)
velocity = normal.slide(velocity)
motion.y = 0
motion = normal.slide(motion)
velocity = normal.slide(velocity)
velocity.y = 0
else:
motion = normal.slide(motion)
velocity = normal.slide(velocity)
move(motion)
else:
else:
can_jump = false
func _ready():

View file

@ -24,7 +24,7 @@
[ext_resource path="res://vaca_walk/vakacaminar0019.png" type="Texture" id=22]
[ext_resource path="res://vaca_walk/vakacaminar0020.png" type="Texture" id=23]
[sub_resource type="ConvexPolygonShape2D" id=1]
[sub_resource type="ConvexPolygonShape2D" id=4]
custom_solver_bias = 0.0
points = Vector2Array( -16.5903, -10.3465, 13.4341, -10.3403, 13.6042, 6.10309, 1.07087, 13.1015, -3.59432, 13.1015, -16.6847, 5.56475 )
@ -52,7 +52,7 @@ animations = [ {
transform/scale = Vector2( 1.8, 1.8 )
input/pickable = false
shapes/0/shape = SubResource( 1 )
shapes/0/shape = SubResource( 4 )
shapes/0/transform = Matrix32( 1.89755, 0, 0, 3.10364, 2.93931, -4.91934 )
shapes/0/trigger = false
shapes/1/shape = SubResource( 2 )
@ -72,8 +72,7 @@ invulneravility_time = 2
[node name="shooter" type="Node2D" parent="."]
editor/display_folded = true
transform/pos = Vector2( 32, 0 )
transform/pos = Vector2( 25.3282, 2.0993 )
transform/scale = Vector2( 0.5, 0.5 )
script/script = ExtResource( 2 )
SHOOT_CADENCE = 0.1
@ -104,7 +103,7 @@ _update_shape_index = 1
frames = SubResource( 3 )
animation = "Idle"
frame = 2
frame = 1
playing = true
[node name="Camera2D" type="Camera2D" parent="sprite"]

View file

@ -3,7 +3,7 @@
[ext_resource path="res://rayo_leche.gd" type="Script" id=1]
[ext_resource path="res://Splash.tscn" type="PackedScene" id=2]
[ext_resource path="res://corazon2.tex" type="Texture" id=3]
[ext_resource path="res://milk_ray/middle/milk_ray_middle0000.png" type="Texture" id=4]
[ext_resource path="res://milk_ray/middle/milk_ray_middle0000.tex" type="Texture" id=4]
[sub_resource type="RectangleShape2D" id=1]
@ -38,7 +38,7 @@ func _fixed_process(delta):
func _on_Area2D_body_enter( body ):
if (body.is_in_group(\"enemy\")):
body.decrease_life(1)
body.decrease_life(0.25)
set_fixed_process(true)
"
@ -86,12 +86,12 @@ texture = ExtResource( 3 )
[node name="middle" type="Sprite" parent="."]
transform/pos = Vector2( 0, 7 )
transform/pos = Vector2( 0, 6 )
texture = ExtResource( 4 )
centered = false
offset = Vector2( 0, -14.5 )
region = true
region_rect = Rect2( 0, 0, 50, 29 )
region_rect = Rect2( 0, 0, 100, 29 )
[connection signal="body_enter" from="end/Area2D" to="end/Area2D" method="_on_Area2D_body_enter"]

View file

@ -7,14 +7,16 @@ onready var origin = get_node("origin")
export var damage = 10
var enabled = false
const MAX_DISTANCE = 1000000
const MAX_DISTANCE = 10000
var distance = MAX_DISTANCE
func look_left():
func look_left():
middle.set_region_rect(Rect2(Vector2(0,0),Vector2(0,0)))
distance = -MAX_DISTANCE
middle.set_rot(PI)
middle.set_rot(PI)
func look_right():
middle.set_region_rect(Rect2(Vector2(0,0),Vector2(0,0)))
distance = MAX_DISTANCE
middle.set_rot(0)
@ -31,14 +33,18 @@ func disable():
middle.set_region_rect(Rect2(Vector2(0,0),Vector2(0,0)))
end.set_global_pos(get_global_pos())
func calc_shoot():
set_cast_to(Vector2(distance, 0))
var end_point
if (is_colliding()):
end_point = Vector2 (abs(get_global_pos().x - get_collision_point().x), 29)
else:
end_point = Vector2 (distance, 29)
middle.set_region_rect(Rect2(get_pos(),end_point))
end.set_global_pos(get_collision_point())
origin.set_pos(get_pos())
func _fixed_process(delta):
if (enabled):
var end_point
set_cast_to(Vector2(distance, 0))
if (is_colliding()):
end_point = Vector2 (abs(get_global_pos().x - get_collision_point().x), 29)
else:
end_point = Vector2 (distance, 29)
middle.set_region_rect(Rect2(get_pos(),end_point))
end.set_global_pos(get_collision_point())
origin.set_pos(get_pos())
calc_shoot()

BIN
sangre.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 B

View file

@ -27,7 +27,7 @@ func shoot_regular ():
var instanced_bullet = BULLET.instance()
get_parent().get_parent().add_child(instanced_bullet)
instanced_bullet.set_global_pos(get_global_pos())
instanced_bullet.set_linear_velocity(shoot_dir + Vector2(rand_range(-100, 100), rand_range(-100, 100)))
instanced_bullet.set_linear_velocity(shoot_dir + Vector2(rand_range(-100, 100) + get_parent().velocity.x, rand_range(-100, 100)))
shooting = true
@ -63,10 +63,10 @@ func _fixed_process(delta):
func _on_KinematicBody2D_looking_left():
shoot_dir = Vector2(-500,-250)
set_pos(Vector2(-30, 0))
set_pos(Vector2(-21, 0))
instanced_ray.look_left()
func _on_KinematicBody2D_looking_right():
shoot_dir = Vector2(500,-250)
set_pos(Vector2(30, 0))
set_pos(Vector2(25, 0))
instanced_ray.look_right()