mirror of
https://github.com/RYGhub/the-cold-night.git
synced 2024-11-25 14:14:19 +00:00
🔧 Add sprites to snowmen
This commit is contained in:
parent
04ea003b6d
commit
2607bea0ba
18 changed files with 166 additions and 58 deletions
|
@ -44,6 +44,11 @@ _global_script_classes=[ {
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://FireExtinguisherEnemy.gd"
|
"path": "res://FireExtinguisherEnemy.gd"
|
||||||
}, {
|
}, {
|
||||||
|
"base": "AnimatedSprite",
|
||||||
|
"class": "FourSidedSprite",
|
||||||
|
"language": "GDScript",
|
||||||
|
"path": "res://src/behaviours/graphics/FourSidedSprite.gd"
|
||||||
|
}, {
|
||||||
"base": "Node",
|
"base": "Node",
|
||||||
"class": "Ownership",
|
"class": "Ownership",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
|
@ -75,9 +80,14 @@ _global_script_classes=[ {
|
||||||
"path": "res://src/behaviours/spawning/SpawnEveryPeriod.gd"
|
"path": "res://src/behaviours/spawning/SpawnEveryPeriod.gd"
|
||||||
}, {
|
}, {
|
||||||
"base": "Node",
|
"base": "Node",
|
||||||
"class": "TeleportToScreenEdge",
|
"class": "TeleportToRandomPosition",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://src/behaviours/movement/TeleportToScreenEdge.gd"
|
"path": "res://src/behaviours/movement/TeleportToScreenEdge.gd"
|
||||||
|
}, {
|
||||||
|
"base": "Node",
|
||||||
|
"class": "TeleportToScreenEdge",
|
||||||
|
"language": "GDScript",
|
||||||
|
"path": "res://src/behaviours/movement/TeleportToRandomPosition.gd"
|
||||||
} ]
|
} ]
|
||||||
_global_script_class_icons={
|
_global_script_class_icons={
|
||||||
"Alliance": "",
|
"Alliance": "",
|
||||||
|
@ -87,12 +97,14 @@ _global_script_class_icons={
|
||||||
"DropLoot": "",
|
"DropLoot": "",
|
||||||
"ErraticMovement": "",
|
"ErraticMovement": "",
|
||||||
"FireExtinguisherEnemy": "",
|
"FireExtinguisherEnemy": "",
|
||||||
|
"FourSidedSprite": "",
|
||||||
"Ownership": "",
|
"Ownership": "",
|
||||||
"PlayerMovement": "",
|
"PlayerMovement": "",
|
||||||
"RNG": "",
|
"RNG": "",
|
||||||
"RandomRotationOnReady": "",
|
"RandomRotationOnReady": "",
|
||||||
"SetSpawnedGoalTo": "",
|
"SetSpawnedGoalTo": "",
|
||||||
"SpawnEveryPeriod": "",
|
"SpawnEveryPeriod": "",
|
||||||
|
"TeleportToRandomPosition": "",
|
||||||
"TeleportToScreenEdge": ""
|
"TeleportToScreenEdge": ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
29
src/behaviours/graphics/FourSidedSprite.gd
Normal file
29
src/behaviours/graphics/FourSidedSprite.gd
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
extends AnimatedSprite
|
||||||
|
class_name FourSidedSprite
|
||||||
|
|
||||||
|
|
||||||
|
const UP_LEFT = -3*PI/4
|
||||||
|
const UP_RIGHT = -PI/4
|
||||||
|
const DOWN_RIGHT = PI/4
|
||||||
|
const DOWN_LEFT = 3*PI/4
|
||||||
|
|
||||||
|
|
||||||
|
func turn(direction: Vector2) -> String:
|
||||||
|
var angle = direction.angle()
|
||||||
|
var anime
|
||||||
|
|
||||||
|
if _between(UP_LEFT, angle, UP_RIGHT):
|
||||||
|
anime = "up"
|
||||||
|
elif _between(UP_RIGHT, angle, DOWN_RIGHT):
|
||||||
|
anime = "right"
|
||||||
|
elif _between(DOWN_RIGHT, angle, DOWN_LEFT):
|
||||||
|
anime = "down"
|
||||||
|
else:
|
||||||
|
anime = "left"
|
||||||
|
|
||||||
|
play(anime)
|
||||||
|
return animation
|
||||||
|
|
||||||
|
|
||||||
|
func _between(m, val, x) -> bool:
|
||||||
|
return (m < val) && (val <= x)
|
6
src/behaviours/graphics/FourSidedSprite.tscn
Normal file
6
src/behaviours/graphics/FourSidedSprite.tscn
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://src/behaviours/graphics/FourSidedSprite.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="FourSidedSprite" type="AnimatedSprite"]
|
||||||
|
script = ExtResource( 1 )
|
|
@ -2,6 +2,7 @@ extends Node
|
||||||
class_name AttractedToMovement
|
class_name AttractedToMovement
|
||||||
|
|
||||||
|
|
||||||
|
signal moving_in_direction(direction)
|
||||||
signal touching_goal
|
signal touching_goal
|
||||||
signal goal_reached
|
signal goal_reached
|
||||||
|
|
||||||
|
@ -19,6 +20,7 @@ var _goal_reached_triggered: bool = false
|
||||||
|
|
||||||
func move():
|
func move():
|
||||||
var direction: Vector2 = (goal.global_position - parent.global_position).normalized()
|
var direction: Vector2 = (goal.global_position - parent.global_position).normalized()
|
||||||
|
emit_signal("moving_in_direction", direction)
|
||||||
var _motion: Vector2 = parent.move_and_slide(direction * movement_per_second, Vector2.ZERO)
|
var _motion: Vector2 = parent.move_and_slide(direction * movement_per_second, Vector2.ZERO)
|
||||||
for slide_no in parent.get_slide_count():
|
for slide_no in parent.get_slide_count():
|
||||||
var slide = parent.get_slide_collision(slide_no)
|
var slide = parent.get_slide_collision(slide_no)
|
||||||
|
|
33
src/behaviours/movement/TeleportToRandomPosition.gd
Normal file
33
src/behaviours/movement/TeleportToRandomPosition.gd
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
extends Node
|
||||||
|
class_name TeleportToScreenEdge
|
||||||
|
|
||||||
|
|
||||||
|
signal teleported(to)
|
||||||
|
|
||||||
|
|
||||||
|
export var bounds: Vector2
|
||||||
|
|
||||||
|
|
||||||
|
onready var parent = get_parent()
|
||||||
|
onready var rng = get_tree().root.get_node("Game/RNG").rng
|
||||||
|
|
||||||
|
|
||||||
|
func teleport():
|
||||||
|
var random = rng.randi_range(1, 4)
|
||||||
|
|
||||||
|
var new_position
|
||||||
|
if random == 1:
|
||||||
|
# Left
|
||||||
|
new_position = Vector2(0, rng.randf_range(0, bounds.y))
|
||||||
|
elif random == 2:
|
||||||
|
# Right
|
||||||
|
new_position = Vector2(bounds.x, rng.randf_range(0, bounds.y))
|
||||||
|
elif random == 3:
|
||||||
|
# Top
|
||||||
|
new_position = Vector2(rng.randf_range(0, bounds.x), 0)
|
||||||
|
else:
|
||||||
|
# Bottom
|
||||||
|
new_position = Vector2(rng.randf_range(0, bounds.y), bounds.y)
|
||||||
|
|
||||||
|
parent.set_position(new_position)
|
||||||
|
emit_signal("teleported", parent.position)
|
6
src/behaviours/movement/TeleportToRandomPosition.tscn
Normal file
6
src/behaviours/movement/TeleportToRandomPosition.tscn
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://src/behaviours/movement/TeleportToScreenEdge.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="TeleportToRandomPosition" type="Node"]
|
||||||
|
script = ExtResource( 1 )
|
|
@ -1,5 +1,5 @@
|
||||||
extends Node
|
extends Node
|
||||||
class_name TeleportToScreenEdge
|
class_name TeleportToRandomPosition
|
||||||
|
|
||||||
|
|
||||||
signal teleported(to)
|
signal teleported(to)
|
||||||
|
@ -13,21 +13,10 @@ onready var rng = get_tree().root.get_node("Game/RNG").rng
|
||||||
|
|
||||||
|
|
||||||
func teleport():
|
func teleport():
|
||||||
var random = rng.randi_range(1, 4)
|
var new_position = Vector2(
|
||||||
|
rng.randf_range(0, bounds.x),
|
||||||
var new_position
|
rng.randf_range(0, bounds.y)
|
||||||
if random == 1:
|
)
|
||||||
# Left
|
|
||||||
new_position = Vector2(0, rng.randf_range(0, bounds.y))
|
|
||||||
elif random == 2:
|
|
||||||
# Right
|
|
||||||
new_position = Vector2(bounds.x, rng.randf_range(0, bounds.y))
|
|
||||||
elif random == 3:
|
|
||||||
# Top
|
|
||||||
new_position = Vector2(rng.randf_range(0, bounds.x), 0)
|
|
||||||
else:
|
|
||||||
# Bottom
|
|
||||||
new_position = Vector2(rng.randf_range(0, bounds.y), bounds.y)
|
|
||||||
|
|
||||||
parent.set_position(new_position)
|
parent.set_position(new_position)
|
||||||
emit_signal("teleported", parent.position)
|
emit_signal("teleported", parent.position)
|
||||||
|
|
54
src/entities/enemies/ChaserEnemy.tscn
Normal file
54
src/entities/enemies/ChaserEnemy.tscn
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
[gd_scene load_steps=12 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://src/entities/enemies/EnemySnowmanLeft.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://src/behaviours/movement/ErraticMovement.tscn" type="PackedScene" id=2]
|
||||||
|
[ext_resource path="res://src/behaviours/movement/AttractedToMovement.tscn" type="PackedScene" id=3]
|
||||||
|
[ext_resource path="res://src/entities/enemies/AbstractEnemy.tscn" type="PackedScene" id=4]
|
||||||
|
[ext_resource path="res://FireExtinguisherEnemy.gd" type="Script" id=5]
|
||||||
|
[ext_resource path="res://src/entities/enemies/EnemySnowmanBack.png" type="Texture" id=6]
|
||||||
|
[ext_resource path="res://src/entities/enemies/EnemySnowmanFront.png" type="Texture" id=7]
|
||||||
|
[ext_resource path="res://src/entities/enemies/EnemySnowmanRight.png" type="Texture" id=8]
|
||||||
|
[ext_resource path="res://src/behaviours/graphics/FourSidedSprite.tscn" type="PackedScene" id=9]
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape2D" id=1]
|
||||||
|
radius = 9.0
|
||||||
|
height = 10.0
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id=2]
|
||||||
|
animations = [ {
|
||||||
|
"frames": [ ExtResource( 1 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "left",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [ ExtResource( 8 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "right",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [ ExtResource( 6 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "up",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [ ExtResource( 7 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "down",
|
||||||
|
"speed": 5.0
|
||||||
|
} ]
|
||||||
|
|
||||||
|
[node name="ChaserEnemy" instance=ExtResource( 4 )]
|
||||||
|
script = ExtResource( 5 )
|
||||||
|
|
||||||
|
[node name="Shape" type="CollisionShape2D" parent="." index="0"]
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="FourSidedSprite" parent="Shape" index="0" instance=ExtResource( 9 )]
|
||||||
|
frames = SubResource( 2 )
|
||||||
|
animation = "down"
|
||||||
|
|
||||||
|
[node name="ErraticMovement" parent="." index="4" instance=ExtResource( 2 )]
|
||||||
|
|
||||||
|
[node name="AttractedToMovement" parent="." index="5" instance=ExtResource( 3 )]
|
||||||
|
|
||||||
|
[connection signal="moving_in_direction" from="AttractedToMovement" to="Shape/FourSidedSprite" method="turn"]
|
|
@ -2,15 +2,15 @@
|
||||||
|
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="StreamTexture"
|
type="StreamTexture"
|
||||||
path="res://.import/EnemySnowmanBack.png-b2eed2720f48972b09c43adc35364e67.stex"
|
path="res://.import/EnemySnowmanBack.png-d689ef59a615a3796d8d5dee024e3fb9.stex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://src/mechanics/EnemySnowmanBack.png"
|
source_file="res://src/entities/enemies/EnemySnowmanBack.png"
|
||||||
dest_files=[ "res://.import/EnemySnowmanBack.png-b2eed2720f48972b09c43adc35364e67.stex" ]
|
dest_files=[ "res://.import/EnemySnowmanBack.png-d689ef59a615a3796d8d5dee024e3fb9.stex" ]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ compress/hdr_mode=0
|
||||||
compress/bptc_ldr=0
|
compress/bptc_ldr=0
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
flags/repeat=0
|
flags/repeat=0
|
||||||
flags/filter=true
|
flags/filter=false
|
||||||
flags/mipmaps=false
|
flags/mipmaps=false
|
||||||
flags/anisotropic=false
|
flags/anisotropic=false
|
||||||
flags/srgb=2
|
flags/srgb=2
|
|
@ -2,15 +2,15 @@
|
||||||
|
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="StreamTexture"
|
type="StreamTexture"
|
||||||
path="res://.import/EnemySnowmanFront.png-a3abfa69d73157e46639cd3e486ba674.stex"
|
path="res://.import/EnemySnowmanFront.png-cd9afc4418c9808a8eabdd96966d3a3c.stex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://src/mechanics/EnemySnowmanFront.png"
|
source_file="res://src/entities/enemies/EnemySnowmanFront.png"
|
||||||
dest_files=[ "res://.import/EnemySnowmanFront.png-a3abfa69d73157e46639cd3e486ba674.stex" ]
|
dest_files=[ "res://.import/EnemySnowmanFront.png-cd9afc4418c9808a8eabdd96966d3a3c.stex" ]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ compress/hdr_mode=0
|
||||||
compress/bptc_ldr=0
|
compress/bptc_ldr=0
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
flags/repeat=0
|
flags/repeat=0
|
||||||
flags/filter=true
|
flags/filter=false
|
||||||
flags/mipmaps=false
|
flags/mipmaps=false
|
||||||
flags/anisotropic=false
|
flags/anisotropic=false
|
||||||
flags/srgb=2
|
flags/srgb=2
|
|
@ -2,15 +2,15 @@
|
||||||
|
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="StreamTexture"
|
type="StreamTexture"
|
||||||
path="res://.import/EnemySnowmanLeft.png-651743351802fe1f1144983f041aa579.stex"
|
path="res://.import/EnemySnowmanLeft.png-622396971c521134bfb97a1767ad0b42.stex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://src/mechanics/EnemySnowmanLeft.png"
|
source_file="res://src/entities/enemies/EnemySnowmanLeft.png"
|
||||||
dest_files=[ "res://.import/EnemySnowmanLeft.png-651743351802fe1f1144983f041aa579.stex" ]
|
dest_files=[ "res://.import/EnemySnowmanLeft.png-622396971c521134bfb97a1767ad0b42.stex" ]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ compress/hdr_mode=0
|
||||||
compress/bptc_ldr=0
|
compress/bptc_ldr=0
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
flags/repeat=0
|
flags/repeat=0
|
||||||
flags/filter=true
|
flags/filter=false
|
||||||
flags/mipmaps=false
|
flags/mipmaps=false
|
||||||
flags/anisotropic=false
|
flags/anisotropic=false
|
||||||
flags/srgb=2
|
flags/srgb=2
|
|
@ -2,15 +2,15 @@
|
||||||
|
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="StreamTexture"
|
type="StreamTexture"
|
||||||
path="res://.import/EnemySnowmanRight.png-3e7f2a8dafa504a24f600bb4b8857d35.stex"
|
path="res://.import/EnemySnowmanRight.png-75a99b9b1b6aa0a37e6ab3b171957d06.stex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://src/mechanics/EnemySnowmanRight.png"
|
source_file="res://src/entities/enemies/EnemySnowmanRight.png"
|
||||||
dest_files=[ "res://.import/EnemySnowmanRight.png-3e7f2a8dafa504a24f600bb4b8857d35.stex" ]
|
dest_files=[ "res://.import/EnemySnowmanRight.png-75a99b9b1b6aa0a37e6ab3b171957d06.stex" ]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ compress/hdr_mode=0
|
||||||
compress/bptc_ldr=0
|
compress/bptc_ldr=0
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
flags/repeat=0
|
flags/repeat=0
|
||||||
flags/filter=true
|
flags/filter=false
|
||||||
flags/mipmaps=false
|
flags/mipmaps=false
|
||||||
flags/anisotropic=false
|
flags/anisotropic=false
|
||||||
flags/srgb=2
|
flags/srgb=2
|
|
@ -1,23 +0,0 @@
|
||||||
[gd_scene load_steps=7 format=2]
|
|
||||||
|
|
||||||
[ext_resource path="res://src/mechanics/White.png" type="Texture" id=1]
|
|
||||||
[ext_resource path="res://src/behaviours/movement/ErraticMovement.tscn" type="PackedScene" id=2]
|
|
||||||
[ext_resource path="res://src/behaviours/movement/AttractedToMovement.tscn" type="PackedScene" id=3]
|
|
||||||
[ext_resource path="res://src/entities/enemies/AbstractEnemy.tscn" type="PackedScene" id=4]
|
|
||||||
[ext_resource path="res://FireExtinguisherEnemy.gd" type="Script" id=5]
|
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
|
||||||
extents = Vector2( 16, 16 )
|
|
||||||
|
|
||||||
[node name="FireExtinguisherEnemy" instance=ExtResource( 4 )]
|
|
||||||
script = ExtResource( 5 )
|
|
||||||
|
|
||||||
[node name="Shape" type="CollisionShape2D" parent="." index="0"]
|
|
||||||
shape = SubResource( 1 )
|
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="Shape" index="0"]
|
|
||||||
texture = ExtResource( 1 )
|
|
||||||
|
|
||||||
[node name="ErraticMovement" parent="." index="4" instance=ExtResource( 2 )]
|
|
||||||
|
|
||||||
[node name="AttractedToMovement" parent="." index="5" instance=ExtResource( 3 )]
|
|
|
@ -8,7 +8,7 @@
|
||||||
[ext_resource path="res://src/levels/Game.gd" type="Script" id=6]
|
[ext_resource path="res://src/levels/Game.gd" type="Script" id=6]
|
||||||
[ext_resource path="res://src/ui/TimeSurvived.tscn" type="PackedScene" id=7]
|
[ext_resource path="res://src/ui/TimeSurvived.tscn" type="PackedScene" id=7]
|
||||||
[ext_resource path="res://src/mechanics/ScreenEdgeSpawner.tscn" type="PackedScene" id=8]
|
[ext_resource path="res://src/mechanics/ScreenEdgeSpawner.tscn" type="PackedScene" id=8]
|
||||||
[ext_resource path="res://src/entities/enemies/FireExtinguisherEnemy.tscn" type="PackedScene" id=9]
|
[ext_resource path="res://src/entities/enemies/ChaserEnemy.tscn" type="PackedScene" id=9]
|
||||||
[ext_resource path="res://src/behaviours/targeting/SetSpawnedGoalTo.tscn" type="PackedScene" id=10]
|
[ext_resource path="res://src/behaviours/targeting/SetSpawnedGoalTo.tscn" type="PackedScene" id=10]
|
||||||
[ext_resource path="res://src/levels/PhaseOneMusic.gd" type="Script" id=11]
|
[ext_resource path="res://src/levels/PhaseOneMusic.gd" type="Script" id=11]
|
||||||
[ext_resource path="res://src/ui/HealthBar.tscn" type="PackedScene" id=14]
|
[ext_resource path="res://src/ui/HealthBar.tscn" type="PackedScene" id=14]
|
||||||
|
@ -49,7 +49,7 @@ position = Vector2( 596, 268 )
|
||||||
|
|
||||||
[node name="Fire" parent="PhaseOne/Entities" instance=ExtResource( 3 )]
|
[node name="Fire" parent="PhaseOne/Entities" instance=ExtResource( 3 )]
|
||||||
position = Vector2( 640, 320 )
|
position = Vector2( 640, 320 )
|
||||||
intensity = 1.0
|
intensity = 2.0
|
||||||
|
|
||||||
[node name="Pickups" type="Node" parent="PhaseOne/Entities"]
|
[node name="Pickups" type="Node" parent="PhaseOne/Entities"]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue