diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..da9c9ec --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,18 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "GDScript Godot", + "type": "godot", + "request": "launch", + "project": "C:\\Users\\jakob\\Documents\\Godot\\Wumper", + "port": 6007, + "address": "127.0.0.1", + "launch_game_instance": true, + "launch_scene": false + } + ] +} \ No newline at end of file diff --git a/project.godot b/project.godot index 72b3442..0073310 100644 --- a/project.godot +++ b/project.godot @@ -12,7 +12,7 @@ _global_script_classes=[ { "base": "KinematicBody2D", "class": "Player", "language": "GDScript", -"path": "res://src/Actor/Player.gd" +"path": "res://src/Actors/Player/Player.gd" }, { "base": "Line2D", "class": "RayCastDebugLines", @@ -99,9 +99,17 @@ boost_move={ 2d_physics/layer_2="enemies" 2d_physics/layer_3="coins" 2d_physics/layer_4="world" +2d_physics/layer_5="platforms" +2d_physics/layer_6="contraption" +2d_physics/layer_7="finnemajig" + +[physics] + +2d/cell_size=100 [rendering] +2d/options/use_nvidia_rect_flicker_workaround=true quality/intended_usage/framebuffer_allocation=0 quality/intended_usage/framebuffer_allocation.mobile=0 2d/snapping/use_gpu_pixel_snap=true diff --git a/src/Actor/Enemy.gd b/src/Actors/Enemy/Enemy.gd similarity index 100% rename from src/Actor/Enemy.gd rename to src/Actors/Enemy/Enemy.gd diff --git a/src/Actor/Enemy.tscn b/src/Actors/Enemy/Enemy.tscn similarity index 94% rename from src/Actor/Enemy.tscn rename to src/Actors/Enemy/Enemy.tscn index b91f55b..bdad37d 100644 --- a/src/Actor/Enemy.tscn +++ b/src/Actors/Enemy/Enemy.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=5 format=2] [ext_resource path="res://assets/enemy/enemy.png" type="Texture" id=1] -[ext_resource path="res://src/Actor/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] extents = Vector2( 8.68243, 5.8581 ) diff --git a/src/Actor/Turret.tscn b/src/Actors/Enemy/Turret.tscn similarity index 100% rename from src/Actor/Turret.tscn rename to src/Actors/Enemy/Turret.tscn diff --git a/src/Actor/Blobby.gd b/src/Actors/Player/Blobby.gd similarity index 89% rename from src/Actor/Blobby.gd rename to src/Actors/Player/Blobby.gd index 62b8f40..87568ab 100644 --- a/src/Actor/Blobby.gd +++ b/src/Actors/Player/Blobby.gd @@ -1,5 +1,5 @@ extends Player - +const PhysicsFunc = preload("res://src/Utilities/Physic/PhysicsFunc.gd") export var jump_buffer_filled := false onready var wall_touch_direction = 0 onready var left_wall_raycasts = $WallRaycasts/LeftWallRaycast @@ -15,7 +15,6 @@ onready var camera = $Camera2D # TODO Too much speed reduction on landings # TODO Too much speed through midair boosting # TODO Mini hopping through jump buffer(rare wallslide) -# TODO func _on_EnemyDetector_area_entered(area: Area2D) -> void: @@ -62,14 +61,14 @@ func calculate_grounded_velocity( ) # Translates velocity back to force and subtracts deceleration force var result_force = ( - abs(convert_velocity_to_force(_velocity.x, mass, delta)) + abs(PhysicsFunc.convert_velocity_to_force(_velocity.x, mass, delta)) - deceleration_force ) if result_force <= 0: out_vel.x = 0 else: out_vel.x = ( - convert_force_to_velocity(result_force, mass, delta) + PhysicsFunc.convert_force_to_velocity(result_force, mass, delta) * velocity_direction ) else: @@ -78,7 +77,7 @@ func calculate_grounded_velocity( var reverse_move = is_reversing_horizontal_movement(direction) if reverse_move: out_vel.x -= ( - convert_force_to_velocity( + PhysicsFunc.convert_force_to_velocity( calculate_deceleration_force(_gravity, mass, delta), mass, delta @@ -103,7 +102,7 @@ func calculate_grounded_velocity( * direction.x ) ) - elif ! reverse_move: + elif !reverse_move: out_vel.x = max_velocity[state] * direction.x # Jumping when grounded or jump is buffered if Input.is_action_just_pressed("jump") || jump_buffer_filled: @@ -132,10 +131,10 @@ func is_reversing_horizontal_movement(direction: Vector2) -> bool: func is_touching_wall_completely() -> bool: for left_raycast in left_wall_raycasts.get_children(): wall_touch_direction = -1 - if ! left_raycast.is_colliding(): + if !left_raycast.is_colliding(): for right_raycast in right_wall_raycasts.get_children(): wall_touch_direction = 1 - if ! right_raycast.is_colliding(): + if !right_raycast.is_colliding(): wall_touch_direction = 0 return false return true @@ -161,16 +160,10 @@ func is_correct_airstrafe_input() -> bool: ) -func convert_velocity_to_force(velocity, mass, delta) -> float: - return (velocity * mass) / delta - - -func convert_force_to_velocity(force, mass, delta) -> float: - return (force / mass) * delta - - # TODO Comments for parameters -func calculate_deceleration_force(_gravity: float, mass: float, delta: float) -> float: +func calculate_deceleration_force( + _gravity: float, mass: float, delta: float +) -> float: return normal_floor_friction * _gravity * mass * delta @@ -195,12 +188,12 @@ func calculate_jump_velocity( ) # TODO Das eskaliert ab und an komplett - if walljumping && ! is_on_floor(): + if walljumping && !is_on_floor(): # The faster you are moving up the farther the walljump goes linear_velocity.y = (acceleration_force["walljump"].y / mass) * -1 linear_velocity.x += acceleration_force["walljump"].x * direction.x - if ! Input.is_action_pressed("jump"): + if !Input.is_action_pressed("jump"): # TODO This is so good not gonna lie if _velocity.y > _gravity * delta * 10: linear_velocity.y += _gravity * delta * 10 @@ -217,7 +210,7 @@ func calculate_jump_velocity( if _velocity.x == 0: linear_velocity.x += inair_velocity * direction.x - if is_correct_airstrafe_input() && ! walljumping: + if is_correct_airstrafe_input() && !walljumping: linear_velocity.x += (direction.x * acceleration_force["air_strafe"].x) air_strafe_charges -= 1 @@ -263,7 +256,9 @@ func calculate_wallslide_velocity( return linear_velocity -func calculate_stomp_velocity(linear_velocity: Vector2, impulse: float) -> Vector2: +func calculate_stomp_velocity( + linear_velocity: Vector2, impulse: float +) -> Vector2: var out := linear_velocity out.y = -impulse return out @@ -271,7 +266,6 @@ func calculate_stomp_velocity(linear_velocity: Vector2, impulse: float) -> Vecto func execute_movement(direction) -> void: _velocity = move_and_slide(_velocity, FLOOR_NORMAL) - # TODO Replace .get_nodes with $ and put them to file beginning if possible func die() -> void: diff --git a/src/Actor/Blobby.tscn b/src/Actors/Player/Blobby.tscn similarity index 82% rename from src/Actor/Blobby.tscn rename to src/Actors/Player/Blobby.tscn index d7dabee..b905091 100644 --- a/src/Actor/Blobby.tscn +++ b/src/Actors/Player/Blobby.tscn @@ -1,15 +1,16 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://assets/blobby/blobby1.png" type="Texture" id=1] -[ext_resource path="res://src/Actor/PlayerStateMachine.gd" type="Script" id=2] -[ext_resource path="res://src/Actor/Blobby.gd" type="Script" id=5] -[ext_resource path="res://src/Actor/Camera2D.gd" type="Script" id=6] +[ext_resource path="res://src/Actors/Player/PlayerStateMachine.gd" type="Script" id=2] +[ext_resource path="res://assets/meta/new_dynamicfont.tres" type="DynamicFont" id=3] +[ext_resource path="res://src/Actors/Player/Blobby.gd" type="Script" id=5] +[ext_resource path="res://src/Actors/Player/Camera2D.gd" type="Script" id=6] [sub_resource type="RectangleShape2D" id=2] -extents = Vector2( 11.2458, 19.4685 ) +extents = Vector2( 4.60652, 5.57253 ) [node name="Blobby" type="KinematicBody2D"] -collision_mask = 8 +collision_mask = 120 script = ExtResource( 5 ) [node name="Player" type="Sprite" parent="."] @@ -20,7 +21,7 @@ texture = ExtResource( 1 ) [node name="AnimationPlayer" type="AnimationPlayer" parent="Player"] [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] -polygon = PoolVector2Array( -6.76445, -3.27282, -2.66045, -7.27159, 3.75863, -7.44698, 7.45577, -2.58186, 7.97746, -1.86331, 7.99487, 8.61092, 4.14448, 8.72349, -3.67768, 8.75857, -6.62144, 8.69444 ) +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 ) [node name="Camera2D" type="Camera2D" parent="."] position = Vector2( 80, 0 ) @@ -66,6 +67,7 @@ margin_top = -34.2836 margin_right = 25.6614 margin_bottom = -20.2836 custom_colors/font_color = Color( 0, 0, 0, 1 ) +custom_fonts/font = ExtResource( 3 ) text = "Ihre Werbung" align = 1 valign = 1 diff --git a/src/Actor/Camera2D.gd b/src/Actors/Player/Camera2D.gd similarity index 100% rename from src/Actor/Camera2D.gd rename to src/Actors/Player/Camera2D.gd diff --git a/src/Actor/Player.gd b/src/Actors/Player/Player.gd similarity index 86% rename from src/Actor/Player.gd rename to src/Actors/Player/Player.gd index 79395b0..754dcce 100644 --- a/src/Actor/Player.gd +++ b/src/Actors/Player/Player.gd @@ -1,5 +1,6 @@ extends KinematicBody2D class_name Player +const PhysicsConst = preload("res://src/Utilities/Physic/PhysicsConst.gd") const FLOOR_NORMAL := Vector2.UP @@ -23,7 +24,7 @@ var acceleration_force := { "walljump": Vector2(130, 1800), "air_strafe": Vector2(60, 0) } -var _gravity := 1111.0 +var _gravity: float = PhysicsConst.gravity # Kilograms var mass := 6.5 diff --git a/src/Actor/PlayerStateMachine.gd b/src/Actors/Player/PlayerStateMachine.gd similarity index 87% rename from src/Actor/PlayerStateMachine.gd rename to src/Actors/Player/PlayerStateMachine.gd index d39bfea..a4545fd 100644 --- a/src/Actor/PlayerStateMachine.gd +++ b/src/Actors/Player/PlayerStateMachine.gd @@ -34,17 +34,17 @@ func _state_logic(delta): match self.state: "idle": - handle_input_ref = funcref(self, 'handle_idle_input') + handle_input_ref = funcref(self, "handle_idle_input") "walk": - handle_input_ref = funcref(self, 'handle_walk_input') + handle_input_ref = funcref(self, "handle_walk_input") "run": - handle_input_ref = funcref(self, 'handle_run_input') + handle_input_ref = funcref(self, "handle_run_input") "jump": - handle_input_ref = funcref(self, 'handle_jump_input') + handle_input_ref = funcref(self, "handle_jump_input") "fall": - handle_input_ref = funcref(self, 'handle_fall_input') + handle_input_ref = funcref(self, "handle_fall_input") "wallslide": - handle_input_ref = funcref(self, 'handle_wallslide_input') + handle_input_ref = funcref(self, "handle_wallslide_input") _: print("don't panik") @@ -105,7 +105,7 @@ func _get_transition(delta): + String(round(parent._velocity.x)) ) var new_state - if ! parent.is_on_floor(): + if !parent.is_on_floor(): if parent._velocity.y < 0: new_state = states.jump @@ -116,9 +116,10 @@ func _get_transition(delta): && parent._velocity.y <= parent.wallslide_threshold ): # TODO Wallslide might be too long + # TODO Player is stuck to the wall new_state = states.wallslide # 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: coyoteTimer.start() coyote_hanging = true @@ -142,6 +143,8 @@ func _get_transition(delta): else: # TODO How does this apply to enviornment induced movement? + # TODO Velocity on moving platforms goes to 0 and to platform speed when jumping + # Can get from platform by jumping often while platform has same direction new_state = states.idle coyote_hanging = false if new_state != self.state: diff --git a/src/Autoload/PhysicsFunc.tscn b/src/Autoload/PhysicsFunc.tscn new file mode 100644 index 0000000..7ef41ab --- /dev/null +++ b/src/Autoload/PhysicsFunc.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://src/Utilities/Physic/PhysicsFunc.gd" type="Script" id=1] + +[node name="Node" type="Node"] +script = ExtResource( 1 ) diff --git a/src/Contraptions/Platform/AnimationPlayer.gd b/src/Contraptions/Platform/AnimationPlayer.gd deleted file mode 100644 index 8bd8d42..0000000 --- a/src/Contraptions/Platform/AnimationPlayer.gd +++ /dev/null @@ -1,16 +0,0 @@ -extends AnimationPlayer - - -# 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: - play() - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -#func _process(delta: float) -> void: -# pass diff --git a/src/Contraptions/Platform/Simple.tscn b/src/Contraptions/Platform/Simple.tscn new file mode 100644 index 0000000..4b9cc41 --- /dev/null +++ b/src/Contraptions/Platform/Simple.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://assets/environment/blocks/Basic stone block.png" type="Texture" id=1] + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 8, 8 ) + +[node name="Simple Platform" type="StaticBody2D"] +collision_layer = 8 +collision_mask = 0 + +[node name="Sprite" type="Sprite" parent="."] +texture = ExtResource( 1 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource( 1 ) diff --git a/src/Contraptions/Platform/Spring.gd b/src/Contraptions/Platform/Spring.gd new file mode 100644 index 0000000..baf0d80 --- /dev/null +++ b/src/Contraptions/Platform/Spring.gd @@ -0,0 +1,32 @@ +extends Node2D +const PhysicsFunc = preload("res://src/Utilities/Physic/PhysicsFunc.gd") +const PhysicsConst = preload("res://src/Utilities/Physic/PhysicsConst.gd") + +# Declare member variables here. Examples: +# var a: int = 2 +# var b: Strin = "text" +var mass = 1 +var spring_k = -200 +var start_y = 0 +var y_velocity = 0 +var friction = 0.9 + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + start_y = self.position.y + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _physics_process(delta: float) -> void: + var spring_force = spring_k * (self.position.y - self.start_y) + var weight_force = PhysicsConst.gravity * mass + var result_force = weight_force + spring_force + + y_velocity += PhysicsFunc.convert_force_to_velocity( + result_force, mass, delta + ) + + y_velocity *= friction + + self.position.y += y_velocity * delta diff --git a/src/Contraptions/Platform/Spring.tscn b/src/Contraptions/Platform/Spring.tscn new file mode 100644 index 0000000..420d2fc --- /dev/null +++ b/src/Contraptions/Platform/Spring.tscn @@ -0,0 +1,24 @@ +[gd_scene load_steps=4 format=2] + +[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] + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 11.8807, 1.59654 ) + +[node name="Spring" type="Node2D"] +script = ExtResource( 1 ) + +[node name="StaticBody2D" type="StaticBody2D" parent="."] +collision_layer = 32 +collision_mask = 41 + +[node name="Sprite" type="Sprite" parent="StaticBody2D"] +position = Vector2( -7.80793, -0.67961 ) +scale = Vector2( 1.48986, 0.197785 ) +texture = ExtResource( 2 ) +centered = false + +[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"] +position = Vector2( 4.1428, 0.903461 ) +shape = SubResource( 1 ) diff --git a/src/Contraptions/Platform/Track.tscn b/src/Contraptions/Platform/Track.tscn index dc99c91..c82d4a7 100644 --- a/src/Contraptions/Platform/Track.tscn +++ b/src/Contraptions/Platform/Track.tscn @@ -29,7 +29,7 @@ script = ExtResource( 2 ) [node name="KinematicBody2D" type="KinematicBody2D" parent="."] position = Vector2( 19.2307, 0 ) collision_layer = 8 -collision_mask = 8 +collision_mask = 0 motion/sync_to_physics = true [node name="Sprite" type="Sprite" parent="KinematicBody2D"] diff --git a/src/Environment/Background.tscn b/src/Environment/Background.tscn new file mode 100644 index 0000000..859f30e --- /dev/null +++ b/src/Environment/Background.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://assets/environment/background/background.png" type="Texture" id=1] + +[node name="Simple Background" type="CanvasLayer"] + +[node name="background" type="TextureRect" parent="."] +margin_right = 426.667 +margin_bottom = 240.0 +texture = ExtResource( 1 ) +expand = true +stretch_mode = 1 diff --git a/src/Levels/Level02.tscn b/src/Levels/Level02.tscn index 69a886f..53c892f 100644 --- a/src/Levels/Level02.tscn +++ b/src/Levels/Level02.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=8 format=2] -[ext_resource path="res://src/Actor/Blobby.tscn" type="PackedScene" id=1] +[ext_resource path="res://src/Actors/Player/Blobby.tscn" type="PackedScene" id=1] [ext_resource path="res://assets/meta/tileset.png" type="Texture" id=2] -[ext_resource path="res://src/Actor/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://src/Neutral Objects/Coin.tscn" type="PackedScene" id=5] diff --git a/src/Levels/Level03.tscn b/src/Levels/Level03.tscn index a0f6802..5cdbd42 100644 --- a/src/Levels/Level03.tscn +++ b/src/Levels/Level03.tscn @@ -1,13 +1,12 @@ -[gd_scene load_steps=9 format=2] +[gd_scene load_steps=8 format=2] -[ext_resource path="res://src/Actor/Blobby.tscn" type="PackedScene" id=1] +[ext_resource path="res://src/Actors/Player/Blobby.tscn" type="PackedScene" id=1] [ext_resource path="res://assets/meta/tileset.tres" type="TileSet" id=2] -[ext_resource path="res://src/Actor/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://src/Neutral Objects/Coin.tscn" type="PackedScene" id=5] [ext_resource path="res://src/UserInterface/Buttons/UserInterface.tscn" type="PackedScene" id=6] -[ext_resource path="res://src/UserInterface/Buttons/EndsScreen.tscn" type="PackedScene" id=7] -[ext_resource path="res://src/Contraptions/Portal/Portal.tscn" type="PackedScene" id=8] +[ext_resource path="res://src/UserInterface/Portal.tscn" type="PackedScene" id=8] [node name="Level03" type="Node2D"] @@ -82,7 +81,6 @@ position = Vector2( 749, 274 ) [node name="Portal" parent="." instance=ExtResource( 8 )] position = Vector2( 130.332, -461.479 ) -next_scene = ExtResource( 7 ) [editable path="Blobby"] [editable path="Coin"] diff --git a/src/Levels/LevelTemplate.tscn b/src/Levels/LevelTemplate.tscn index 67063f7..f78da47 100644 --- a/src/Levels/LevelTemplate.tscn +++ b/src/Levels/LevelTemplate.tscn @@ -1,13 +1,13 @@ [gd_scene load_steps=13 format=2] -[ext_resource path="res://src/Actor/Blobby.tscn" type="PackedScene" id=1] +[ext_resource path="res://src/Actors/Player/Blobby.tscn" type="PackedScene" id=1] [ext_resource path="res://assets/meta/tileset.png" type="Texture" id=2] -[ext_resource path="res://src/Actor/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://src/Neutral Objects/Coin.tscn" type="PackedScene" id=5] [ext_resource path="res://src/UserInterface/Buttons/UserInterface.tscn" type="PackedScene" id=6] -[ext_resource path="res://src/Contraptions/Portal/Portal.tscn" type="PackedScene" id=7] -[ext_resource path="res://src/UserInterface/Buttons/EndsScreen.tscn" type="PackedScene" id=8] +[ext_resource path="res://src/UserInterface/Portal.tscn" type="PackedScene" id=7] +[ext_resource path="res://src/UserInterface/Screens/LevelEndScreen.tscn" type="PackedScene" id=8] [ext_resource path="res://assets/meta/tileset.tres" type="TileSet" id=9] [sub_resource type="ConvexPolygonShape2D" id=1] @@ -110,5 +110,4 @@ position = Vector2( 131, 339 ) next_scene = SubResource( 3 ) [editable path="Blobby"] - [editable path="Coin"] diff --git a/src/Levels/Plattforms Level.tscn b/src/Levels/Plattforms Level.tscn index 1b37395..e402164 100644 --- a/src/Levels/Plattforms Level.tscn +++ b/src/Levels/Plattforms Level.tscn @@ -1,10 +1,9 @@ -[gd_scene load_steps=11 format=2] +[gd_scene load_steps=10 format=2] -[ext_resource path="res://src/Actor/Blobby.tscn" type="PackedScene" id=1] +[ext_resource path="res://src/Actors/Player/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://src/Levels/StaticBody2D.gd" type="Script" id=3] -[ext_resource path="res://assets/environment/background/background.png" type="Texture" id=4] -[ext_resource path="res://src/Actor/Camera2D.gd" type="Script" id=5] +[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] [sub_resource type="NavigationPolygon" id=1] vertices = PoolVector2Array( 16, 16, 0, 16, 0, 0, 16, 0 ) @@ -42,7 +41,7 @@ points = PoolVector2Array( 16, 16, 0, 16, 0, 0, 16, 0 ) 0/z_index = 0 [sub_resource type="RectangleShape2D" id=5] -extents = Vector2( 190, 8 ) +extents = Vector2( 8, 8 ) [node name="LevelTemplate" type="Node2D"] __meta__ = { @@ -50,22 +49,8 @@ __meta__ = { "_edit_vertical_guides_": [ 2880.0 ] } -[node name="Blobby" parent="." instance=ExtResource( 1 )] -position = Vector2( 50.7867, 604.063 ) - -[node name="CanvasLayer" type="CanvasLayer" parent="."] +[node name="Simple Background" parent="." instance=ExtResource( 4 )] layer = -1 -script = ExtResource( 5 ) - -[node name="background" type="TextureRect" parent="CanvasLayer"] -margin_right = 426.667 -margin_bottom = 240.0 -texture = ExtResource( 4 ) -expand = true -stretch_mode = 1 -__meta__ = { -"_edit_use_anchors_": false -} [node name="TileMap" type="TileMap" parent="."] tile_set = SubResource( 4 ) @@ -77,16 +62,21 @@ 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, 31, 0, 0, 32, 0, 0, 33, 0, 0, 34, 0, 0, 35, 0, 0, 36, 0, 0, 37, 0, 0, 38, 0, 0, 39, 0, 0, 40, 0, 0, 41, 0, 0, 42, 0, 0, 43, 0, 0, 44, 0, 0, 45, 0, 0, 46, 0, 0, 47, 0, 0, 48, 0, 0, 49, 0, 0, 50, 0, 0, 51, 0, 0, 52, 0, 0, 53, 0, 0, 54, 0, 0, 55, 0, 0, 56, 0, 0, 57, 0, 0, 58, 0, 0, 59, 0, 0, 60, 0, 0, 65536, 0, 0, 65596, 0, 0, 131072, 0, 0, 131132, 0, 0, 196608, 0, 0, 196668, 0, 0, 262144, 0, 0, 262204, 0, 0, 327680, 0, 0, 327740, 0, 0, 393216, 0, 0, 393276, 0, 0, 458752, 0, 0, 458812, 0, 0, 524288, 0, 0, 524348, 0, 0, 589824, 0, 0, 589884, 0, 0, 655360, 0, 0, 655420, 0, 0, 720896, 0, 0, 720956, 0, 0, 786432, 0, 0, 786492, 0, 0, 851968, 0, 0, 852028, 0, 0, 917504, 0, 0, 917564, 0, 0, 983040, 0, 0, 983100, 0, 0, 1048576, 0, 0, 1048636, 0, 0, 1114112, 0, 0, 1114172, 0, 0, 1179648, 0, 0, 1179708, 0, 0, 1245184, 0, 0, 1245244, 0, 0, 1310720, 0, 0, 1310780, 0, 0, 1376256, 0, 0, 1376316, 0, 0, 1441792, 0, 0, 1441852, 0, 0, 1507328, 0, 0, 1507388, 0, 0, 1572864, 0, 0, 1572924, 0, 0, 1638400, 0, 0, 1638460, 0, 0, 1703936, 0, 0, 1703996, 0, 0, 1769472, 0, 0, 1769532, 0, 0, 1835008, 0, 0, 1835068, 0, 0, 1900544, 0, 0, 1900604, 0, 0, 1966080, 0, 0, 1966140, 0, 0, 2031616, 0, 0, 2031676, 0, 0, 2097152, 0, 0, 2097212, 0, 0, 2162688, 0, 0, 2162748, 0, 0, 2228224, 0, 0, 2228284, 0, 0, 2293760, 0, 0, 2293820, 0, 0, 2359296, 0, 0, 2359356, 0, 0, 2424832, 0, 0, 2424892, 0, 0, 2490368, 0, 0, 2490428, 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, 2555935, 0, 0, 2555936, 0, 0, 2555937, 0, 0, 2555938, 0, 0, 2555939, 0, 0, 2555940, 0, 0, 2555941, 0, 0, 2555942, 0, 0, 2555943, 0, 0, 2555944, 0, 0, 2555945, 0, 0, 2555946, 0, 0, 2555947, 0, 0, 2555948, 0, 0, 2555949, 0, 0, 2555950, 0, 0, 2555951, 0, 0, 2555952, 0, 0, 2555953, 0, 0, 2555954, 0, 0, 2555955, 0, 0, 2555956, 0, 0, 2555957, 0, 0, 2555958, 0, 0, 2555959, 0, 0, 2555960, 0, 0, 2555961, 0, 0, 2555962, 0, 0, 2555963, 0, 0, 2555964, 0, 0 ) -[node name="StaticBody2D" type="StaticBody2D" parent="."] -script = ExtResource( 3 ) +[node name="Spring" parent="." instance=ExtResource( 3 )] +position = Vector2( 206.918, 601.665 ) -[node name="Tween" type="Tween" parent="StaticBody2D"] +[node name="Blobby" parent="." instance=ExtResource( 1 )] +position = Vector2( 50.7867, 604.063 ) -[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"] -position = Vector2( 413.838, 598.422 ) +[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="StaticBody2D/CollisionShape2D"] -position = Vector2( -0.0883788, 0 ) -scale = Vector2( 23.7344, 1 ) +[node name="Sprite" type="Sprite" parent="RigidBody2D/CollisionShape2D"] +position = Vector2( 0, -0.000244141 ) texture = ExtResource( 2 ) diff --git a/src/Levels/Simple Level.tscn b/src/Levels/Simple Level.tscn index 5b7c354..a70f49f 100644 --- a/src/Levels/Simple Level.tscn +++ b/src/Levels/Simple Level.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=9 format=2] +[gd_scene load_steps=10 format=2] -[ext_resource path="res://src/Actor/Blobby.tscn" type="PackedScene" id=1] +[ext_resource path="res://src/Actors/Player/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://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://src/UserInterface/Portal.tscn" type="PackedScene" id=5] [sub_resource type="NavigationPolygon" id=1] vertices = PoolVector2Array( 16, 16, 0, 16, 0, 0, 16, 0 ) @@ -46,6 +47,10 @@ __meta__ = { "_edit_vertical_guides_": [ 2880.0 ] } +[node name="Portal" parent="." instance=ExtResource( 5 )] +position = Vector2( 40.0074, 395.986 ) +scale = Vector2( 0.5, 0.5 ) + [node name="Blobby" parent="." instance=ExtResource( 1 )] position = Vector2( 46.7551, 565.6 ) @@ -61,9 +66,6 @@ margin_bottom = 240.0 texture = ExtResource( 4 ) expand = true stretch_mode = 1 -__meta__ = { -"_edit_use_anchors_": false -} [node name="TileMap" type="TileMap" parent="."] tile_set = SubResource( 4 ) diff --git a/src/UserInterface/Buttons/QuitButton.tscn b/src/UserInterface/Buttons/QuitButton.tscn index 98e94dd..a0e010f 100644 --- a/src/UserInterface/Buttons/QuitButton.tscn +++ b/src/UserInterface/Buttons/QuitButton.tscn @@ -2,7 +2,6 @@ [ext_resource path="res://src/UserInterface/Buttons/QuitButton.gd" type="Script" id=1] - [node name="QuitButton" type="Button"] anchor_left = 0.5 anchor_right = 0.5 @@ -15,4 +14,5 @@ script = ExtResource( 1 ) __meta__ = { "_edit_use_anchors_": false } + [connection signal="button_up" from="." to="." method="_on_button_up"] diff --git a/src/UserInterface/Buttons/RetryButton.tscn b/src/UserInterface/Buttons/RetryButton.tscn index 9950eb8..b12c808 100644 --- a/src/UserInterface/Buttons/RetryButton.tscn +++ b/src/UserInterface/Buttons/RetryButton.tscn @@ -2,7 +2,6 @@ [ext_resource path="res://src/UserInterface/Buttons/RetryButton.gd" type="Script" id=1] - [node name="RetryButton" type="Button"] margin_right = 139.0 margin_bottom = 78.0 @@ -12,4 +11,5 @@ script = ExtResource( 1 ) __meta__ = { "_edit_use_anchors_": false } + [connection signal="button_up" from="." to="." method="_on_button_up"] diff --git a/src/UserInterface/Buttons/StatsLabel.tscn b/src/UserInterface/Buttons/StatsLabel.tscn index 389e27d..22f8d89 100644 --- a/src/UserInterface/Buttons/StatsLabel.tscn +++ b/src/UserInterface/Buttons/StatsLabel.tscn @@ -2,7 +2,6 @@ [ext_resource path="res://assets/meta/montserrat_extrabold.otf" type="DynamicFontData" id=1] - [sub_resource type="DynamicFont" id=1] size = 24 use_mipmaps = true @@ -21,6 +20,3 @@ margin_bottom = 46.5 custom_fonts/font = SubResource( 1 ) text = "Your final score is %s. Your died %s times." -__meta__ = { -"_edit_use_anchors_": false -} diff --git a/src/UserInterface/Buttons/Titel.tscn b/src/UserInterface/Buttons/Titel.tscn index dbc0c8e..b67388f 100644 --- a/src/UserInterface/Buttons/Titel.tscn +++ b/src/UserInterface/Buttons/Titel.tscn @@ -4,8 +4,6 @@ [sub_resource type="DynamicFont" id=1] size = 69 -use_mipmaps = true -use_filter = true font_data = ExtResource( 1 ) [node name="Titel" type="Label"] diff --git a/src/UserInterface/Buttons/UserInterface.tscn b/src/UserInterface/Buttons/UserInterface.tscn index 3488476..fc7977f 100644 --- a/src/UserInterface/Buttons/UserInterface.tscn +++ b/src/UserInterface/Buttons/UserInterface.tscn @@ -12,9 +12,6 @@ anchor_right = 1.0 anchor_bottom = 1.0 theme = ExtResource( 1 ) script = ExtResource( 5 ) -__meta__ = { -"_edit_use_anchors_": false -} [node name="PauseOverlay" type="ColorRect" parent="."] visible = false diff --git a/src/Contraptions/Portal/Portal.tscn b/src/UserInterface/Portal.tscn similarity index 93% rename from src/Contraptions/Portal/Portal.tscn rename to src/UserInterface/Portal.tscn index 1659229..39b0bd9 100644 --- a/src/Contraptions/Portal/Portal.tscn +++ b/src/UserInterface/Portal.tscn @@ -1,8 +1,8 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://assets/contraption/portal.png" type="Texture" id=1] [ext_resource path="res://src/Contraptions/Portal/Portal.gd" type="Script" id=2] - +[ext_resource path="res://src/UserInterface/Screens/LevelEndScreen.tscn" type="PackedScene" id=3] [sub_resource type="CapsuleShape2D" id=1] radius = 39.0 @@ -63,9 +63,10 @@ tracks/1/keys = { } [node name="Portal" type="Area2D"] -monitorable = false collision_layer = 0 +monitorable = false script = ExtResource( 2 ) +next_scene = ExtResource( 3 ) [node name="portal" type="Sprite" parent="."] position = Vector2( -1.90735e-06, -65 ) @@ -92,4 +93,5 @@ __meta__ = { autoplay = "Start" anims/Start = SubResource( 2 ) anims/fade_in = SubResource( 3 ) + [connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/src/UserInterface/Buttons/EndsScreen.tscn b/src/UserInterface/Screens/LevelEndScreen.tscn similarity index 78% rename from src/UserInterface/Buttons/EndsScreen.tscn rename to src/UserInterface/Screens/LevelEndScreen.tscn index 73c1397..c764f2a 100644 --- a/src/UserInterface/Buttons/EndsScreen.tscn +++ b/src/UserInterface/Screens/LevelEndScreen.tscn @@ -1,22 +1,18 @@ [gd_scene load_steps=9 format=2] [ext_resource path="res://assets/environment/background/background.png" type="Texture" id=1] -[ext_resource path="res://src/UserInterface/Buttons/ChangeSceneButton.tscn" type="PackedScene" id=2] -[ext_resource path="res://src/UserInterface/Buttons/QuitButton.tscn" type="PackedScene" id=3] -[ext_resource path="res://src/UserInterface/Buttons/StatsLabel.tscn" type="PackedScene" id=4] -[ext_resource path="res://src/UserInterface/Buttons/StatsLabel.gd" type="Script" id=5] -[ext_resource path="res://assets/meta/ui_theme.tres" type="Theme" id=6] -[ext_resource path="res://src/UserInterface/Buttons/Titel.tscn" type="PackedScene" id=7] -[ext_resource path="res://assets/meta/new_dynamicfont.tres" type="DynamicFont" id=8] - +[ext_resource path="res://assets/meta/new_dynamicfont.tres" type="DynamicFont" id=2] +[ext_resource path="res://src/UserInterface/Buttons/Titel.tscn" type="PackedScene" id=3] +[ext_resource path="res://src/UserInterface/Buttons/ChangeSceneButton.tscn" type="PackedScene" id=4] +[ext_resource path="res://src/UserInterface/Buttons/QuitButton.tscn" type="PackedScene" id=5] +[ext_resource path="res://src/UserInterface/Buttons/StatsLabel.tscn" type="PackedScene" id=6] +[ext_resource path="res://assets/meta/ui_theme.tres" type="Theme" id=7] +[ext_resource path="res://src/UserInterface/Buttons/StatsLabel.gd" type="Script" id=8] [node name="EndScreen" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 -theme = ExtResource( 6 ) -__meta__ = { -"_edit_use_anchors_": false -} +theme = ExtResource( 7 ) [node name="background" type="TextureRect" parent="."] anchor_left = 0.00195313 @@ -29,7 +25,7 @@ __meta__ = { "_edit_use_anchors_": true } -[node name="EndScreenLabel" parent="." instance=ExtResource( 7 )] +[node name="EndScreenLabel" parent="." instance=ExtResource( 3 )] anchor_left = 0.5 anchor_right = 0.5 margin_left = -169.0 @@ -40,17 +36,17 @@ rect_pivot_offset = Vector2( 170, 0 ) size_flags_horizontal = 2 size_flags_vertical = 2 size_flags_stretch_ratio = 0.0 -custom_fonts/font = ExtResource( 8 ) +custom_fonts/font = ExtResource( 2 ) text = "Thank You For Playing!" autowrap = true -[node name="StatsLabel" parent="." instance=ExtResource( 4 )] +[node name="StatsLabel" parent="." instance=ExtResource( 6 )] margin_left = -146.5 margin_top = -64.5 margin_right = 146.5 margin_bottom = 2.5 align = 1 -script = ExtResource( 5 ) +script = ExtResource( 8 ) [node name="MenuContainer" type="VBoxContainer" parent="."] anchor_left = 0.5 @@ -65,12 +61,12 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="PlayButton" parent="MenuContainer" instance=ExtResource( 2 )] +[node name="PlayButton" parent="MenuContainer" instance=ExtResource( 4 )] margin_right = 246.0 text = "Begin Again" -next_scene_path = "res://src/Screens/MainScreen.tscn" +next_scene_path = "res://src/UserInterface/Screens/MainScreen.tscn" -[node name="QuitButton" parent="MenuContainer" instance=ExtResource( 3 )] +[node name="QuitButton" parent="MenuContainer" instance=ExtResource( 5 )] anchor_left = 0.0 anchor_right = 0.0 margin_left = 0.0 diff --git a/src/UserInterface/Screens/MainScreen.tscn b/src/UserInterface/Screens/MainScreen.tscn index 66824ab..39be647 100644 --- a/src/UserInterface/Screens/MainScreen.tscn +++ b/src/UserInterface/Screens/MainScreen.tscn @@ -37,7 +37,7 @@ margin_bottom = 85.0 grow_horizontal = 2 size_flags_horizontal = 2 size_flags_vertical = 2 -text = "Very Bad Game" +text = "Wumper" [node name="MenuContainer" type="VBoxContainer" parent="ViewportContainer"] anchor_left = 0.5 @@ -54,7 +54,7 @@ __meta__ = { [node name="PlayButton" parent="ViewportContainer/MenuContainer" instance=ExtResource( 3 )] margin_right = 97.0 margin_bottom = 38.0 -next_scene_path = "res://src/Levels/Simple Level.tscn" +next_scene_path = "res://src/Levels/Plattforms Level.tscn" [node name="QuitButton" parent="ViewportContainer/MenuContainer" instance=ExtResource( 1 )] anchor_left = 0.0 diff --git a/src/Utilities/Physic/PhysicsConst.gd b/src/Utilities/Physic/PhysicsConst.gd new file mode 100644 index 0000000..d97687a --- /dev/null +++ b/src/Utilities/Physic/PhysicsConst.gd @@ -0,0 +1 @@ +const gravity: float = 1111.0 diff --git a/src/Utilities/Physic/PhysicsFunc.gd b/src/Utilities/Physic/PhysicsFunc.gd new file mode 100644 index 0000000..b667336 --- /dev/null +++ b/src/Utilities/Physic/PhysicsFunc.gd @@ -0,0 +1,6 @@ +static func convert_velocity_to_force(velocity, mass, delta) -> float: + return (velocity * mass) / delta + + +static func convert_force_to_velocity(force, mass, delta) -> float: + return (force / mass) * delta