Group based area/body detection, walljump fix
This commit is contained in:
parent
6605221398
commit
1a45a0ca84
@ -116,7 +116,7 @@ quality/intended_usage/framebuffer_allocation.mobile=0
|
|||||||
quality/filters/use_nearest_mipmap_filter=true
|
quality/filters/use_nearest_mipmap_filter=true
|
||||||
quality/filters/msaa=1
|
quality/filters/msaa=1
|
||||||
environment/default_environment="res://default_env.tres"
|
environment/default_environment="res://default_env.tres"
|
||||||
quality/2d/use_pixel_snap=true
|
quality/2d/use_pixel_snap=false
|
||||||
environment/2d/use_nvidia_rect_flicker_workaround=true
|
environment/2d/use_nvidia_rect_flicker_workaround=true
|
||||||
environment/stretch/aspect="ignore"
|
environment/stretch/aspect="ignore"
|
||||||
environment/intended_usage/framebuffer_allocation.mobile=0
|
environment/intended_usage/framebuffer_allocation.mobile=0
|
||||||
|
|||||||
@ -20,13 +20,15 @@ onready var camera = $Camera2D
|
|||||||
# TODO This is the worst thing since... you know
|
# TODO This is the worst thing since... you know
|
||||||
# When the Enemy stomp AREA enters the enemy collision area -> stomp
|
# When the Enemy stomp AREA enters the enemy collision area -> stomp
|
||||||
func _on_BlobbySkin_area_entered(area: Area2D) -> void:
|
func _on_BlobbySkin_area_entered(area: Area2D) -> void:
|
||||||
if area.name == "StompDetector":
|
if area.is_in_group("weakpoint"):
|
||||||
velocity = calculate_stomp_velocity(velocity, stomp_feedback)
|
velocity = calculate_stomp_velocity(velocity, stomp_feedback)
|
||||||
|
if area.is_in_group("harmful"):
|
||||||
|
die()
|
||||||
|
|
||||||
|
|
||||||
# When the Enemy collision BODY enters the enemy collision area -> die
|
# When the Enemy collision BODY enters the enemy collision area -> die
|
||||||
func _on_BlobbySkin_body_entered(body: Node) -> void:
|
func _on_BlobbySkin_body_entered(body: Node) -> void:
|
||||||
if body.name == "EnemyBody":
|
if body.is_in_group("harmful"):
|
||||||
die()
|
die()
|
||||||
|
|
||||||
|
|
||||||
@ -245,19 +247,13 @@ func calculate_fall_velocity(
|
|||||||
func calculate_wallslide_velocity(
|
func calculate_wallslide_velocity(
|
||||||
linear_velocity: Vector2, delta: float, direction: Vector2
|
linear_velocity: Vector2, delta: float, direction: Vector2
|
||||||
) -> Vector2:
|
) -> Vector2:
|
||||||
# Walljump mechanics
|
# Walljump mechanicsdd
|
||||||
if is_correct_walljump_input(direction):
|
if is_correct_walljump_input(direction):
|
||||||
linear_velocity.x = PhysicsFunc.two_step_euler(
|
linear_velocity.x = PhysicsFunc.two_step_euler(
|
||||||
linear_velocity.x,
|
0, acceleration_force["walljump"].x * direction.x, mass, delta
|
||||||
acceleration_force["walljump"].x * direction.x,
|
|
||||||
mass,
|
|
||||||
delta
|
|
||||||
)
|
)
|
||||||
linear_velocity.y += PhysicsFunc.two_step_euler(
|
linear_velocity.y = PhysicsFunc.two_step_euler(
|
||||||
linear_velocity.y,
|
0, acceleration_force["walljump"].y * -1, mass, delta
|
||||||
acceleration_force["walljump"].y * -1,
|
|
||||||
mass,
|
|
||||||
delta
|
|
||||||
)
|
)
|
||||||
elif is_correct_airstrafe_input():
|
elif is_correct_airstrafe_input():
|
||||||
linear_velocity.x = PhysicsFunc.two_step_euler(
|
linear_velocity.x = PhysicsFunc.two_step_euler(
|
||||||
|
|||||||
@ -17,7 +17,7 @@ texture = ExtResource( 1 )
|
|||||||
|
|
||||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="Player"]
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="Player"]
|
||||||
|
|
||||||
[node name="BlobbyBody" type="CollisionPolygon2D" parent="."]
|
[node name="BlobbyBody" type="CollisionPolygon2D" parent="." groups=["player"]]
|
||||||
polygon = PoolVector2Array( -6.7, -3.273, -2.676, -7.3, 3.939, -7.3, 8, -1.768, 8, 4.912, 4.944, 8.5, -1.03623, 8.5, -4.213, 8.5, -6.7, 6.089 )
|
polygon = PoolVector2Array( -6.7, -3.273, -2.676, -7.3, 3.939, -7.3, 8, -1.768, 8, 4.912, 4.944, 8.5, -1.03623, 8.5, -4.213, 8.5, -6.7, 6.089 )
|
||||||
|
|
||||||
[node name="Camera2D" type="Camera2D" parent="."]
|
[node name="Camera2D" type="Camera2D" parent="."]
|
||||||
@ -39,7 +39,7 @@ script = ExtResource( 2 )
|
|||||||
|
|
||||||
[node name="ShiftTween" type="Tween" parent="Camera2D"]
|
[node name="ShiftTween" type="Tween" parent="Camera2D"]
|
||||||
|
|
||||||
[node name="BlobbySkin" type="Area2D" parent="."]
|
[node name="BlobbySkin" type="Area2D" parent="." groups=["player"]]
|
||||||
collision_mask = 126
|
collision_mask = 126
|
||||||
|
|
||||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="BlobbySkin"]
|
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="BlobbySkin"]
|
||||||
|
|||||||
@ -12,7 +12,7 @@ func _ready() -> void:
|
|||||||
func _on_StompDetector_body_entered(body: Node) -> void:
|
func _on_StompDetector_body_entered(body: Node) -> void:
|
||||||
if body.global_position.y > get_node("StompDetector").global_position.y:
|
if body.global_position.y > get_node("StompDetector").global_position.y:
|
||||||
return
|
return
|
||||||
get_node("EnemyShape").disabled = true
|
get_node("EnemyBody").disabled = true
|
||||||
die()
|
die()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ extents = Vector2( 2.72463, 1.17848 )
|
|||||||
[sub_resource type="RectangleShape2D" id=2]
|
[sub_resource type="RectangleShape2D" id=2]
|
||||||
extents = Vector2( 15.4794, 6.68174 )
|
extents = Vector2( 15.4794, 6.68174 )
|
||||||
|
|
||||||
[node name="Enemy" type="KinematicBody2D"]
|
[node name="Enemy" type="KinematicBody2D" groups=["harmful"]]
|
||||||
collision_layer = 2
|
collision_layer = 2
|
||||||
collision_mask = 9
|
collision_mask = 9
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
@ -26,12 +26,12 @@ rect = Rect2( -89, -10, 2, 20 )
|
|||||||
process_parent = true
|
process_parent = true
|
||||||
physics_process_parent = true
|
physics_process_parent = true
|
||||||
|
|
||||||
[node name="EnemyBody" type="CollisionShape2D" parent="."]
|
[node name="EnemyBody" type="CollisionShape2D" parent="." groups=["harmful"]]
|
||||||
position = Vector2( 0, 6.48802 )
|
position = Vector2( 0, 6.48802 )
|
||||||
scale = Vector2( 5.68128, 5.29182 )
|
scale = Vector2( 5.68128, 5.29182 )
|
||||||
shape = SubResource( 1 )
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
[node name="StompDetector" type="Area2D" parent="."]
|
[node name="StompDetector" type="Area2D" parent="." groups=["weakpoint"]]
|
||||||
modulate = Color( 0, 0.0392157, 1, 1 )
|
modulate = Color( 0, 0.0392157, 1, 1 )
|
||||||
position = Vector2( 0, -6.44095 )
|
position = Vector2( 0, -6.44095 )
|
||||||
collision_layer = 2
|
collision_layer = 2
|
||||||
|
|||||||
@ -23,7 +23,7 @@ var acceleration_force := {
|
|||||||
"walk": Vector2(2000, 68000),
|
"walk": Vector2(2000, 68000),
|
||||||
"idle": Vector2(2000, 68000),
|
"idle": Vector2(2000, 68000),
|
||||||
"run": Vector2(2000, 68000),
|
"run": Vector2(2000, 68000),
|
||||||
"walljump": Vector2(30000, 58000),
|
"walljump": Vector2(50000, 58000),
|
||||||
"air_strafe": Vector2(20000, 0)
|
"air_strafe": Vector2(20000, 0)
|
||||||
}
|
}
|
||||||
# Gravity as m/s^2
|
# Gravity as m/s^2
|
||||||
|
|||||||
@ -117,8 +117,6 @@ func _get_transition(_delta):
|
|||||||
parent.is_touching_wall_completely()
|
parent.is_touching_wall_completely()
|
||||||
&& parent.velocity.y <= parent.wallslide_threshold
|
&& parent.velocity.y <= parent.wallslide_threshold
|
||||||
):
|
):
|
||||||
# TODO Wallslide might be too long
|
|
||||||
# TODO Player is stuck to the wall
|
|
||||||
new_state = states.wallslide
|
new_state = states.wallslide
|
||||||
# Begins coyote time only if walking from ledge
|
# Begins coyote time only if walking from ledge
|
||||||
elif [states.walk, states.run].has(self.state) && !coyote_hanging:
|
elif [states.walk, states.run].has(self.state) && !coyote_hanging:
|
||||||
@ -144,8 +142,6 @@ func _get_transition(_delta):
|
|||||||
coyote_hanging = false
|
coyote_hanging = false
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# TODO How does this apply to enviornment induced movement?
|
|
||||||
# TODO Can get from platform by jumping often while platform has same direction
|
|
||||||
new_state = states.idle
|
new_state = states.idle
|
||||||
coyote_hanging = false
|
coyote_hanging = false
|
||||||
if new_state != self.state:
|
if new_state != self.state:
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
tool
|
tool
|
||||||
extends Area2D
|
extends Area2D
|
||||||
|
|
||||||
|
|
||||||
onready var anim_player: AnimationPlayer = $AnimationPlayer
|
onready var anim_player: AnimationPlayer = $AnimationPlayer
|
||||||
|
|
||||||
export var next_scene: PackedScene
|
export var next_scene: PackedScene
|
||||||
|
|
||||||
|
|
||||||
func _get_configuration_warning() -> String:
|
func _get_configuration_warning() -> String:
|
||||||
return "The next scene property can't be empty" if not next_scene else ""
|
return "The next scene property can't be empty" if not next_scene else ""
|
||||||
|
|
||||||
@ -16,5 +16,5 @@ func teleport() -> void:
|
|||||||
get_tree().change_scene_to(next_scene)
|
get_tree().change_scene_to(next_scene)
|
||||||
|
|
||||||
|
|
||||||
func _on_body_entered(body: Node) -> void:
|
func _on_body_entered(_body: Node) -> void:
|
||||||
teleport()
|
teleport()
|
||||||
|
|||||||
18
src/HarmfulObjects/Bullet.gd
Normal file
18
src/HarmfulObjects/Bullet.gd
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
extends Area2D
|
||||||
|
|
||||||
|
# Declare member variables here. Examples:
|
||||||
|
# var a: int = 2
|
||||||
|
# var b: String = "text"
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
position.x += 30 * delta
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Bullet_body_entered(_body: Node) -> void:
|
||||||
|
queue_free()
|
||||||
23
src/HarmfulObjects/Bullet.tscn
Normal file
23
src/HarmfulObjects/Bullet.tscn
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://assets/environment/blocks/approx build block.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://src/HarmfulObjects/Bullet.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
|
extents = Vector2( 1.51498, 5.05697 )
|
||||||
|
|
||||||
|
[node name="Bullet" type="Area2D" groups=["harmful"]]
|
||||||
|
rotation = 1.5708
|
||||||
|
collision_layer = 64
|
||||||
|
collision_mask = 59
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
|
position = Vector2( -0.00644289, 0.0188824 )
|
||||||
|
scale = Vector2( 0.0919913, 0.313283 )
|
||||||
|
texture = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="." to="." method="_on_Bullet_body_entered"]
|
||||||
@ -1,10 +1,12 @@
|
|||||||
[gd_scene load_steps=10 format=2]
|
[gd_scene load_steps=12 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://src/Actors/Blobby/Blobby.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://src/Actors/Blobby/Blobby.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://assets/environment/blocks/Basic stone block.png" type="Texture" id=2]
|
[ext_resource path="res://assets/environment/blocks/Basic stone block.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://src/Contraptions/Platform/Spring.tscn" type="PackedScene" id=3]
|
[ext_resource path="res://src/Contraptions/Platform/Spring.tscn" type="PackedScene" id=3]
|
||||||
[ext_resource path="res://src/Environment/Background.tscn" type="PackedScene" id=4]
|
[ext_resource path="res://src/Environment/Background.tscn" type="PackedScene" id=4]
|
||||||
[ext_resource path="res://src/Contraptions/Platform/Track.tscn" type="PackedScene" id=5]
|
[ext_resource path="res://src/Contraptions/Platform/Track.tscn" type="PackedScene" id=5]
|
||||||
|
[ext_resource path="res://src/HarmfulObjects/Bullet.tscn" type="PackedScene" id=6]
|
||||||
|
[ext_resource path="res://src/UserInterface/Buttons/UI.tscn" type="PackedScene" id=7]
|
||||||
|
|
||||||
[sub_resource type="NavigationPolygon" id=1]
|
[sub_resource type="NavigationPolygon" id=1]
|
||||||
vertices = PoolVector2Array( 16, 16, 0, 16, 0, 0, 16, 0 )
|
vertices = PoolVector2Array( 16, 16, 0, 16, 0, 0, 16, 0 )
|
||||||
@ -47,6 +49,8 @@ __meta__ = {
|
|||||||
"_edit_vertical_guides_": [ 2880.0 ]
|
"_edit_vertical_guides_": [ 2880.0 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[node name="UserInterface" parent="." instance=ExtResource( 7 )]
|
||||||
|
|
||||||
[node name="Simple Background" parent="." instance=ExtResource( 4 )]
|
[node name="Simple Background" parent="." instance=ExtResource( 4 )]
|
||||||
layer = -1
|
layer = -1
|
||||||
|
|
||||||
@ -67,9 +71,6 @@ position = Vector2( 50.7867, 604.063 )
|
|||||||
position = Vector2( 331.785, 601.665 )
|
position = Vector2( 331.785, 601.665 )
|
||||||
scale = Vector2( 1.88002, 1 )
|
scale = Vector2( 1.88002, 1 )
|
||||||
|
|
||||||
[node name="Spring" parent="Spring4" instance=ExtResource( 3 )]
|
|
||||||
position = Vector2( 206.918, 601.665 )
|
|
||||||
|
|
||||||
[node name="Track" parent="." instance=ExtResource( 5 )]
|
[node name="Track" parent="." instance=ExtResource( 5 )]
|
||||||
position = Vector2( 422.501, 601.665 )
|
position = Vector2( 422.501, 601.665 )
|
||||||
scale = Vector2( 2.83999, 0.56 )
|
scale = Vector2( 2.83999, 0.56 )
|
||||||
@ -77,6 +78,8 @@ scale = Vector2( 2.83999, 0.56 )
|
|||||||
[node name="KinematicBody2D" parent="Track" index="0"]
|
[node name="KinematicBody2D" parent="Track" index="0"]
|
||||||
position = Vector2( 8, 0 )
|
position = Vector2( 8, 0 )
|
||||||
|
|
||||||
|
[node name="Bullet" parent="." instance=ExtResource( 6 )]
|
||||||
|
position = Vector2( 237.856, 601.801 )
|
||||||
|
|
||||||
[editable path="Spring4"]
|
[editable path="Spring4"]
|
||||||
[editable path="Spring4/Spring"]
|
|
||||||
[editable path="Track"]
|
[editable path="Track"]
|
||||||
|
|||||||
7
src/UserInterface/Buttons/UI.tscn
Normal file
7
src/UserInterface/Buttons/UI.tscn
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://src/UserInterface/Buttons/UserInterface.tscn" type="PackedScene" id=1]
|
||||||
|
|
||||||
|
[node name="UserInterface" type="CanvasLayer"]
|
||||||
|
|
||||||
|
[node name="UserInterface" parent="." instance=ExtResource( 1 )]
|
||||||
@ -8,15 +8,19 @@ onready var pause_title: Label = get_node("PauseOverlay/Title")
|
|||||||
|
|
||||||
var paused := false setget set_paused
|
var paused := false setget set_paused
|
||||||
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
PlayerData.connect("score_updated", self, "update_interface")
|
PlayerData.connect("score_updated", self, "update_interface")
|
||||||
PlayerData.connect("player_died", self, "_on_PlayerData_player_died")
|
PlayerData.connect("player_died", self, "_on_PlayerData_player_died")
|
||||||
update_interface()
|
update_interface()
|
||||||
|
|
||||||
|
|
||||||
|
# TODO Main Menu doesnt work when opened from here
|
||||||
func _on_PlayerData_player_died() -> void:
|
func _on_PlayerData_player_died() -> void:
|
||||||
self.paused = true
|
self.paused = true
|
||||||
pause_title.text = "You lost"
|
pause_title.text = "You lost"
|
||||||
|
|
||||||
|
|
||||||
func _unhandled_input(event: InputEvent) -> void:
|
func _unhandled_input(event: InputEvent) -> void:
|
||||||
if event.is_action_pressed("pause") and pause_title.text != "You lost":
|
if event.is_action_pressed("pause") and pause_title.text != "You lost":
|
||||||
#not oder ! schaltet einen boolean um
|
#not oder ! schaltet einen boolean um
|
||||||
@ -24,9 +28,11 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
self.paused = not paused
|
self.paused = not paused
|
||||||
scene_tree.set_input_as_handled()
|
scene_tree.set_input_as_handled()
|
||||||
|
|
||||||
|
|
||||||
func update_interface() -> void:
|
func update_interface() -> void:
|
||||||
score.text = "Score: %s" % PlayerData.score
|
score.text = "Score: %s" % PlayerData.score
|
||||||
|
|
||||||
|
|
||||||
func set_paused(value: bool) -> void:
|
func set_paused(value: bool) -> void:
|
||||||
paused = value
|
paused = value
|
||||||
scene_tree.paused = value
|
scene_tree.paused = value
|
||||||
|
|||||||
@ -49,7 +49,7 @@ margin_top = 84.0
|
|||||||
margin_right = 222.0
|
margin_right = 222.0
|
||||||
margin_bottom = 164.0
|
margin_bottom = 164.0
|
||||||
text = "Main Menu"
|
text = "Main Menu"
|
||||||
next_scene_path = "res://src/Screens/MainScreen.tscn"
|
next_scene_path = "res://src/UserInterface/Screens/MainScreen.tscn"
|
||||||
|
|
||||||
[node name="QuitButton" parent="PauseOverlay/VBoxContainer" instance=ExtResource( 2 )]
|
[node name="QuitButton" parent="PauseOverlay/VBoxContainer" instance=ExtResource( 2 )]
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
@ -76,11 +76,9 @@ __meta__ = {
|
|||||||
[node name="Label" type="Label" parent="."]
|
[node name="Label" type="Label" parent="."]
|
||||||
anchor_left = 1.0
|
anchor_left = 1.0
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
margin_left = -180.0
|
margin_left = -84.0
|
||||||
margin_bottom = 45.0
|
margin_right = -5.0
|
||||||
|
margin_bottom = 24.0
|
||||||
rect_scale = Vector2( 0.590909, 0.627907 )
|
rect_scale = Vector2( 0.590909, 0.627907 )
|
||||||
text = "Score: %s"
|
text = "Score: %s"
|
||||||
align = 2
|
align = 2
|
||||||
__meta__ = {
|
|
||||||
"_edit_use_anchors_": false
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user