1
Fork 0
mirror of https://github.com/RYGhub/the-cold-night.git synced 2024-11-22 04:34:19 +00:00

💥 everything works now but i dont remember why

This commit is contained in:
Steffo 2022-04-04 16:16:26 +02:00
parent 480e172307
commit d97890bed3
Signed by: steffo
GPG key ID: 6965406171929D01
22 changed files with 172 additions and 55 deletions

View file

@ -80,6 +80,11 @@ _global_script_classes=[ {
"path": "res://src/behaviours/graphics/RandomRotationOnReady.gd" "path": "res://src/behaviours/graphics/RandomRotationOnReady.gd"
}, { }, {
"base": "Node", "base": "Node",
"class": "RapidFire",
"language": "GDScript",
"path": "res://src/pickups/effects/RapidFire.gd"
}, {
"base": "Node",
"class": "SetSpawnedGoalTo", "class": "SetSpawnedGoalTo",
"language": "GDScript", "language": "GDScript",
"path": "res://src/behaviours/targeting/SetSpawnedGoalTo.gd" "path": "res://src/behaviours/targeting/SetSpawnedGoalTo.gd"
@ -119,6 +124,7 @@ _global_script_class_icons={
"PlayerMovement": "", "PlayerMovement": "",
"RNG": "", "RNG": "",
"RandomRotationOnReady": "", "RandomRotationOnReady": "",
"RapidFire": "",
"SetSpawnedGoalTo": "", "SetSpawnedGoalTo": "",
"SpawnEveryPeriod": "", "SpawnEveryPeriod": "",
"SpawnOnShoot": "", "SpawnOnShoot": "",
@ -189,6 +195,7 @@ player_shoot={
2d_physics/layer_2="Damageable" 2d_physics/layer_2="Damageable"
2d_physics/layer_3="Projectiles" 2d_physics/layer_3="Projectiles"
2d_physics/layer_4="UI" 2d_physics/layer_4="UI"
2d_physics/layer_5="Pickups"
[physics] [physics]

View file

@ -8,13 +8,12 @@ signal goal_reached
export var movement_per_second: float export var movement_per_second: float
export var goal_path: NodePath
onready var parent: KinematicBody2D = get_parent() onready var parent: KinematicBody2D = get_parent()
onready var goal: PhysicsBody2D = get_node(goal_path) if goal_path else null
var goal: Node2D = null
var _goal_reached_triggered: bool = false var _goal_reached_triggered: bool = false

View file

@ -13,21 +13,15 @@ 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)
func _handle_spawned(_node):
teleport()

View file

@ -13,10 +13,25 @@ onready var rng = get_tree().root.get_node("Game/RNG").rng
func teleport(): func teleport():
var new_position = Vector2( var random = rng.randi_range(1, 4)
rng.randf_range(0, bounds.x),
rng.randf_range(0, bounds.y) 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.x), bounds.y)
parent.set_position(new_position) parent.set_position(new_position)
emit_signal("teleported", parent.position) emit_signal("teleported", parent.position)
func _handle_spawned(_node):
teleport()

View file

@ -24,7 +24,7 @@ func select_drop() -> PackedScene:
var result = rng.randf_range(0.0, total_weights) var result = rng.randf_range(0.0, total_weights)
for i in range(loot_types.len()): for i in range(len(loot_types)):
var loot_type = loot_types[i] var loot_type = loot_types[i]
var loot_weight = loot_weights[i] var loot_weight = loot_weights[i]
result -= loot_weight result -= loot_weight

View file

@ -8,6 +8,7 @@ signal shot(bullet)
export var bullet: PackedScene export var bullet: PackedScene
export var cooldown: float setget set_cooldown, get_cooldown export var cooldown: float setget set_cooldown, get_cooldown
export var rapid_fire: bool export var rapid_fire: bool
export var angle_offset: float
onready var parent: Node2D = get_parent() onready var parent: Node2D = get_parent()
@ -25,7 +26,7 @@ func shoot(target):
var node = bullet.instance() var node = bullet.instance()
container.add_child(node) container.add_child(node)
node.set_position(global_position) node.set_position(global_position)
node.set_rotation(node.get_angle_to(target)) node.set_rotation(node.get_angle_to(target) + angle_offset)
node.get_node("Ownership").entity_owner = parent node.get_node("Ownership").entity_owner = parent
node.add_collision_exception_with(parent) node.add_collision_exception_with(parent)
emit_signal("shot") emit_signal("shot")

View file

@ -3,8 +3,9 @@ class_name SetSpawnedGoalTo
export var goal_path: NodePath export var goal_path: NodePath
onready var goal = get_node(goal_path)
func set_goal(node): func set_goal(node):
var movement = node.get_node("AttractedToMovement") var movement = node.get_node("AttractedToMovement")
movement.goal = get_node(goal_path) movement.goal = goal

View file

@ -9,3 +9,5 @@
alliance = -1 alliance = -1
[node name="DropLoot" parent="." index="2" instance=ExtResource( 1 )] [node name="DropLoot" parent="." index="2" instance=ExtResource( 1 )]
[connection signal="dead" from="Damageable" to="DropLoot" method="create_drop"]

View file

@ -1,9 +1,10 @@
[gd_scene load_steps=11 format=2] [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/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/pickups/BranchPickup.tscn" type="PackedScene" id=2]
[ext_resource path="res://src/behaviours/movement/AttractedToMovement.tscn" type="PackedScene" id=3] [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://src/entities/enemies/AbstractEnemy.tscn" type="PackedScene" id=4]
[ext_resource path="res://src/pickups/RapidFirePickup.tscn" type="PackedScene" id=5]
[ext_resource path="res://src/entities/enemies/EnemySnowmanBack.png" type="Texture" id=6] [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/EnemySnowmanFront.png" type="Texture" id=7]
[ext_resource path="res://src/entities/enemies/EnemySnowmanRight.png" type="Texture" id=8] [ext_resource path="res://src/entities/enemies/EnemySnowmanRight.png" type="Texture" id=8]
@ -45,8 +46,10 @@ shape = SubResource( 1 )
frames = SubResource( 2 ) frames = SubResource( 2 )
animation = "down" animation = "down"
[node name="ErraticMovement" parent="." index="4" instance=ExtResource( 2 )] [node name="DropLoot" parent="." index="3"]
loot_types = [ null, ExtResource( 2 ), ExtResource( 5 ) ]
loot_weights = [ 1.0, 1.0, 0.1 ]
[node name="AttractedToMovement" parent="." index="5" instance=ExtResource( 3 )] [node name="AttractedToMovement" parent="." index="4" instance=ExtResource( 3 )]
[connection signal="moving_in_direction" from="AttractedToMovement" to="Shape/FourSidedSprite" method="turn"] [connection signal="moving_in_direction" from="AttractedToMovement" to="Shape/FourSidedSprite" method="turn"]

View file

@ -1,7 +1,6 @@
[gd_scene load_steps=10 format=2] [gd_scene load_steps=9 format=2]
[ext_resource path="res://src/entities/players/AbstractPlayer.tscn" type="PackedScene" id=1] [ext_resource path="res://src/entities/players/AbstractPlayer.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/mechanics/White.png" type="Texture" id=2]
[ext_resource path="res://src/entities/bullets/ArrowAlternative.tscn" type="PackedScene" id=3] [ext_resource path="res://src/entities/bullets/ArrowAlternative.tscn" type="PackedScene" id=3]
[ext_resource path="res://src/behaviours/spawning/SpawnOnShoot.tscn" type="PackedScene" id=4] [ext_resource path="res://src/behaviours/spawning/SpawnOnShoot.tscn" type="PackedScene" id=4]
[ext_resource path="res://src/entities/players/CharacterFrontLeft.png" type="Texture" id=5] [ext_resource path="res://src/entities/players/CharacterFrontLeft.png" type="Texture" id=5]
@ -24,7 +23,7 @@ animations = [ {
"name": "right", "name": "right",
"speed": 5.0 "speed": 5.0
}, { }, {
"frames": [ ExtResource( 2 ) ], "frames": [ ExtResource( 5 ) ],
"loop": true, "loop": true,
"name": "up", "name": "up",
"speed": 5.0 "speed": 5.0
@ -36,6 +35,7 @@ animations = [ {
} ] } ]
[node name="PhaseOnePlayer" instance=ExtResource( 1 )] [node name="PhaseOnePlayer" instance=ExtResource( 1 )]
collision_layer = 19
[node name="Shape" type="CollisionShape2D" parent="." index="0"] [node name="Shape" type="CollisionShape2D" parent="." index="0"]
shape = SubResource( 3 ) shape = SubResource( 3 )
@ -50,7 +50,6 @@ current = true
[node name="SpawnOnShoot" parent="." index="2" instance=ExtResource( 4 )] [node name="SpawnOnShoot" parent="." index="2" instance=ExtResource( 4 )]
bullet = ExtResource( 3 ) bullet = ExtResource( 3 )
cooldown = 0.1 cooldown = 0.2
rapid_fire = true
[connection signal="moving_in_direction" from="PlayerMovement" to="Shape/FourSidedSprite" method="turn"] [connection signal="moving_in_direction" from="PlayerMovement" to="Shape/FourSidedSprite" method="turn"]

View file

@ -12,3 +12,7 @@ func set_survival_seconds(value):
func _process(delta): func _process(delta):
set_survival_seconds(survival_seconds + delta) set_survival_seconds(survival_seconds + delta)
func _on_Fire_intensity_reached_min():
print("Game over!")

File diff suppressed because one or more lines are too long

View file

@ -7,4 +7,5 @@
[node name="TeleportToScreenEdge" parent="." index="1" instance=ExtResource( 2 )] [node name="TeleportToScreenEdge" parent="." index="1" instance=ExtResource( 2 )]
[connection signal="spawned" from="." to="TeleportToScreenEdge" method="_handle_spawned"]
[connection signal="timeout" from="Period" to="TeleportToScreenEdge" method="teleport"] [connection signal="timeout" from="Period" to="TeleportToScreenEdge" method="teleport"]

View file

@ -0,0 +1,16 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://src/pickups/effects/ChangeFireIntensity.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/pickups/Pickup.tscn" type="PackedScene" id=2]
[node name="BranchPickup" instance=ExtResource( 2 )]
scale = Vector2( 0.5, 0.5 )
duration_seconds = 0.4
despawn_seconds = 15.0
[node name="Despawn" parent="." index="2"]
autostart = true
[node name="ChangeFireIntensity" parent="." index="3" instance=ExtResource( 1 )]
[connection signal="picked_up" from="." to="ChangeFireIntensity" method="_on_picked_up"]

View file

@ -1,9 +1,8 @@
extends Area2D extends Area2D
export var sprite: Texture = preload("res://src/mechanics/White.png") setget set_sprite, get_sprite export var duration_seconds: float setget set_duration, get_duration
export var duration_seconds: float = 1.0 setget set_duration, get_duration export var despawn_seconds: float setget set_despawn, get_despawn
export var despawn_seconds: float = INF setget set_despawn, get_despawn
signal picked_up signal picked_up
signal expired signal expired
@ -11,18 +10,10 @@ signal despawned
func _ready(): func _ready():
set_sprite(sprite)
set_duration(duration_seconds) set_duration(duration_seconds)
set_despawn(despawn_seconds) set_despawn(despawn_seconds)
func set_sprite(value):
$Shape/Sprite.texture = value
func get_sprite():
return $Shape/Sprite.texture
func set_duration(value): func set_duration(value):
$Duration.wait_time = value $Duration.wait_time = value
@ -36,7 +27,6 @@ func _on_Duration_timeout():
func set_despawn(value): func set_despawn(value):
$Despawn.wait_time = value $Despawn.wait_time = value
$Despawn.start()
func get_despawn(): func get_despawn():
return $Despawn.wait_time return $Despawn.wait_time

View file

@ -1,13 +1,15 @@
[gd_scene load_steps=5 format=2] [gd_scene load_steps=5 format=2]
[ext_resource path="res://src/entities/behaviours/SpriteRandomRotation.gd" type="Script" id=1] [ext_resource path="res://src/behaviours/graphics/RandomRotationOnReady.gd" type="Script" id=1]
[ext_resource path="res://src/pickups/Branch1.png" type="Texture" id=2] [ext_resource path="res://src/pickups/Branch1.png" type="Texture" id=2]
[ext_resource path="res://src/entities/Pickup.gd" type="Script" id=3] [ext_resource path="res://src/pickups/Pickup.gd" type="Script" id=3]
[sub_resource type="RectangleShape2D" id=1] [sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 16, 16 ) extents = Vector2( 16, 16 )
[node name="Pickup" type="Area2D"] [node name="Pickup" type="Area2D"]
collision_layer = 16
collision_mask = 16
input_pickable = false input_pickable = false
script = ExtResource( 3 ) script = ExtResource( 3 )

View file

@ -0,0 +1,18 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://src/pickups/effects/RapidFire.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/pickups/WeaponCrossbow.png" type="Texture" id=2]
[ext_resource path="res://src/pickups/Pickup.tscn" type="PackedScene" id=3]
[node name="RapidFirePickup" instance=ExtResource( 3 )]
scale = Vector2( 0.5, 0.5 )
duration_seconds = inf
[node name="Sprite" parent="Shape" index="0"]
scale = Vector2( 2, 2 )
texture = ExtResource( 2 )
[node name="RapidFire" parent="." index="3" instance=ExtResource( 1 )]
new_cooldown = 0.1
[connection signal="picked_up" from="." to="RapidFire" method="_on_picked_up"]

View file

@ -2,15 +2,15 @@
importer="texture" importer="texture"
type="StreamTexture" type="StreamTexture"
path="res://.import/WeaponCrossbow.png-0a9cc264e092ccff57799323e11448eb.stex" path="res://.import/WeaponCrossbow.png-e19361cc3a5a60e770b810055c1aa183.stex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
[deps] [deps]
source_file="res://src/mechanics/WeaponCrossbow.png" source_file="res://src/pickups/WeaponCrossbow.png"
dest_files=[ "res://.import/WeaponCrossbow.png-0a9cc264e092ccff57799323e11448eb.stex" ] dest_files=[ "res://.import/WeaponCrossbow.png-e19361cc3a5a60e770b810055c1aa183.stex" ]
[params] [params]

View file

@ -1,9 +1,8 @@
extends Node extends Node
export var target_path: NodePath = NodePath("../../Fire")
export var amount_per_second: float = 0.2 export var amount_per_second: float = 0.2
onready var target = get_node(target_path) onready var target = get_tree().root.find_node("Fire", true, false)
onready var pickup: Area2D = get_parent() onready var pickup: Area2D = get_parent()
var active = false var active = false

View file

@ -0,0 +1,15 @@
extends Node
class_name RapidFire
export var new_cooldown: float
onready var target = get_tree().root.find_node("PhaseOnePlayer", true, false)
onready var pickup: Area2D = get_parent()
func _on_picked_up():
var shoot = target.get_node("SpawnOnShoot")
shoot.cooldown = new_cooldown
shoot.rapid_fire = true

View file

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://src/pickups/effects/RapidFire.gd" type="Script" id=1]
[node name="RapidFire" type="Node"]
script = ExtResource( 1 )