diff --git a/src/Actors/Blobby/Blobby.gd b/src/Actors/Blobby/Blobby.gd index b221d1b..f660df7 100644 --- a/src/Actors/Blobby/Blobby.gd +++ b/src/Actors/Blobby/Blobby.gd @@ -155,7 +155,7 @@ func is_correct_airstrafe_input() -> bool: # Calculates the force of the ground friction func calculate_deceleration_force(_gravity: float, mass: float) -> float: - return normal_floor_friction * _gravity * mass + return floor_friction * _gravity * mass func calculate_jump_velocity( @@ -173,7 +173,6 @@ func calculate_jump_velocity( ) if !Input.is_action_pressed("jump"): - # TODO This is so good not gonna lie # Smooth transition from jumping to falling if velocity.y > _gravity * delta * 10: linear_velocity.y += _gravity * delta * 10 @@ -201,7 +200,6 @@ func calculate_fall_velocity( linear_velocity: Vector2, delta: float, direction: Vector2 ) -> Vector2: if velocity.y < max_velocity["fall"]: - # linear_velocity.y += _gravity * delta linear_velocity.y = PhysicsFunc.two_step_euler( linear_velocity.y, _gravity * mass, mass, delta ) @@ -259,7 +257,6 @@ func execute_airstrafe( linear_velocity.y = 0 air_strafe_charges -= 1 return linear_velocity - # TODO Suspend in air func calculate_stomp_velocity( @@ -284,4 +281,9 @@ func die() -> void: # It is particularly usefull for moving floor physics func _on_Blobby_got_grounded() -> void: velocity -= get_floor_velocity() + var floor_object = get_last_slide_collision().collider.get_parent() + if "slide_friction" in floor_object: + floor_friction = floor_object.slide_friction + else: + floor_friction = base_floor_friction air_strafe_charges = 1 diff --git a/src/Actors/Blobby/BlobbyCam.gd b/src/Actors/Blobby/BlobbyCam.gd index e6b113e..0499de9 100644 --- a/src/Actors/Blobby/BlobbyCam.gd +++ b/src/Actors/Blobby/BlobbyCam.gd @@ -7,6 +7,8 @@ var camera_vertical_shift = 90 onready var prev_camera_pos = get_camera_position() onready var tween = $ShiftTween +onready var original_x_zoom = zoom.x +onready var original_y_zoom = zoom.y # Gets the camera limits from the tilemap of the level # Requires "TileMap" to be a sibling of blobby @@ -18,20 +20,28 @@ func _process(_delta: float) -> void: prev_camera_pos = get_camera_position() func _set_boundaries(): - # TODO Pass Reference to child and do not traverse the tree upwards # This is ok, because it only happens on initialization # But it is also quite fickle var tilemap = get_node("../../TileMap") var rect = tilemap.get_used_rect() var cell_size = tilemap.cell_size - # TODO Change camera zoom when level is smaller than camera limit_right = rect.end.x * cell_size.x limit_left = rect.position.x * cell_size.x limit_top = rect.position.y * cell_size.y limit_bottom = rect.end.y * cell_size.y + var screen_size = get_viewport_rect() + var h_pixels = limit_right - limit_left + var v_pixels = limit_bottom - limit_top + if screen_size.end.x * original_x_zoom - h_pixels > 0: + zoom.x = h_pixels / screen_size.end.x + zoom.y = zoom.x + if screen_size.end.y * original_y_zoom - v_pixels > 0: + zoom.y = v_pixels / screen_size.end.y + zoom.x = zoom.y -# TODO Smoothing the camera limits in godot ruins this +# TODO Smoothing the camera limits in godot ruins this still? func _adapt_to_movement(): + # TODO Adapt this to movement speed var target_offset: Vector2 = Vector2(0,0) var tween_v = false var tween_h = false diff --git a/src/Actors/Blobby/BlobbyStateMachine.gd b/src/Actors/Blobby/BlobbyStateMachine.gd index 0c6f1a1..95ad249 100644 --- a/src/Actors/Blobby/BlobbyStateMachine.gd +++ b/src/Actors/Blobby/BlobbyStateMachine.gd @@ -162,7 +162,6 @@ func _enter_state(new_state, old_state): init_boost = true init_boost_type = old_state + "_" + new_state - # TODO This may be hard to keep track of if many states are added if !["run", "walk", "idle"].has(old_state) && parent.is_on_floor(): emit_signal("got_grounded") diff --git a/src/Actors/Player.gd b/src/Actors/Player.gd index fc997a0..64ab18e 100644 --- a/src/Actors/Player.gd +++ b/src/Actors/Player.gd @@ -7,8 +7,8 @@ const FLOOR_NORMAL := Vector2.UP var stomp_feedback := 1000.0 var inair_velocity := 21 var wallslide_threshold := 1000 -# TODO Map to floor types and move to physics constants -var normal_floor_friction := 0.5 +var base_floor_friction := 0.5 +var floor_friction := base_floor_friction var max_velocity := { "walk": 120, "run": 160, "fall": 420, "walljump": 200, "idle": 12000 } diff --git a/src/Contraptions/Platform/FlyingLaserCutter.gd b/src/Contraptions/Platform/FlyingLaserCutter.gd index 268346c..cca90b0 100644 --- a/src/Contraptions/Platform/FlyingLaserCutter.gd +++ b/src/Contraptions/Platform/FlyingLaserCutter.gd @@ -1,12 +1,12 @@ -extends KinematicBody2D +extends Node2D const PhysicsFunc = preload("res://src/Utilities/Physic/PhysicsFunc.gd") #Array of RayCast2D -onready var trigger_rays = $Triggers.get_children() -onready var tween = $Tween -onready var original_position: Vector2 = self.global_position +onready var trigger_rays = $FlyingLaserCutterBody/Triggers.get_children() +onready var tween = $FlyingLaserCutterBody/Tween onready var local_facing: Vector2 = Vector2.RIGHT onready var global_facing: Vector2 = local_facing.rotated(transform.get_rotation()) +onready var slide_friction = 1.5 var flyoff_triggered = false var velocity = 1 @@ -14,12 +14,11 @@ var max_velocity = 200 var acceleration_force = 1200 var mass = 10 -# TODO Returing Laser cutter has broken collision and infinite impulse -# TODO Friction on the laser and other platforms should be higher - +# TODO Returing Laser cutter has broken collision and infinite inertia +# Maybe keep returning paths free and crush player when in the way func _ready() -> void: - $Sprite/AnimationPlayer.play("default") + $FlyingLaserCutterBody/Sprite/AnimationPlayer.play("default") func _physics_process(delta: float) -> void: @@ -28,7 +27,7 @@ func _physics_process(delta: float) -> void: if ray.is_colliding(): var collider = ray.get_collider() if collider.is_in_group("player"): - tween.stop(self) + tween.stop($FlyingLaserCutterBody) set("motion/sync_to_physics", false) flyoff_triggered = true break @@ -37,7 +36,7 @@ func _physics_process(delta: float) -> void: velocity, acceleration_force, mass, delta ) velocity = clamp(velocity, 0, max_velocity) - var collision = move_and_collide(velocity*global_facing*delta,true) + var collision = $FlyingLaserCutterBody.move_and_collide(velocity*global_facing*delta,true) if collision != null: if !collision.collider.is_in_group("player"): _on_collision() @@ -47,11 +46,11 @@ func _on_collision() -> void: velocity = 1 flyoff_triggered = false set("motion/sync_to_physics", true) - var distance: Vector2 = self.global_position - original_position + var distance: Vector2 = $FlyingLaserCutterBody.global_position - self.global_position var time_vec = Vector2(abs(distance.x), abs(distance.y)) / (max_velocity / 3) var time = time_vec.length() tween.interpolate_property( - self, "position", self.global_position, original_position, time + $FlyingLaserCutterBody, "global_position", $FlyingLaserCutterBody.global_position, self.global_position, time ) tween.start() diff --git a/src/Contraptions/Platform/FlyingLaserCutter.tscn b/src/Contraptions/Platform/FlyingLaserCutter.tscn index 33dcb46..b2289e3 100644 --- a/src/Contraptions/Platform/FlyingLaserCutter.tscn +++ b/src/Contraptions/Platform/FlyingLaserCutter.tscn @@ -2,11 +2,11 @@ [ext_resource path="res://src/Contraptions/Platform/FlyingLaserCutter.gd" type="Script" id=1] -[sub_resource type="RectangleShape2D" id=4] -extents = Vector2( 3.30347, 10.9923 ) - [sub_resource type="RectangleShape2D" id=3] -extents = Vector2( 11.9396, 11.9718 ) +extents = Vector2( 11.4921, 11.9129 ) + +[sub_resource type="RectangleShape2D" id=4] +extents = Vector2( 3.06672, 10.9923 ) [sub_resource type="StreamTexture" id=6] load_path = "res://.import/FlyingLaserCutter.png-9cf80385a79c58041216f8c2509a5bab.stex" @@ -27,30 +27,30 @@ tracks/0/keys = { "values": [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0 ] } -[node name="FlyingLaserCutter" type="KinematicBody2D"] -collision_layer = 32 -collision_mask = 123 -collision/safe_margin = 0.001 +[node name="FlyingLaserCutter" type="Node2D"] script = ExtResource( 1 ) -[node name="LaserArea" type="Area2D" parent="." groups=["harmful"]] +[node name="FlyingLaserCutterBody" type="KinematicBody2D" parent="."] +collision_layer = 32 +collision_mask = 56 + +[node name="Tween" type="Tween" parent="FlyingLaserCutterBody"] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="FlyingLaserCutterBody"] +position = Vector2( -0.461158, 0.0588541 ) +shape = SubResource( 3 ) + +[node name="LaserArea" type="Area2D" parent="FlyingLaserCutterBody" groups=["harmful"]] process_priority = -1 collision_layer = 32 collision_mask = 3 -[node name="PainZone" type="CollisionShape2D" parent="LaserArea" groups=["harmful"]] +[node name="PainZone" type="CollisionShape2D" parent="FlyingLaserCutterBody/LaserArea" groups=["harmful"]] process_priority = -1 -position = Vector2( 9.88403, 0.0077219 ) +position = Vector2( 9.64728, 0.0077219 ) shape = SubResource( 4 ) -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -position = Vector2( -0.0136938, 0 ) -shape = SubResource( 3 ) - -[node name="Tween" type="Tween" parent="."] -playback_process_mode = 0 - -[node name="Sprite" type="Sprite" parent="."] +[node name="Sprite" type="Sprite" parent="FlyingLaserCutterBody"] texture = SubResource( 6 ) hframes = 5 vframes = 5 @@ -58,13 +58,13 @@ __meta__ = { "_editor_description_": "YXNlcHJpdGVfd2l6YXJkX2NvbmZpZwpwbGF5ZXJ8PVNwcml0ZS9BbmltYXRpb25QbGF5ZXIKc291cmNlfD1yZXM6Ly9hc3NldHMvY29udHJhcHRpb24vRmx5aW5nTGFzZXJDdXR0ZXIuYXNlcHJpdGUKbGF5ZXJ8PQpvcF9leHB8PUZhbHNlCm9fZm9sZGVyfD0Kb19uYW1lfD0Kb25seV92aXNpYmxlfD1GYWxzZQpvX2V4X3B8PQo=" } -[node name="AnimationPlayer" type="AnimationPlayer" parent="Sprite"] +[node name="AnimationPlayer" type="AnimationPlayer" parent="FlyingLaserCutterBody/Sprite"] anims/default = SubResource( 2 ) -[node name="Triggers" type="Node2D" parent="."] +[node name="Triggers" type="Node2D" parent="FlyingLaserCutterBody"] position = Vector2( 0, 0.0077219 ) -[node name="RayCast2D" type="RayCast2D" parent="Triggers"] +[node name="RayCast2D" type="RayCast2D" parent="FlyingLaserCutterBody/Triggers"] position = Vector2( 3.92072e-12, 8.99337 ) rotation = -1.5708 scale = Vector2( 1, 1000 ) @@ -72,12 +72,10 @@ enabled = true cast_to = Vector2( 0, 1 ) collision_mask = 9 -[node name="RayCast2D2" type="RayCast2D" parent="Triggers"] +[node name="RayCast2D2" type="RayCast2D" parent="FlyingLaserCutterBody/Triggers"] position = Vector2( 0, -8.95621 ) rotation = -1.5708 scale = Vector2( 1, 1000 ) enabled = true cast_to = Vector2( 0, 1 ) collision_mask = 9 - -[connection signal="area_entered" from="LaserArea" to="." method="_on_LaserArea_area_entered"] diff --git a/src/Contraptions/Platform/Spring.gd b/src/Contraptions/Platform/Spring.gd index 429a7c0..9a2e041 100644 --- a/src/Contraptions/Platform/Spring.gd +++ b/src/Contraptions/Platform/Spring.gd @@ -2,9 +2,11 @@ extends Node2D const PhysicsFunc = preload("res://src/Utilities/Physic/PhysicsFunc.gd") const PhysicsConst = preload("res://src/Utilities/Physic/PhysicsConst.gd") +# onready var slide_friction = 0.5 + var mass = 1 var coupled_mass = mass -var spring_k = -600 +var spring_k = -1000 var start_y = 0 var y_velocity = 0 var friction = 0.91 diff --git a/src/Contraptions/Platform/Spring.tscn b/src/Contraptions/Platform/Spring.tscn index ccb5474..32ae85c 100644 --- a/src/Contraptions/Platform/Spring.tscn +++ b/src/Contraptions/Platform/Spring.tscn @@ -4,13 +4,13 @@ [ext_resource path="res://assets/environment/blocks/Basic stone block.png" type="Texture" id=2] [sub_resource type="RectangleShape2D" id=2] -extents = Vector2( 11.6455, 2.10568 ) +extents = Vector2( 11.4863, 2.10568 ) [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 11.918, 1.57982 ) [sub_resource type="RectangleShape2D" id=3] -extents = Vector2( 11.7639, 2.06284 ) +extents = Vector2( 11.9158, 2.06284 ) [node name="Spring" type="Node2D"] script = ExtResource( 1 ) @@ -24,7 +24,7 @@ collision_layer = 32 collision_mask = 3 [node name="CollisionShape2D" type="CollisionShape2D" parent="SpringSkin"] -position = Vector2( 0, -1.27843 ) +position = Vector2( -0.0412841, -1.27843 ) shape = SubResource( 2 ) [node name="SpringBody" type="KinematicBody2D" parent="."] @@ -41,7 +41,7 @@ collision_layer = 32 collision_mask = 41 [node name="CollisionShape2D" type="CollisionShape2D" parent="EnteringVelocityDetector"] -position = Vector2( 0.00390673, -1.07744 ) +position = Vector2( 0.00395775, -1.07744 ) shape = SubResource( 3 ) [connection signal="area_exited" from="SpringSkin" to="." method="_on_SpringSkin_area_exited"] diff --git a/src/Contraptions/Platform/Track.gd b/src/Contraptions/Platform/Track.gd index 2f08bf7..4b178bd 100644 --- a/src/Contraptions/Platform/Track.gd +++ b/src/Contraptions/Platform/Track.gd @@ -1,5 +1,6 @@ extends Node2D +onready var slide_friction = 2 # Declare member variables here. Examples: # var a: int = 2 # var b: String = "text" diff --git a/src/Levels/1Level.tscn b/src/Levels/1Level.tscn index cb25475..db5a8e3 100644 --- a/src/Levels/1Level.tscn +++ b/src/Levels/1Level.tscn @@ -8,7 +8,7 @@ [ext_resource path="res://src/Contraptions/Platform/FlyingLaserCutter.tscn" type="PackedScene" id=6] [sub_resource type="ConvexPolygonShape2D" id=3] -points = PoolVector2Array( 23.7224, 24, 0, 24, 0, 0, 24, 0 ) +points = PoolVector2Array( 0, 0, 24, 0, 24, 24, 0, 24 ) [sub_resource type="TileSet" id=2] 1/name = "24BlockBasic.png 1" @@ -66,14 +66,14 @@ position = Vector2( -166.948, 610.671 ) scale = Vector2( 0.15, 0.15 ) [node name="AnimatedSprite" parent="Collectibles/Coin" index="2"] -frame = 285 +frame = 32 [node name="FlyingLaserCutter3" parent="." instance=ExtResource( 6 )] position = Vector2( -167.267, 632.742 ) rotation = 1.5708 [node name="FlyingLaserCutter4" parent="." instance=ExtResource( 6 )] -position = Vector2( -296.474, 577.769 ) +position = Vector2( -300.48, 729.708 ) [node name="FlyingLaserCutter5" parent="." instance=ExtResource( 6 )] position = Vector2( -14.0224, 527.789 ) diff --git a/src/Levels/Plattforms Level.tscn b/src/Levels/Plattforms Level.tscn index 9cade4e..fb61645 100644 --- a/src/Levels/Plattforms Level.tscn +++ b/src/Levels/Plattforms Level.tscn @@ -61,27 +61,22 @@ cell_custom_transform = Transform2D( 16, 0, 0, 16, 0, 0 ) collision_layer = 8 collision_mask = 2147483648 format = 1 -tile_data = PoolIntArray( 0, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 6, 0, 0, 7, 0, 0, 8, 0, 0, 9, 0, 0, 10, 0, 0, 11, 0, 0, 12, 0, 0, 13, 0, 0, 14, 0, 0, 15, 0, 0, 16, 0, 0, 17, 0, 0, 18, 0, 0, 19, 0, 0, 20, 0, 0, 21, 0, 0, 22, 0, 0, 23, 0, 0, 24, 0, 0, 25, 0, 0, 26, 0, 0, 27, 0, 0, 28, 0, 0, 29, 0, 0, 30, 0, 0, 65536, 0, 0, 65566, 0, 0, 131072, 0, 0, 131102, 0, 0, 196608, 0, 0, 196638, 0, 0, 262144, 0, 0, 262174, 0, 0, 327680, 0, 0, 327710, 0, 0, 393216, 0, 0, 393246, 0, 0, 458752, 0, 0, 458782, 0, 0, 524288, 0, 0, 524318, 0, 0, 589824, 0, 0, 589854, 0, 0, 655360, 0, 0, 655390, 0, 0, 720896, 0, 0, 720926, 0, 0, 786432, 0, 0, 786462, 0, 0, 851968, 0, 0, 851998, 0, 0, 917504, 0, 0, 917534, 0, 0, 983040, 0, 0, 983070, 0, 0, 1048576, 0, 0, 1048606, 0, 0, 1114112, 0, 0, 1114142, 0, 0, 1179648, 0, 0, 1179678, 0, 0, 1245184, 0, 0, 1245214, 0, 0, 1310720, 0, 0, 1310750, 0, 0, 1376256, 0, 0, 1376286, 0, 0, 1441792, 0, 0, 1441822, 0, 0, 1507328, 0, 0, 1507358, 0, 0, 1572864, 0, 0, 1572894, 0, 0, 1638400, 0, 0, 1638430, 0, 0, 1703936, 0, 0, 1703966, 0, 0, 1769472, 0, 0, 1769502, 0, 0, 1835008, 0, 0, 1835038, 0, 0, 1900544, 0, 0, 1900574, 0, 0, 1966080, 0, 0, 1966110, 0, 0, 2031616, 0, 0, 2031646, 0, 0, 2097152, 0, 0, 2097182, 0, 0, 2162688, 0, 0, 2162718, 0, 0, 2228224, 0, 0, 2228254, 0, 0, 2293760, 0, 0, 2293790, 0, 0, 2359296, 0, 0, 2359326, 0, 0, 2424832, 0, 0, 2424862, 0, 0, 2490368, 0, 0, 2490398, 0, 0, 2555904, 0, 0, 2555905, 0, 0, 2555906, 0, 0, 2555907, 0, 0, 2555908, 0, 0, 2555909, 0, 0, 2555910, 0, 0, 2555911, 0, 0, 2555912, 0, 0, 2555913, 0, 0, 2555914, 0, 0, 2555915, 0, 0, 2555916, 0, 0, 2555917, 0, 0, 2555918, 0, 0, 2555919, 0, 0, 2555920, 0, 0, 2555921, 0, 0, 2555922, 0, 0, 2555923, 0, 0, 2555924, 0, 0, 2555925, 0, 0, 2555926, 0, 0, 2555927, 0, 0, 2555928, 0, 0, 2555929, 0, 0, 2555930, 0, 0, 2555931, 0, 0, 2555932, 0, 0, 2555933, 0, 0, 2555934, 0, 0 ) +tile_data = PoolIntArray( 1900544, 0, 0, 1900545, 0, 0, 1900546, 0, 0, 1900547, 0, 0, 1900548, 0, 0, 1900549, 0, 0, 1900550, 0, 0, 1900551, 0, 0, 1900552, 0, 0, 1900553, 0, 0, 1900554, 0, 0, 1900555, 0, 0, 1900556, 0, 0, 1900557, 0, 0, 1900558, 0, 0, 1900559, 0, 0, 1900560, 0, 0, 1900561, 0, 0, 1900562, 0, 0, 1900563, 0, 0, 1900564, 0, 0, 1900565, 0, 0, 1900566, 0, 0, 1900567, 0, 0, 1900568, 0, 0, 1900569, 0, 0, 1966080, 0, 0, 1966105, 0, 0, 2031616, 0, 0, 2031641, 0, 0, 2097152, 0, 0, 2097177, 0, 0, 2162688, 0, 0, 2162713, 0, 0, 2228224, 0, 0, 2228249, 0, 0, 2293760, 0, 0, 2293785, 0, 0, 2359296, 0, 0, 2359321, 0, 0, 2424832, 0, 0, 2424857, 0, 0, 2490368, 0, 0, 2490393, 0, 0, 2555904, 0, 0, 2555905, 0, 0, 2555906, 0, 0, 2555907, 0, 0, 2555908, 0, 0, 2555909, 0, 0, 2555910, 0, 0, 2555911, 0, 0, 2555912, 0, 0, 2555913, 0, 0, 2555914, 0, 0, 2555915, 0, 0, 2555916, 0, 0, 2555917, 0, 0, 2555918, 0, 0, 2555919, 0, 0, 2555920, 0, 0, 2555921, 0, 0, 2555922, 0, 0, 2555923, 0, 0, 2555924, 0, 0, 2555925, 0, 0, 2555926, 0, 0, 2555927, 0, 0, 2555928, 0, 0, 2555929, 0, 0 ) [node name="Blobby" parent="." instance=ExtResource( 1 )] position = Vector2( 50.7867, 604.063 ) -[node name="Spring4" parent="." instance=ExtResource( 3 )] -position = Vector2( 170, 600.198 ) -scale = Vector2( 1.88002, 1 ) - -[node name="CollisionShape2D" parent="Spring4/SpringSkin" index="0"] -position = Vector2( 0, -2.09229 ) - -[node name="CollisionShape2D" parent="Spring4/EnteringVelocityDetector" index="0"] -position = Vector2( 0, -6.14911 ) - [node name="Track" parent="." instance=ExtResource( 5 )] -position = Vector2( 291.104, 535.161 ) +position = Vector2( 34.7867, 501.525 ) scale = Vector2( 2.83999, 0.56 ) [node name="KinematicBody2D" parent="Track" index="0"] position = Vector2( 25.0812, 0 ) -[editable path="Spring4"] +[node name="CollisionShape2D" parent="Track/KinematicBody2D" index="1"] +position = Vector2( -0.00534821, 0.0656128 ) + +[node name="Spring" parent="." instance=ExtResource( 3 )] +position = Vector2( 170, 603.063 ) + [editable path="Track"] diff --git a/src/UserInterface/Buttons/UserInterface.gd b/src/UserInterface/Buttons/UserInterface.gd index f5b9dba..3ac4ed2 100644 --- a/src/UserInterface/Buttons/UserInterface.gd +++ b/src/UserInterface/Buttons/UserInterface.gd @@ -15,7 +15,6 @@ func _ready(): update_interface() -# TODO Main Menu doesnt work when opened from here func _on_PlayerData_player_died() -> void: self.paused = true pause_title.text = "You lost"