Make Ghost Enemy and Fix Can Once Again
parent
a81c6b9afd
commit
fed4a0779a
|
@ -7,6 +7,6 @@ var health = 2
|
|||
|
||||
func add_health(amount):
|
||||
health = clamp(health + amount, 0, 3)
|
||||
get_tree().get_root().get_node("Game/UI/Health/HealthSprite").frame = health
|
||||
get_tree().get_root().get_node("Game/UIWrapper/UI/Health/HealthSprite").frame = health
|
||||
if health == 0:
|
||||
pass # TODO endgame
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://src/models/enemies/bat/sprite.png" type="Texture" id=1]
|
||||
[ext_resource path="res://src/models/enemies/bat/bat.gd" type="Script" id=2]
|
||||
|
@ -6,7 +6,12 @@
|
|||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 4, 3 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 6, 4 )
|
||||
|
||||
[node name="Bat" type="KinematicBody2D" groups=["enemy"]]
|
||||
collision_layer = 2
|
||||
collision_mask = 2
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
|
@ -18,3 +23,7 @@ centered = false
|
|||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
position = Vector2( 7, 4 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="SameSpeciesCollider" type="CollisionShape2D" parent="."]
|
||||
position = Vector2( 7, 4 )
|
||||
shape = SubResource( 2 )
|
||||
|
|
|
@ -29,4 +29,4 @@ func _physics_process(_delta):
|
|||
velocity.y = sin(angle + 180)
|
||||
|
||||
velocity *= speed * speed_multiplier
|
||||
move_and_slide(velocity)
|
||||
velocity = move_and_slide(velocity)
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://src/models/enemies/ghost/sprites/ghost.png" type="Texture" id=1]
|
||||
[ext_resource path="res://src/models/enemies/ghost/ghost.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 7, 9 )
|
||||
|
||||
[node name="Ghost" type="KinematicBody2D" groups=["enemy"]]
|
||||
z_index = 2
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 1 )
|
||||
centered = false
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
position = Vector2( 7, 9 )
|
||||
shape = SubResource( 1 )
|
|
@ -0,0 +1,27 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
onready var player = $"../../Player"
|
||||
var speed_multiplier = 1
|
||||
var dash_target = Vector2.ZERO
|
||||
var dash_timer = .0
|
||||
var dashing = false
|
||||
|
||||
func _physics_process(delta):
|
||||
var dist = global_position.distance_to(player.global_position)
|
||||
if dist > 25 and dash_target == Vector2.ZERO:
|
||||
global_position = global_position.move_toward(player.global_position, dist * delta * speed_multiplier)
|
||||
else:
|
||||
if dash_target == Vector2.ZERO:
|
||||
var angle = global_position.angle_to_point(player.global_position) + PI
|
||||
dash_target = global_position + Vector2(70, 0).rotated(angle)
|
||||
if dash_target != Vector2.ZERO:
|
||||
dash_timer += delta
|
||||
if dash_timer >= 2.0:
|
||||
dash_timer = 0
|
||||
dashing = true
|
||||
|
||||
if dashing:
|
||||
global_position = global_position.move_toward(dash_target, 10)
|
||||
if global_position == dash_target:
|
||||
dashing = false
|
||||
dash_target = Vector2.ZERO
|
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
|
@ -0,0 +1,35 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/ghost.png-97fb088169a5396720410fd8966f5d01.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://src/models/enemies/ghost/sprites/ghost.png"
|
||||
dest_files=[ "res://.import/ghost.png-97fb088169a5396720410fd8966f5d01.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=false
|
||||
svg/scale=1.0
|
|
@ -7,14 +7,15 @@
|
|||
extents = Vector2( 6, 7 )
|
||||
|
||||
[node name="TrashCan" type="KinematicBody2D"]
|
||||
z_index = 2
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 3, 0 )
|
||||
texture = ExtResource( 1 )
|
||||
centered = false
|
||||
|
||||
[node name="EnemyCollider" type="Area2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="EnemyCollider"]
|
||||
position = Vector2( 6, 7 )
|
||||
position = Vector2( 3, 0 )
|
||||
shape = SubResource( 1 )
|
||||
|
|
|
@ -45,7 +45,7 @@ func _ready():
|
|||
last_y = self.global_position.y
|
||||
|
||||
path_sprite.centered = false
|
||||
path_sprite.modulate.a = 1
|
||||
path_sprite.modulate.a = 0.5
|
||||
get_parent().call_deferred("add_child", path_sprite)
|
||||
|
||||
func drop_trash():
|
||||
|
@ -55,10 +55,9 @@ func drop_trash():
|
|||
|
||||
func _physics_process(delta):
|
||||
if start_timer < 2:
|
||||
path_sprite.modulate.a = 2 - start_timer
|
||||
path_sprite.modulate.a = (2 - start_timer) / 2
|
||||
start_timer += delta
|
||||
return
|
||||
|
||||
drop_timer += delta
|
||||
|
||||
velocity = Vector2.ZERO
|
||||
|
|
|
@ -25,6 +25,3 @@ shape = SubResource( 1 )
|
|||
[node name="CollisionShape2D" type="CollisionShape2D" parent="EnemyCollision"]
|
||||
position = Vector2( 12, 12 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[connection signal="area_entered" from="EnemyCollision" to="." method="area_entered"]
|
||||
[connection signal="area_exited" from="EnemyCollision" to="." method="area_exited"]
|
||||
|
|
|
@ -1,28 +1,29 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
var velocity = Vector2.ZERO
|
||||
var speed_multiplier = 1
|
||||
var speed_multiplier: float = 1.0
|
||||
var slowed = false
|
||||
var speed = 100
|
||||
|
||||
func get_input():
|
||||
var input_direction = Input.get_vector("left", "right", "up", "down")
|
||||
velocity = input_direction * speed
|
||||
|
||||
func area_entered(area):
|
||||
if area.get_parent().is_in_group("trash_drop"):
|
||||
speed_multiplier = 0.5
|
||||
|
||||
func area_exited(area):
|
||||
# Check if __all__ the drops exited
|
||||
var exited = true
|
||||
for area in $EnemyCollision.get_overlapping_areas():
|
||||
if area.get_parent().is_in_group("trash_drop"):
|
||||
exited = false
|
||||
if exited:
|
||||
speed_multiplier = 1
|
||||
|
||||
func _physics_process(_delta):
|
||||
get_input()
|
||||
|
||||
var areas = $EnemyCollision.get_overlapping_areas()
|
||||
slowed = false
|
||||
for area in areas:
|
||||
if area.get_parent().is_in_group("trash_drop"):
|
||||
slowed = true
|
||||
break
|
||||
|
||||
if slowed:
|
||||
speed_multiplier = 0.5
|
||||
else:
|
||||
speed_multiplier = 1.0
|
||||
|
||||
velocity = move_and_slide(velocity * speed_multiplier)
|
||||
_choose_target()
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=19 format=2]
|
||||
[gd_scene load_steps=20 format=2]
|
||||
|
||||
[ext_resource path="res://src/scenes/menu/background/background.png" type="Texture" id=1]
|
||||
[ext_resource path="res://src/scenes/game/sprites/background_houses.png" type="Texture" id=2]
|
||||
|
@ -9,11 +9,12 @@
|
|||
[ext_resource path="res://src/scenes/game/sprites/health/1.png" type="Texture" id=7]
|
||||
[ext_resource path="res://src/scenes/game/sprites/health/2.png" type="Texture" id=8]
|
||||
[ext_resource path="res://src/scenes/game/sprites/health/0.png" type="Texture" id=9]
|
||||
[ext_resource path="res://icon.png" type="Texture" id=10]
|
||||
[ext_resource path="res://src/scenes/game/sprites/player_icon.png" type="Texture" id=10]
|
||||
[ext_resource path="res://src/scenes/game/game.gd" type="Script" id=11]
|
||||
[ext_resource path="res://src/scenes/game/sprites/ui_background.png" type="Texture" id=12]
|
||||
[ext_resource path="res://src/models/enemies/trash_can/TrashCan.tscn" type="PackedScene" id=13]
|
||||
[ext_resource path="res://src/models/enemies/bat/Bat.tscn" type="PackedScene" id=14]
|
||||
[ext_resource path="res://src/models/enemies/ghost/Ghost.tscn" type="PackedScene" id=15]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 10, 60 )
|
||||
|
@ -81,29 +82,35 @@ z_index = 1
|
|||
position = Vector2( 142, 54 )
|
||||
z_index = 1
|
||||
|
||||
[node name="Ghost" parent="View/Enemies" instance=ExtResource( 15 )]
|
||||
position = Vector2( 400, 50 )
|
||||
|
||||
[node name="Player" parent="View" instance=ExtResource( 5 )]
|
||||
position = Vector2( 46, 42 )
|
||||
z_index = 1
|
||||
|
||||
[node name="UI" type="Control" parent="."]
|
||||
[node name="UIWrapper" type="CanvasLayer" parent="."]
|
||||
layer = 3
|
||||
|
||||
[node name="UI" type="Control" parent="UIWrapper"]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
|
||||
[node name="Background" type="TextureRect" parent="UI"]
|
||||
[node name="Background" type="TextureRect" parent="UIWrapper/UI"]
|
||||
margin_top = 120.0
|
||||
margin_right = 320.0
|
||||
margin_bottom = 180.0
|
||||
texture = ExtResource( 12 )
|
||||
expand = true
|
||||
|
||||
[node name="SpellHolder" type="Control" parent="UI"]
|
||||
[node name="SpellHolder" type="Control" parent="UIWrapper/UI"]
|
||||
margin_left = 120.0
|
||||
margin_top = 145.0
|
||||
margin_right = 200.0
|
||||
margin_bottom = 159.0
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Text" type="Label" parent="UI/SpellHolder"]
|
||||
[node name="Text" type="Label" parent="UIWrapper/UI/SpellHolder"]
|
||||
margin_left = 1.0
|
||||
margin_top = -14.0
|
||||
margin_right = 79.0
|
||||
|
@ -111,18 +118,17 @@ margin_bottom = 7.0
|
|||
custom_fonts/font = SubResource( 1 )
|
||||
text = "spell modifiers"
|
||||
|
||||
[node name="Health" type="Control" parent="UI"]
|
||||
[node name="Health" type="Control" parent="UIWrapper/UI"]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
|
||||
[node name="HealthSprite" type="AnimatedSprite" parent="UI/Health"]
|
||||
[node name="HealthSprite" type="AnimatedSprite" parent="UIWrapper/UI/Health"]
|
||||
position = Vector2( 70, 145 )
|
||||
frames = SubResource( 4 )
|
||||
frame = 2
|
||||
centered = false
|
||||
|
||||
[node name="PlayerIcon" type="Sprite" parent="UI"]
|
||||
[node name="PlayerIcon" type="Sprite" parent="UIWrapper/UI"]
|
||||
position = Vector2( 20, 134 )
|
||||
scale = Vector2( 0.5, 0.5 )
|
||||
texture = ExtResource( 10 )
|
||||
centered = false
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 6.8 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.6 KiB |
|
@ -0,0 +1,35 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/background_houses_old.png-1d6d95d92529e7c5e15327686796eba5.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://src/scenes/game/sprites/background_houses_old.png"
|
||||
dest_files=[ "res://.import/background_houses_old.png-1d6d95d92529e7c5e15327686796eba5.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=false
|
||||
svg/scale=1.0
|
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
|
@ -0,0 +1,35 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/player_icon.png-a729c1dec9fd225b7fe2783392839b49.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://src/scenes/game/sprites/player_icon.png"
|
||||
dest_files=[ "res://.import/player_icon.png-a729c1dec9fd225b7fe2783392839b49.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=false
|
||||
svg/scale=1.0
|
|
@ -15,6 +15,6 @@ func check_poisoned():
|
|||
if poisoned_timer >= 1:
|
||||
hp -= 5
|
||||
|
||||
func _physics_process(delta):
|
||||
func _physics_process(_delta):
|
||||
check_frozen()
|
||||
check_poisoned()
|
||||
|
|
Loading…
Reference in New Issue