fix: Frogs avoiding pits, Frog leash spawning on level load

This commit is contained in:
Jakob Feldmann 2023-04-06 15:54:07 +02:00
parent d3838a21fb
commit 1533e94fa2
20 changed files with 184 additions and 126 deletions

View File

@ -19,6 +19,11 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://src/Actors/Enemies/Beings/Enemy.gd"
}, {
"base": "Node2D",
"class": "LevelTemplate",
"language": "GDScript",
"path": "res://src/Levels/Templates/LevelTemplate.gd"
}, {
"base": "Line2D",
"class": "RayCastDebugLines",
"language": "GDScript",
@ -37,6 +42,7 @@ _global_script_classes=[ {
_global_script_class_icons={
"Actor": "",
"Enemy": "",
"LevelTemplate": "",
"RayCastDebugLines": "",
"RayCaster": "",
"StateMachine": ""

View File

@ -3,13 +3,18 @@ extends Node2D
# Is given in blocks
export var movement_radius = 6
onready var tilemap: TileMap = $"%TileMap"
onready var levelState := get_tree().root.get_child(1).get_node("%LevelState")
onready var signalManager := get_tree().root.get_child(1).get_node("%SignalManager")
var Rope = preload("res://src/Contraptions/Rope/Rope.tscn")
var RopeAnchor = preload("res://src/Contraptions/Rope/RopeAnchor.tscn")
var rope
var is_first_signal = true
func _on_Level_ready() -> void:
func _ready() -> void:
signalManager.connect("level_loaded", self, "_on_level_loaded")
func _on_level_loaded() -> void:
rope = Rope.instance()
# For some reason the rope only can be instanced in the parent scene
# The scene also has to be ready beforehand

View File

@ -1,8 +1,6 @@
extends Actor
class_name Enemy
# TODO adapt to groups
# TODO Engine error here(what does it WANT???)
func _on_StompDetector_body_entered(body: Node) -> void:
if body.global_position.y > get_node("StompDetector").global_position.y:
return

View File

@ -404,6 +404,7 @@ func is_jump_path_safe(v: Vector2, pos: Vector2) -> bool:
var angle = v.angle()
var jump_distance = calculate_jump_distance(v)
var harmful_nodes = get_tree().get_nodes_in_group("harmful")
harmful_nodes.append_array(get_tree().get_nodes_in_group("pit"))
for node in harmful_nodes:
var node_pos = node.global_position
if abs(node_pos.x - pos.x) > abs(jump_distance) * 3 || abs(node_pos.x - pos.x) < 1:

1
src/Levels/Level 1.gd Normal file
View File

@ -0,0 +1 @@
extends LevelTemplate

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=11 format=2]
[gd_scene load_steps=12 format=2]
[ext_resource path="res://src/Environment/AlienShipTileSet.tres" type="TileSet" id=1]
[ext_resource path="res://src/Utilities/SignalManager.tscn" type="PackedScene" id=2]
@ -9,10 +9,12 @@
[ext_resource path="res://src/Levels/Level 2.tscn" type="PackedScene" id=7]
[ext_resource path="res://src/Actors/Blobby/Blobby.tscn" type="PackedScene" id=8]
[ext_resource path="res://src/UserInterface/UserInterface.tscn" type="PackedScene" id=9]
[ext_resource path="res://src/Levels/Level 1.gd" type="Script" id=10]
[sub_resource type="AnimationNodeStateMachinePlayback" id=4]
[node name="First Level" type="Node2D"]
[node name="Level 1" type="Node2D"]
script = ExtResource( 10 )
__meta__ = {
"_edit_horizontal_guides_": [ 464.0 ],
"_edit_vertical_guides_": [ 2880.0 ]
@ -34,10 +36,10 @@ unique_name_in_owner = true
drag_margin_bottom = 0.3
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
frame = 0
frame = 11
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
frame = 0
frame = 11
[node name="Blobby" parent="." instance=ExtResource( 8 )]
unique_name_in_owner = true

1
src/Levels/Level 2.gd Normal file
View File

@ -0,0 +1 @@
extends LevelTemplate

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=16 format=2]
[gd_scene load_steps=17 format=2]
[ext_resource path="res://src/Environment/AlienShipTileSet.tres" type="TileSet" id=1]
[ext_resource path="res://src/Contraptions/Portal/Portal.tscn" type="PackedScene" id=2]
@ -14,10 +14,12 @@
[ext_resource path="res://src/Actors/Enemies/Beings/SimpleEnemy.tscn" type="PackedScene" id=12]
[ext_resource path="res://src/Platforms/DropThroughPlatform.tscn" type="PackedScene" id=13]
[ext_resource path="res://src/Actors/Enemies/Beings/WhatAreFrog.tscn" type="PackedScene" id=14]
[ext_resource path="res://src/Levels/Level 2.gd" type="Script" id=15]
[sub_resource type="AnimationNodeStateMachinePlayback" id=4]
[node name="First Level" type="Node2D"]
[node name="Level 2" type="Node2D"]
script = ExtResource( 15 )
__meta__ = {
"_edit_horizontal_guides_": [ 464.0 ],
"_edit_vertical_guides_": [ 2880.0 ]
@ -39,10 +41,10 @@ unique_name_in_owner = true
drag_margin_bottom = 0.3
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
frame = 5
frame = 3
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
frame = 5
frame = 3
[node name="Blobby" parent="." instance=ExtResource( 9 )]
unique_name_in_owner = true
@ -53,6 +55,9 @@ parameters/playback = SubResource( 4 )
[node name="PitArea" parent="." instance=ExtResource( 10 )]
position = Vector2( 717, 147 )
[node name="CollisionShape2D" parent="PitArea/Area2D" index="0"]
position = Vector2( 195, -87 )
[node name="SimpleEnemy" parent="." instance=ExtResource( 12 )]
position = Vector2( 1857, -13 )

1
src/Levels/Level 3.gd Normal file
View File

@ -0,0 +1 @@
extends LevelTemplate

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,7 @@
extends Node2D
class_name LevelTemplate
onready var signalManager := $"%SignalManager"
func _ready() -> void:
signalManager.emit_signal("level_loaded")

View File

@ -1,17 +1,19 @@
[gd_scene load_steps=10 format=2]
[gd_scene load_steps=11 format=2]
[ext_resource path="res://src/Environment/AlienShipTileSet.tres" type="TileSet" id=1]
[ext_resource path="res://src/Utilities/SignalManager.tscn" type="PackedScene" id=2]
[ext_resource path="res://src/Utilities/LevelState.tscn" type="PackedScene" id=3]
[ext_resource path="res://src/Actors/BlobbyCam.tscn" type="PackedScene" id=4]
[ext_resource path="res://src/Contraptions/Portal/Portal.tscn" type="PackedScene" id=5]
[ext_resource path="res://src/Levels/Legacy Levels/02 Level.tscn" type="PackedScene" id=6]
[ext_resource path="res://src/Levels/x02 Level.tscn" type="PackedScene" id=6]
[ext_resource path="res://src/Actors/Blobby/Blobby.tscn" type="PackedScene" id=7]
[ext_resource path="res://src/UserInterface/UserInterface.tscn" type="PackedScene" id=8]
[ext_resource path="res://src/Levels/Templates/LevelTemplate.gd" type="Script" id=9]
[sub_resource type="AnimationNodeStateMachinePlayback" id=4]
[node name="LevelTemplate" type="Node2D"]
script = ExtResource( 9 )
__meta__ = {
"_edit_horizontal_guides_": [ 464.0 ],
"_edit_vertical_guides_": [ 2880.0 ]
@ -33,10 +35,10 @@ unique_name_in_owner = true
drag_margin_bottom = 0.3
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
frame = 6
frame = 12
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
frame = 10
frame = 2
[node name="Blobby" parent="." instance=ExtResource( 7 )]
unique_name_in_owner = true

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,7 @@
[ext_resource path="res://src/Actors/BlobbyCam.tscn" type="PackedScene" id=4]
[ext_resource path="res://src/Utilities/SignalManager.tscn" type="PackedScene" id=5]
[ext_resource path="res://src/Contraptions/Portal/Portal.tscn" type="PackedScene" id=6]
[ext_resource path="res://src/Levels/Legacy Levels/Enemy Test Level.tscn" type="PackedScene" id=7]
[ext_resource path="res://src/Levels/xEnemy Test Level.tscn" type="PackedScene" id=7]
[ext_resource path="res://src/Actors/Enemies/Beings/Flyer.tscn" type="PackedScene" id=8]
[ext_resource path="res://src/Utilities/LevelState.tscn" type="PackedScene" id=9]
[ext_resource path="res://src/Contraptions/Triggers/ThreeWhyButtons.tscn" type="PackedScene" id=10]

View File

@ -5,7 +5,7 @@
[ext_resource path="res://src/Actors/BlobbyCam.tscn" type="PackedScene" id=4]
[ext_resource path="res://src/NeutralObjects/Coin.tscn" type="PackedScene" id=5]
[ext_resource path="res://src/Contraptions/Portal/Portal.tscn" type="PackedScene" id=6]
[ext_resource path="res://src/Levels/Legacy Levels/Enemy Test Level.tscn" type="PackedScene" id=7]
[ext_resource path="res://src/Levels/xEnemy Test Level.tscn" type="PackedScene" id=7]
[ext_resource path="res://src/Platforms/FlyingLaserCutter.tscn" type="PackedScene" id=8]
[ext_resource path="res://src/Actors/Enemies/Beings/BoundFrog.tscn" type="PackedScene" id=9]
[ext_resource path="res://src/Contraptions/Triggers/ThreeWhyButtons.tscn" type="PackedScene" id=10]
@ -136,7 +136,7 @@ monitoring = false
next_scene = ExtResource( 7 )
[node name="Flyer" parent="." instance=ExtResource( 14 )]
position = Vector2( 169, 192 )
position = Vector2( 555, 192 )
aggressive = false
patrolling_slowdown = 0.3
@ -150,7 +150,7 @@ position = Vector2( -1, -23 )
position = Vector2( -1, 20 )
[node name="SpringPlatform" parent="." instance=ExtResource( 15 )]
position = Vector2( 398, 232 )
position = Vector2( 228, 234 )
rotation = -6.28318
[node name="FlyingLaserCutter" parent="." instance=ExtResource( 8 )]
@ -158,7 +158,7 @@ position = Vector2( 828, 324 )
rotation = -4.71238
[node name="BoundFrog" parent="." instance=ExtResource( 9 )]
position = Vector2( 324, 224 )
position = Vector2( 741, 327 )
[connection signal="ready" from="." to="BoundFrog" method="_on_Level_ready"]

View File

@ -1,5 +1,6 @@
extends Node
signal level_loaded()
signal terminal_activated()
signal getback_timer_up()
signal currency_updated()