enemies now get squashed by rocks
This commit is contained in:
parent
416982d88e
commit
2cb646ce32
14 changed files with 110 additions and 28 deletions
3
.import/cave.png-453d1492f7a12007a61b71cc1e5f2b93.md5
Normal file
3
.import/cave.png-453d1492f7a12007a61b71cc1e5f2b93.md5
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
source_md5="43e86f36af66b60a97c5bc72b3ccdde0"
|
||||||
|
dest_md5="64ae32fc889df051b035c0114ce55022"
|
||||||
|
|
BIN
.import/cave.png-453d1492f7a12007a61b71cc1e5f2b93.stex
Normal file
BIN
.import/cave.png-453d1492f7a12007a61b71cc1e5f2b93.stex
Normal file
Binary file not shown.
|
@ -1,3 +1,3 @@
|
||||||
source_md5="e3faccac81a57b393e0b8825a7fd1a83"
|
source_md5="80a374a7f80261ece53dd37429da46c1"
|
||||||
dest_md5="de8e5d579635e1ee91db2d6b92c44407"
|
dest_md5="87a32645729271bbe1cb1f471b22c2d9"
|
||||||
|
|
||||||
|
|
Binary file not shown.
BIN
graphics/backgrounds/cave.png
Normal file
BIN
graphics/backgrounds/cave.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 273 B |
35
graphics/backgrounds/cave.png.import
Normal file
35
graphics/backgrounds/cave.png.import
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/cave.png-453d1492f7a12007a61b71cc1e5f2b93.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://graphics/backgrounds/cave.png"
|
||||||
|
dest_files=[ "res://.import/cave.png-453d1492f7a12007a61b71cc1e5f2b93.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=false
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=true
|
||||||
|
svg/scale=1.0
|
Binary file not shown.
Before Width: | Height: | Size: 488 B After Width: | Height: | Size: 486 B |
File diff suppressed because one or more lines are too long
3
objects/enemy/climber.tscn
Normal file
3
objects/enemy/climber.tscn
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[gd_scene format=2]
|
||||||
|
|
||||||
|
[node name="Climber" type="Node2D"]
|
|
@ -27,8 +27,9 @@ func _on_Area2D_area_entered(area):
|
||||||
Game.instance_node(Game.block_text,global_position.x,global_position.y,get_parent())
|
Game.instance_node(Game.block_text,global_position.x,global_position.y,get_parent())
|
||||||
#Die from rock/ get squashed
|
#Die from rock/ get squashed
|
||||||
if area.is_in_group("squash"):
|
if area.is_in_group("squash"):
|
||||||
|
Debug.print("squash")
|
||||||
var squasher = area.get_parent()
|
var squasher = area.get_parent()
|
||||||
if squasher.position.y + squasher.bottom.position.y < global_position.y:
|
if squasher.global_position.y < global_position.y && squasher.velocity.y > 0:
|
||||||
die()
|
die()
|
||||||
|
|
||||||
func die():
|
func die():
|
||||||
|
|
15
objects/enemy/enemy_climber.gd
Normal file
15
objects/enemy/enemy_climber.gd
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
extends "res://objects/enemy/enemy.gd"
|
||||||
|
|
||||||
|
# Declare member variables here. Examples:
|
||||||
|
# var a = 2
|
||||||
|
# var b = "text"
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
#func _process(delta):
|
||||||
|
# pass
|
|
@ -5,18 +5,38 @@ export var left_up_boundry = 0.0
|
||||||
export var right_down_boundry = 0.0
|
export var right_down_boundry = 0.0
|
||||||
#Start direction
|
#Start direction
|
||||||
export var direction = 1
|
export var direction = 1
|
||||||
export var speed = 50
|
export var slower_speed = 50
|
||||||
|
export var faster_speed = 100
|
||||||
#Move horizontal or vertical
|
#Move horizontal or vertical
|
||||||
export(int, "Horizontal", "Vertical") var move_direction
|
export(int, "Horizontal", "Vertical") var move_direction
|
||||||
export var flip_sprite = true
|
export var flip_sprite = true
|
||||||
#Onreadys
|
#Onreadys
|
||||||
onready var startpos = position
|
onready var startpos = position
|
||||||
onready var sprite = $AnimatedSprite
|
onready var sprite = $AnimatedSprite
|
||||||
|
onready var raycast = $Area2D/RayCast2D
|
||||||
|
onready var timer = $Timer
|
||||||
|
|
||||||
|
var speed = 50
|
||||||
|
var go_fast = false
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
if move_direction == 0:
|
if move_direction == 0:
|
||||||
move_side_to_side(delta)
|
move_side_to_side(delta)
|
||||||
else: move_up_and_down(delta)
|
else: move_up_and_down(delta)
|
||||||
|
#Speed up if in raycast
|
||||||
|
if raycast.get_collider() != null:
|
||||||
|
if raycast.get_collider().is_in_group("player"):
|
||||||
|
go_fast = true
|
||||||
|
timer.set_wait_time(0.5)
|
||||||
|
timer.start()
|
||||||
|
#chnage speed depedning on you know
|
||||||
|
if go_fast:
|
||||||
|
speed = faster_speed
|
||||||
|
else:
|
||||||
|
speed = slower_speed
|
||||||
|
#flip raycast with sprite
|
||||||
|
raycast.scale.x = sprite.scale.x
|
||||||
|
|
||||||
|
|
||||||
func move_side_to_side(delta):
|
func move_side_to_side(delta):
|
||||||
#Move
|
#Move
|
||||||
|
@ -39,3 +59,7 @@ func move_up_and_down(delta):
|
||||||
if position.y <= startpos.y + (-left_up_boundry * 8):
|
if position.y <= startpos.y + (-left_up_boundry * 8):
|
||||||
direction = 1
|
direction = 1
|
||||||
if flip_sprite == true: sprite.scale.y = -1
|
if flip_sprite == true: sprite.scale.y = -1
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Timer_timeout():
|
||||||
|
go_fast = false
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
[ext_resource path="res://scripts/1px_border.gdshader" type="Shader" id=1]
|
[ext_resource path="res://scripts/1px_border.gdshader" type="Shader" id=1]
|
||||||
[ext_resource path="res://graphics/enemy/snail.png" type="Texture" id=2]
|
[ext_resource path="res://graphics/enemy/snail.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://objects/enemy/enemy_move_sidesideupdown.gd" type="Script" id=3]
|
[ext_resource path="res://objects/enemy/enemy_speedup_in_range.gd" type="Script" id=3]
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id=1]
|
[sub_resource type="ShaderMaterial" id=1]
|
||||||
shader = ExtResource( 1 )
|
shader = ExtResource( 1 )
|
||||||
|
@ -30,21 +30,28 @@ extents = Vector2( 4, 4 )
|
||||||
|
|
||||||
[node name="Snail" type="Node2D"]
|
[node name="Snail" type="Node2D"]
|
||||||
script = ExtResource( 3 )
|
script = ExtResource( 3 )
|
||||||
|
slower_speed = 10
|
||||||
|
|
||||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||||
material = SubResource( 1 )
|
material = SubResource( 1 )
|
||||||
frames = SubResource( 4 )
|
frames = SubResource( 4 )
|
||||||
frame = 1
|
|
||||||
playing = true
|
playing = true
|
||||||
|
|
||||||
[node name="Area2D" type="Area2D" parent="."]
|
[node name="Area2D" type="Area2D" parent="."]
|
||||||
visible = false
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||||
position = Vector2( 0, 1 )
|
position = Vector2( 0, 1 )
|
||||||
shape = SubResource( 5 )
|
shape = SubResource( 5 )
|
||||||
|
|
||||||
[node name="RayCast2D" type="RayCast2D" parent="."]
|
[node name="RayCast2D" type="RayCast2D" parent="Area2D"]
|
||||||
|
enabled = true
|
||||||
cast_to = Vector2( 32, 0 )
|
cast_to = Vector2( 32, 0 )
|
||||||
|
collide_with_areas = true
|
||||||
|
collide_with_bodies = false
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="."]
|
||||||
|
wait_time = 0.5
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"]
|
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"]
|
||||||
|
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
||||||
|
|
|
@ -75,8 +75,6 @@ func _physics_process(delta):
|
||||||
#Apply velocity
|
#Apply velocity
|
||||||
move_and_slide(velocity,Vector2.UP)
|
move_and_slide(velocity,Vector2.UP)
|
||||||
|
|
||||||
Debug.print(get_owner().filename)
|
|
||||||
|
|
||||||
func _process_idle():
|
func _process_idle():
|
||||||
if anims.get_current_animation() != "idle": anims.play("idle")
|
if anims.get_current_animation() != "idle": anims.play("idle")
|
||||||
#Stop
|
#Stop
|
||||||
|
@ -94,7 +92,6 @@ func _process_walk():
|
||||||
for i in get_slide_count():
|
for i in get_slide_count():
|
||||||
var collision = get_slide_collision(i)
|
var collision = get_slide_collision(i)
|
||||||
if collision.get_collider().is_in_group("pushable"):
|
if collision.get_collider().is_in_group("pushable"):
|
||||||
print(collision.get_collider())
|
|
||||||
collision.get_collider().push(collision.normal)
|
collision.get_collider().push(collision.normal)
|
||||||
|
|
||||||
func _process_idle_walk():
|
func _process_idle_walk():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue