Renamed Areas and Bodies, slight restructure, preliminary spring

This commit is contained in:
Jakob Feldmann 2022-05-23 16:19:32 +02:00
parent cb894d1c5d
commit 9c2a01f8a1
16 changed files with 120 additions and 127 deletions

View File

@ -12,7 +12,7 @@ _global_script_classes=[ {
"base": "KinematicBody2D", "base": "KinematicBody2D",
"class": "Player", "class": "Player",
"language": "GDScript", "language": "GDScript",
"path": "res://src/Actors/Player/Player.gd" "path": "res://src/Actors/Player.gd"
}, { }, {
"base": "Line2D", "base": "Line2D",
"class": "RayCastDebugLines", "class": "RayCastDebugLines",

View File

@ -15,14 +15,20 @@ onready var camera = $Camera2D
# TODO Too much speed reduction on landings # TODO Too much speed reduction on landings
# TODO Too much speed through midair boosting # TODO Too much speed through midair boosting
# TODO Mini hopping through jump buffer(rare wallslide) # TODO Mini hopping through jump buffer(rare wallslide)
# TODO Think about how each component and feature would scale in the future
func _on_EnemyDetector_area_entered(area: Area2D) -> void: # TODO This is the worst thing since... you know
_velocity = calculate_stomp_velocity(_velocity, stomp_feedback) # When the Enemy stomp AREA enters the enemy collision area -> stomp
func _on_Skin_area_entered(area: Area2D) -> void:
if area.name == "StompDetector":
velocity = calculate_stomp_velocity(velocity, stomp_feedback)
func _on_EnemyDetector_body_entered(body: Node) -> void: # When the Enemy collision BODY enters the enemy collision area -> die
die() func _on_Skin_body_entered(body: Node) -> void:
if body.name == "EnemyBody":
die()
func _on_JumpBufferTimer_timeout() -> void: func _on_JumpBufferTimer_timeout() -> void:
@ -30,19 +36,19 @@ func _on_JumpBufferTimer_timeout() -> void:
func handle_grounded_movement(delta: float, direction: Vector2) -> Vector2: func handle_grounded_movement(delta: float, direction: Vector2) -> Vector2:
return calculate_grounded_velocity(_velocity, delta, direction) return calculate_grounded_velocity(velocity, delta, direction)
func handle_jump_movement(delta: float, direction: Vector2) -> Vector2: func handle_jump_movement(delta: float, direction: Vector2) -> Vector2:
return calculate_jump_velocity(_velocity, delta, direction) return calculate_jump_velocity(velocity, delta, direction)
func handle_fall_movement(delta: float, direction: Vector2) -> Vector2: func handle_fall_movement(delta: float, direction: Vector2) -> Vector2:
return calculate_fall_velocity(_velocity, delta, direction) return calculate_fall_velocity(velocity, delta, direction)
func handle_wallslide_movement(delta: float, direction: Vector2) -> Vector2: func handle_wallslide_movement(delta: float, direction: Vector2) -> Vector2:
return calculate_wallslide_velocity(_velocity, delta, direction) return calculate_wallslide_velocity(velocity, delta, direction)
func calculate_grounded_velocity( func calculate_grounded_velocity(
@ -51,7 +57,7 @@ func calculate_grounded_velocity(
var state = player_state_machine.state var state = player_state_machine.state
var out_vel := linear_velocity var out_vel := linear_velocity
var velocity_direction = 1.0 var velocity_direction = 1.0
if _velocity.x < 0: if velocity.x < 0:
velocity_direction = -1.0 velocity_direction = -1.0
# Stopping movement # Stopping movement
@ -61,7 +67,7 @@ func calculate_grounded_velocity(
) )
# Translates velocity back to force and subtracts deceleration force # Translates velocity back to force and subtracts deceleration force
var result_force = ( var result_force = (
abs(PhysicsFunc.convert_velocity_to_force(_velocity.x, mass, delta)) abs(PhysicsFunc.convert_velocity_to_force(velocity.x, mass, delta))
- deceleration_force - deceleration_force
) )
if result_force <= 0: if result_force <= 0:
@ -85,7 +91,7 @@ func calculate_grounded_velocity(
* velocity_direction * velocity_direction
) )
# Normal movement # Normal movement
if abs(_velocity.x) < max_velocity[state]: if abs(velocity.x) < max_velocity[state]:
out_vel.x += ( out_vel.x += (
delta delta
* ( * (
@ -106,7 +112,7 @@ func calculate_grounded_velocity(
out_vel.x = max_velocity[state] * direction.x out_vel.x = max_velocity[state] * direction.x
# Jumping when grounded or jump is buffered # Jumping when grounded or jump is buffered
if Input.is_action_just_pressed("jump") || jump_buffer_filled: if Input.is_action_just_pressed("jump") || jump_buffer_filled:
return calculate_jump_velocity(_velocity, delta, direction) return calculate_jump_velocity(velocity, delta, direction)
elif player_state_machine.coyote_hanging: elif player_state_machine.coyote_hanging:
out_vel.y = 0 out_vel.y = 0
@ -119,8 +125,8 @@ func calculate_grounded_velocity(
func is_reversing_horizontal_movement(direction: Vector2) -> bool: func is_reversing_horizontal_movement(direction: Vector2) -> bool:
return ( return (
(direction.x > 0 && _velocity.x < 0) (direction.x > 0 && velocity.x < 0)
|| (direction.x < 0 && _velocity.x >= 0) || (direction.x < 0 && velocity.x >= 0)
) )
@ -179,7 +185,7 @@ func calculate_jump_velocity(
): ):
var additive_jump_force = ( var additive_jump_force = (
velocity_jump_boost_ratio velocity_jump_boost_ratio
* abs(_velocity.x) * abs(velocity.x)
* mass * mass
) )
linear_velocity.y = ( linear_velocity.y = (
@ -195,7 +201,7 @@ func calculate_jump_velocity(
if !Input.is_action_pressed("jump"): if !Input.is_action_pressed("jump"):
# TODO This is so good not gonna lie # TODO This is so good not gonna lie
if _velocity.y > _gravity * delta * 10: if velocity.y > _gravity * delta * 10:
linear_velocity.y += _gravity * delta * 10 linear_velocity.y += _gravity * delta * 10
else: else:
linear_velocity.y += ( linear_velocity.y += (
@ -207,7 +213,7 @@ func calculate_jump_velocity(
linear_velocity.y += _gravity * delta linear_velocity.y += _gravity * delta
# TODO Dis shizzle buggy # TODO Dis shizzle buggy
if _velocity.x == 0: if velocity.x == 0:
linear_velocity.x += inair_velocity * direction.x linear_velocity.x += inair_velocity * direction.x
if is_correct_airstrafe_input() && !walljumping: if is_correct_airstrafe_input() && !walljumping:
@ -222,11 +228,11 @@ func calculate_jump_velocity(
func calculate_fall_velocity( func calculate_fall_velocity(
linear_velocity: Vector2, delta: float, direction: Vector2 linear_velocity: Vector2, delta: float, direction: Vector2
) -> Vector2: ) -> Vector2:
if _velocity.y < max_velocity["fall"]: if velocity.y < max_velocity["fall"]:
linear_velocity.y += _gravity * delta linear_velocity.y += _gravity * delta
else: else:
linear_velocity.y = max_velocity["fall"] linear_velocity.y = max_velocity["fall"]
if _velocity.x == 0: if velocity.x == 0:
# TODO this is weird # TODO this is weird
linear_velocity.x += inair_velocity * direction.x linear_velocity.x += inair_velocity * direction.x
if Input.is_action_just_pressed("jump"): if Input.is_action_just_pressed("jump"):
@ -243,7 +249,7 @@ func calculate_wallslide_velocity(
# Walljump mechanics # Walljump mechanics
if is_correct_walljump_input(direction): if is_correct_walljump_input(direction):
# TODO This +0.01 indicates a larger problem with division through possible 0 values!! # TODO This +0.01 indicates a larger problem with division through possible 0 values!!
var multiplicator = max(min(1, 1000 / (_velocity.y + 0.01)), 0.9) var multiplicator = max(min(1, 1000 / (velocity.y + 0.01)), 0.9)
linear_velocity.y += ( linear_velocity.y += (
(acceleration_force["walljump"].y / mass) (acceleration_force["walljump"].y / mass)
* -1 * -1
@ -264,8 +270,8 @@ func calculate_stomp_velocity(
return out return out
func execute_movement(direction) -> void: func execute_movement() -> void:
_velocity = move_and_slide(_velocity, FLOOR_NORMAL) velocity = move_and_slide(velocity, FLOOR_NORMAL)
func die() -> void: func die() -> void:

View File

@ -1,17 +1,14 @@
[gd_scene load_steps=7 format=2] [gd_scene load_steps=6 format=2]
[ext_resource path="res://assets/blobby/blobby1.png" type="Texture" id=1] [ext_resource path="res://assets/blobby/blobby1.png" type="Texture" id=1]
[ext_resource path="res://src/Actors/Player/PlayerStateMachine.gd" type="Script" id=2] [ext_resource path="res://src/Actors/Blobby/Camera2D.gd" type="Script" id=2]
[ext_resource path="res://assets/meta/new_dynamicfont.tres" type="DynamicFont" id=3] [ext_resource path="res://src/Actors/PlayerStateMachine.gd" type="Script" id=3]
[ext_resource path="res://src/Actors/Player/Blobby.gd" type="Script" id=5] [ext_resource path="res://src/Actors/Blobby/Blobby.gd" type="Script" id=4]
[ext_resource path="res://src/Actors/Player/Camera2D.gd" type="Script" id=6] [ext_resource path="res://assets/meta/new_dynamicfont.tres" type="DynamicFont" id=5]
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 4.60652, 5.57253 )
[node name="Blobby" type="KinematicBody2D"] [node name="Blobby" type="KinematicBody2D"]
collision_mask = 120 collision_mask = 120
script = ExtResource( 5 ) script = ExtResource( 4 )
[node name="Player" type="Sprite" parent="."] [node name="Player" type="Sprite" parent="."]
position = Vector2( -0.00490093, 0.00763269 ) position = Vector2( -0.00490093, 0.00763269 )
@ -20,8 +17,8 @@ texture = ExtResource( 1 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="Player"] [node name="AnimationPlayer" type="AnimationPlayer" parent="Player"]
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] [node name="BlobbyBody" type="CollisionPolygon2D" parent="."]
polygon = PoolVector2Array( -6.76445, -3.27282, -2.676, -7.3, 3.939, -7.3, 7.45577, -2.58186, 7.97746, -1.86331, 8.02357, 4.91157, 4.944, 8.5, -4.213, 8.5, -6.67105, 6.08934 ) 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="."]
position = Vector2( 80, 0 ) position = Vector2( 80, 0 )
@ -38,20 +35,19 @@ drag_margin_right = 0.08
drag_margin_bottom = 0.07 drag_margin_bottom = 0.07
editor_draw_limits = true editor_draw_limits = true
editor_draw_drag_margin = true editor_draw_drag_margin = true
script = ExtResource( 6 ) script = ExtResource( 2 )
[node name="ShiftTween" type="Tween" parent="Camera2D"] [node name="ShiftTween" type="Tween" parent="Camera2D"]
[node name="EnemyDetector" type="Area2D" parent="."] [node name="Skin" type="Area2D" parent="."]
collision_mask = 2 collision_mask = 126
monitorable = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="EnemyDetector"] [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Skin"]
modulate = Color( 0.2, 0, 0.494118, 1 ) scale = Vector2( 1.03, 1.03 )
shape = SubResource( 2 ) polygon = PoolVector2Array( -6.7, -3.311, -2.676, -7.3, 3.939, -7.3, 8, -1.863, 8, 4.912, 4.944, 8.5, -1.03623, 8.5, -4.213, 8.5, -6.7, 6.089 )
[node name="PlayerStateMachine" type="Node" parent="."] [node name="PlayerStateMachine" type="Node" parent="."]
script = ExtResource( 2 ) script = ExtResource( 3 )
[node name="JumpBufferTimer" type="Timer" parent="PlayerStateMachine"] [node name="JumpBufferTimer" type="Timer" parent="PlayerStateMachine"]
wait_time = 0.034 wait_time = 0.034
@ -67,7 +63,7 @@ margin_top = -34.2836
margin_right = 25.6614 margin_right = 25.6614
margin_bottom = -20.2836 margin_bottom = -20.2836
custom_colors/font_color = Color( 0, 0, 0, 1 ) custom_colors/font_color = Color( 0, 0, 0, 1 )
custom_fonts/font = ExtResource( 3 ) custom_fonts/font = ExtResource( 5 )
text = "Ihre Werbung" text = "Ihre Werbung"
align = 1 align = 1
valign = 1 valign = 1
@ -75,7 +71,7 @@ valign = 1
[node name="WallRaycasts" type="Node2D" parent="."] [node name="WallRaycasts" type="Node2D" parent="."]
[node name="LeftWallRaycast" type="Node2D" parent="WallRaycasts"] [node name="LeftWallRaycast" type="Node2D" parent="WallRaycasts"]
position = Vector2( 3.95827, 5.64054 ) position = Vector2( 3.86988, 6.34765 )
[node name="Left_Wallcast1" type="RayCast2D" parent="WallRaycasts/LeftWallRaycast"] [node name="Left_Wallcast1" type="RayCast2D" parent="WallRaycasts/LeftWallRaycast"]
position = Vector2( -10.706, -8.03844 ) position = Vector2( -10.706, -8.03844 )
@ -103,6 +99,6 @@ enabled = true
cast_to = Vector2( 2, 0 ) cast_to = Vector2( 2, 0 )
collision_mask = 9 collision_mask = 9
[connection signal="area_entered" from="EnemyDetector" to="." method="_on_EnemyDetector_area_entered"] [connection signal="area_entered" from="Skin" to="." method="_on_Skin_area_entered"]
[connection signal="body_entered" from="EnemyDetector" to="." method="_on_EnemyDetector_body_entered"] [connection signal="body_entered" from="Skin" to="." method="_on_Skin_body_entered"]
[connection signal="timeout" from="PlayerStateMachine/JumpBufferTimer" to="." method="_on_JumpBufferTimer_timeout"] [connection signal="timeout" from="PlayerStateMachine/JumpBufferTimer" to="." method="_on_JumpBufferTimer_timeout"]

View File

@ -5,21 +5,21 @@ export var score := 100
func _ready() -> void: func _ready() -> void:
set_physics_process(false) set_physics_process(false)
_velocity.x = -300 velocity.x = -30
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("CollisionShape2D").disabled = true get_node("EnemyShape").disabled = true
die() die()
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
_velocity.y += _gravity * delta velocity.y += _gravity * delta
if is_on_wall(): if is_on_wall():
_velocity.x *= -1.0 velocity.x *= -1.0
_velocity.y = move_and_slide(_velocity, FLOOR_NORMAL).y velocity.y = move_and_slide(velocity, FLOOR_NORMAL).y
func die() -> void: func die() -> void:

View File

@ -4,10 +4,10 @@
[ext_resource path="res://src/Actors/Enemy/Enemy.gd" type="Script" id=2] [ext_resource path="res://src/Actors/Enemy/Enemy.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1] [sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 8.68243, 5.8581 ) extents = Vector2( 2.72463, 1.17848 )
[sub_resource type="RectangleShape2D" id=2] [sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 45, 14 ) extents = Vector2( 15.4794, 6.68174 )
[node name="Enemy" type="KinematicBody2D"] [node name="Enemy" type="KinematicBody2D"]
collision_layer = 2 collision_layer = 2
@ -15,28 +15,29 @@ collision_mask = 9
script = ExtResource( 2 ) script = ExtResource( 2 )
[node name="enemy" type="Sprite" parent="."] [node name="enemy" type="Sprite" parent="."]
position = Vector2( 0, -48 ) position = Vector2( 0, -1.90735e-06 )
scale = Vector2( 0.286789, 0.276348 )
texture = ExtResource( 1 ) texture = ExtResource( 1 )
[node name="VisibilityEnabler2D" type="VisibilityEnabler2D" parent="."] [node name="VisibilityEnabler2D" type="VisibilityEnabler2D" parent="."]
position = Vector2( 3895.22, -31 ) position = Vector2( 1362.81, -0.138177 )
scale = Vector2( 44.2501, 3.1 ) scale = Vector2( 15.4865, 1.28502 )
rect = Rect2( -89, -10, 2, 20 ) rect = Rect2( -89, -10, 2, 20 )
process_parent = true process_parent = true
physics_process_parent = true physics_process_parent = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="EnemyBody" type="CollisionShape2D" parent="."]
position = Vector2( -0.445457, -31.2227 ) 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="."]
modulate = Color( 0, 0.0392157, 1, 1 ) modulate = Color( 0, 0.0392157, 1, 1 )
position = Vector2( 0, -62 ) position = Vector2( 0, -6.44095 )
collision_layer = 2 collision_layer = 2
input_pickable = false
[node name="CollisionShape2D2" type="CollisionShape2D" parent="StompDetector"] [node name="CollisionShape2D" type="CollisionShape2D" parent="StompDetector"]
position = Vector2( 0.44545, -13 )
shape = SubResource( 2 ) shape = SubResource( 2 )
[connection signal="body_entered" from="StompDetector" to="." method="_on_StompDetector_body_entered"] [connection signal="body_entered" from="StompDetector" to="." method="_on_StompDetector_body_entered"]

View File

@ -28,6 +28,6 @@ var _gravity: float = PhysicsConst.gravity
# Kilograms # Kilograms
var mass := 6.5 var mass := 6.5
var _velocity := Vector2.ZERO var velocity := Vector2.ZERO
var air_strafe_charges := 1 var air_strafe_charges := 1

View File

@ -50,8 +50,8 @@ func _state_logic(delta):
var direction = get_horizontal_direction() var direction = get_horizontal_direction()
parent._velocity = handle_input_ref.call_func(delta, direction) parent.velocity = handle_input_ref.call_func(delta, direction)
parent.execute_movement(direction) parent.execute_movement()
func handle_idle_input(delta, direction) -> Vector2: func handle_idle_input(delta, direction) -> Vector2:
@ -102,18 +102,18 @@ func _get_transition(delta):
parent.get_node("StateLabel").text = ( parent.get_node("StateLabel").text = (
self.state self.state
+ " x vel:" + " x vel:"
+ String(round(parent._velocity.x)) + String(round(parent.velocity.x))
) )
var new_state var new_state
if !parent.is_on_floor(): if !parent.is_on_floor():
if parent._velocity.y < 0: if parent.velocity.y < 0:
new_state = states.jump new_state = states.jump
if parent._velocity.y >= 0: if parent.velocity.y >= 0:
new_state = states.fall new_state = states.fall
if ( if (
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 Wallslide might be too long
# TODO Player is stuck to the wall # TODO Player is stuck to the wall
@ -134,7 +134,7 @@ func _get_transition(delta):
if coyote_hanging: if coyote_hanging:
new_state = self.state new_state = self.state
elif parent._velocity.x != 0: elif parent.velocity.x != 0:
if Input.is_action_pressed("boost_move"): if Input.is_action_pressed("boost_move"):
new_state = states.run new_state = states.run
else: else:

View File

@ -30,3 +30,14 @@ func _physics_process(delta: float) -> void:
y_velocity *= friction y_velocity *= friction
self.position.y += y_velocity * delta self.position.y += y_velocity * delta
func _on_Area2D_area_entered(area: Area2D) -> void:
var area_parent = area.get_parent()
var a_velocity = area_parent.velocity.y
var a_mass = area_parent.mass
var b_velocity = y_velocity
var b_mass = mass
y_velocity += PhysicsFunc.complete_unelastic_shock(
a_velocity, b_velocity, a_mass, b_mass
)

View File

@ -1,10 +1,13 @@
[gd_scene load_steps=4 format=2] [gd_scene load_steps=5 format=2]
[ext_resource path="res://src/Contraptions/Platform/Spring.gd" type="Script" id=1] [ext_resource path="res://src/Contraptions/Platform/Spring.gd" type="Script" 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]
[sub_resource type="RectangleShape2D" id=1] [sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 11.8807, 1.59654 ) extents = Vector2( 11.913, 1.58343 )
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 11.8988, 1.56963 )
[node name="Spring" type="Node2D"] [node name="Spring" type="Node2D"]
script = ExtResource( 1 ) script = ExtResource( 1 )
@ -14,11 +17,22 @@ collision_layer = 32
collision_mask = 41 collision_mask = 41
[node name="Sprite" type="Sprite" parent="StaticBody2D"] [node name="Sprite" type="Sprite" parent="StaticBody2D"]
position = Vector2( -7.80793, -0.67961 ) position = Vector2( -11.9516, -1.58488 )
scale = Vector2( 1.48986, 0.197785 ) scale = Vector2( 1.48986, 0.197785 )
texture = ExtResource( 2 ) texture = ExtResource( 2 )
centered = false centered = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"] [node name="SpringBody" type="CollisionShape2D" parent="StaticBody2D"]
position = Vector2( 4.1428, 0.903461 ) position = Vector2( -0.0323062, -0.0131137 )
shape = SubResource( 1 ) shape = SubResource( 1 )
[node name="Spring" type="Area2D" parent="StaticBody2D"]
position = Vector2( -0.0323062, -0.0131137 )
collision_layer = 32
collision_mask = 3
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D/Spring"]
position = Vector2( 0.0323062, 0.0137925 )
shape = SubResource( 2 )
[connection signal="area_entered" from="StaticBody2D/Spring" to="." method="_on_Area2D_area_entered"]

View File

@ -1,6 +1,6 @@
[gd_scene load_steps=8 format=2] [gd_scene load_steps=8 format=2]
[ext_resource path="res://src/Actors/Player/Blobby.tscn" type="PackedScene" id=1] [ext_resource path="res://src/Actors/Blobby/Blobby.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/meta/tileset.png" type="Texture" id=2] [ext_resource path="res://assets/meta/tileset.png" type="Texture" id=2]
[ext_resource path="res://src/Actors/Enemy/Enemy.tscn" type="PackedScene" id=3] [ext_resource path="res://src/Actors/Enemy/Enemy.tscn" type="PackedScene" id=3]
[ext_resource path="res://assets/environment/background/background.png" type="Texture" id=4] [ext_resource path="res://assets/environment/background/background.png" type="Texture" id=4]

View File

@ -1,6 +1,6 @@
[gd_scene load_steps=8 format=2] [gd_scene load_steps=8 format=2]
[ext_resource path="res://src/Actors/Player/Blobby.tscn" type="PackedScene" id=1] [ext_resource path="res://src/Actors/Blobby/Blobby.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/meta/tileset.tres" type="TileSet" id=2] [ext_resource path="res://assets/meta/tileset.tres" type="TileSet" id=2]
[ext_resource path="res://src/Actors/Enemy/Enemy.tscn" type="PackedScene" id=3] [ext_resource path="res://src/Actors/Enemy/Enemy.tscn" type="PackedScene" id=3]
[ext_resource path="res://assets/environment/background/background.png" type="Texture" id=4] [ext_resource path="res://assets/environment/background/background.png" type="Texture" id=4]
@ -34,38 +34,13 @@ format = 1
tile_data = PoolIntArray( -1048576, 0, 0, -1048564, 0, 0, -983040, 0, 0, -983028, 0, 0, -917504, 0, 0, -917492, 0, 0, -851968, 0, 0, -851956, 0, 0, -786432, 0, 0, -786420, 0, 0, -720896, 0, 0, -720884, 0, 0, -655360, 0, 0, -655348, 0, 0, -589824, 0, 0, -589812, 0, 0, -524288, 0, 0, -524276, 0, 0, -458752, 0, 0, -458740, 0, 0, -393216, 0, 0, -393215, 0, 0, -393214, 0, 0, -393213, 0, 0, -393204, 0, 0, -327680, 0, 0, -327668, 0, 0, -262144, 0, 0, -262132, 0, 0, -196608, 0, 0, -196607, 0, 0, -196606, 0, 0, -196605, 0, 0, -196596, 0, 0, -131072, 0, 0, -131060, 0, 0, -65536, 0, 0, -65524, 0, 0, 0, 0, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 12, 0, 0, 65536, 0, 0, 65544, 0, 0, 65548, 0, 0, 131072, 0, 0, 131084, 0, 0, 196608, 0, 0, 196620, 0, 0, 262144, 0, 0, 262149, 0, 0, 262154, 0, 0, 262155, 0, 0, 262156, 0, 0, 327680, 0, 0, 327681, 0, 0, 327692, 0, 0, 393216, 0, 0, 393228, 0, 0, 458752, 0, 0, 458753, 0, 0, 458754, 0, 0, 458755, 0, 0, 458756, 0, 0, 458757, 0, 0, 458758, 0, 0, 458759, 0, 0, 458760, 0, 0, 458761, 0, 0, 458762, 0, 0, 458763, 0, 0, 458764, 0, 0, 524288, 0, 0, 524289, 0, 0, 524290, 0, 0, 524291, 0, 0, 524292, 0, 0, 524293, 0, 0, 524294, 0, 0, 524295, 0, 0, 524296, 0, 0, 524297, 0, 0, 524298, 0, 0, 524299, 0, 0, 524300, 0, 0, 589824, 0, 0, 589825, 0, 0, 589826, 0, 0, 589827, 0, 0, 589828, 0, 0, 589829, 0, 0, 589830, 0, 0, 589831, 0, 0, 589832, 0, 0, 589833, 0, 0, 589834, 0, 0, 589835, 0, 0, 589836, 0, 0 ) tile_data = PoolIntArray( -1048576, 0, 0, -1048564, 0, 0, -983040, 0, 0, -983028, 0, 0, -917504, 0, 0, -917492, 0, 0, -851968, 0, 0, -851956, 0, 0, -786432, 0, 0, -786420, 0, 0, -720896, 0, 0, -720884, 0, 0, -655360, 0, 0, -655348, 0, 0, -589824, 0, 0, -589812, 0, 0, -524288, 0, 0, -524276, 0, 0, -458752, 0, 0, -458740, 0, 0, -393216, 0, 0, -393215, 0, 0, -393214, 0, 0, -393213, 0, 0, -393204, 0, 0, -327680, 0, 0, -327668, 0, 0, -262144, 0, 0, -262132, 0, 0, -196608, 0, 0, -196607, 0, 0, -196606, 0, 0, -196605, 0, 0, -196596, 0, 0, -131072, 0, 0, -131060, 0, 0, -65536, 0, 0, -65524, 0, 0, 0, 0, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 12, 0, 0, 65536, 0, 0, 65544, 0, 0, 65548, 0, 0, 131072, 0, 0, 131084, 0, 0, 196608, 0, 0, 196620, 0, 0, 262144, 0, 0, 262149, 0, 0, 262154, 0, 0, 262155, 0, 0, 262156, 0, 0, 327680, 0, 0, 327681, 0, 0, 327692, 0, 0, 393216, 0, 0, 393228, 0, 0, 458752, 0, 0, 458753, 0, 0, 458754, 0, 0, 458755, 0, 0, 458756, 0, 0, 458757, 0, 0, 458758, 0, 0, 458759, 0, 0, 458760, 0, 0, 458761, 0, 0, 458762, 0, 0, 458763, 0, 0, 458764, 0, 0, 524288, 0, 0, 524289, 0, 0, 524290, 0, 0, 524291, 0, 0, 524292, 0, 0, 524293, 0, 0, 524294, 0, 0, 524295, 0, 0, 524296, 0, 0, 524297, 0, 0, 524298, 0, 0, 524299, 0, 0, 524300, 0, 0, 589824, 0, 0, 589825, 0, 0, 589826, 0, 0, 589827, 0, 0, 589828, 0, 0, 589829, 0, 0, 589830, 0, 0, 589831, 0, 0, 589832, 0, 0, 589833, 0, 0, 589834, 0, 0, 589835, 0, 0, 589836, 0, 0 )
[node name="Blobby" parent="." instance=ExtResource( 1 )] [node name="Blobby" parent="." instance=ExtResource( 1 )]
position = Vector2( 131, 560 ) position = Vector2( 156.988, 538.998 )
[node name="Player" parent="Blobby" index="0"]
position = Vector2( -0.476822, -29.8424 )
[node name="CollisionPolygon2D" parent="Blobby" index="1"]
position = Vector2( -1.16798, -29.1162 )
[node name="Camera2D" parent="Blobby" index="2"]
position = Vector2( 390.714, -75 )
limit_top = -10000
limit_right = 1040
limit_bottom = 700
drag_margin_h_enabled = false
[node name="EnemyDetector" parent="Blobby" index="3"]
position = Vector2( 14.6832, -44.0497 )
[node name="CollisionShape2D" parent="Blobby/EnemyDetector" index="0"]
position = Vector2( -15.3507, 14.3845 )
[node name="StateLabel" parent="Blobby" index="5"]
margin_left = -38.6708
margin_top = -73.3364
margin_right = 48.3292
margin_bottom = -59.3364
[node name="WallRaycasts" parent="Blobby" index="6"]
position = Vector2( -0.589935, -29.85 )
[node name="Enemy" parent="." instance=ExtResource( 3 )] [node name="Enemy" parent="." instance=ExtResource( 3 )]
position = Vector2( 715.5, 560 ) position = Vector2( 718.871, 527.037 )
[node name="VisibilityEnabler2D" parent="Enemy" index="1"]
position = Vector2( 1363.25, -11.7006 )
[node name="Coin" parent="." instance=ExtResource( 5 )] [node name="Coin" parent="." instance=ExtResource( 5 )]
position = Vector2( 592, 352 ) position = Vector2( 592, 352 )
@ -82,5 +57,5 @@ position = Vector2( 749, 274 )
[node name="Portal" parent="." instance=ExtResource( 8 )] [node name="Portal" parent="." instance=ExtResource( 8 )]
position = Vector2( 130.332, -461.479 ) position = Vector2( 130.332, -461.479 )
[editable path="Blobby"] [editable path="Enemy"]
[editable path="Coin"] [editable path="Coin"]

View File

@ -1,6 +1,6 @@
[gd_scene load_steps=13 format=2] [gd_scene load_steps=13 format=2]
[ext_resource path="res://src/Actors/Player/Blobby.tscn" type="PackedScene" id=1] [ext_resource path="res://src/Actors/Blobby/Blobby.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/meta/tileset.png" type="Texture" id=2] [ext_resource path="res://assets/meta/tileset.png" type="Texture" id=2]
[ext_resource path="res://src/Actors/Enemy/Enemy.tscn" type="PackedScene" id=3] [ext_resource path="res://src/Actors/Enemy/Enemy.tscn" type="PackedScene" id=3]
[ext_resource path="res://assets/environment/background/background.png" type="Texture" id=4] [ext_resource path="res://assets/environment/background/background.png" type="Texture" id=4]

View File

@ -1,6 +1,6 @@
[gd_scene load_steps=10 format=2] [gd_scene load_steps=9 format=2]
[ext_resource path="res://src/Actors/Player/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]
@ -40,9 +40,6 @@ points = PoolVector2Array( 16, 16, 0, 16, 0, 0, 16, 0 )
} ] } ]
0/z_index = 0 0/z_index = 0
[sub_resource type="RectangleShape2D" id=5]
extents = Vector2( 8, 8 )
[node name="LevelTemplate" type="Node2D"] [node name="LevelTemplate" type="Node2D"]
__meta__ = { __meta__ = {
"_edit_horizontal_guides_": [ 464.0 ], "_edit_horizontal_guides_": [ 464.0 ],
@ -67,16 +64,3 @@ position = Vector2( 206.918, 601.665 )
[node name="Blobby" parent="." instance=ExtResource( 1 )] [node name="Blobby" parent="." instance=ExtResource( 1 )]
position = Vector2( 50.7867, 604.063 ) position = Vector2( 50.7867, 604.063 )
[node name="RigidBody2D" type="RigidBody2D" parent="."]
position = Vector2( -104.184, -29.293 )
collision_layer = 64
collision_mask = 8
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
position = Vector2( 130.787, 601.665 )
shape = SubResource( 5 )
[node name="Sprite" type="Sprite" parent="RigidBody2D/CollisionShape2D"]
position = Vector2( 0, -0.000244141 )
texture = ExtResource( 2 )

View File

@ -1,6 +1,6 @@
[gd_scene load_steps=10 format=2] [gd_scene load_steps=10 format=2]
[ext_resource path="res://src/Actors/Player/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/Track.tscn" type="PackedScene" id=3] [ext_resource path="res://src/Contraptions/Platform/Track.tscn" type="PackedScene" id=3]
[ext_resource path="res://assets/environment/background/background.png" type="Texture" id=4] [ext_resource path="res://assets/environment/background/background.png" type="Texture" id=4]

View File

@ -4,3 +4,9 @@ static func convert_velocity_to_force(velocity, mass, delta) -> float:
static func convert_force_to_velocity(force, mass, delta) -> float: static func convert_force_to_velocity(force, mass, delta) -> float:
return (force / mass) * delta return (force / mass) * delta
static func complete_unelastic_shock(
v1: float, v2: float, m1: float, m2: float
) -> float:
return (m1 * v1 + m2 * v2) / (m1 + m2)