commit 6b640f50905c04e45ed3189cb6196717ab51abe4 Author: Misha Vicha Date: Sun Mar 22 16:08:40 2026 +0100 exampleShittyPlatformer diff --git a/code/Blorbo.cs b/code/Blorbo.cs new file mode 100644 index 0000000..50853b2 --- /dev/null +++ b/code/Blorbo.cs @@ -0,0 +1,75 @@ +using Godot; +using System; + +public partial class Blorbo : CharacterBody2D +{ + public const float TerminalVelocity = 500.0f; // Max falling speed + public const float Speed = 60.0f; + public const float JumpVelocity = -160.0f; + public const float Acceleration = 400.0f; // How much we speed up/second + public const float Decelleration = 400.0f; // Slow down/second + public const float AirFrictionMultiplier = 0.2f; // How much less control and speedup we have in the air + + public override void _PhysicsProcess(double delta) + { + Vector2 velocity = Velocity; + + // Add the gravity. + if (!IsOnFloor()) + { + velocity += GetGravity() * (float)delta; + velocity.Y = Math.Min(TerminalVelocity, velocity.Y); + } + + // Handle Jump. + if (Input.IsActionJustPressed("ui_accept") && IsOnFloor()) + { + velocity.Y = JumpVelocity; + } + + // Get the input direction and handle the movement/deceleration. + // As good practice, you should replace UI actions with custom gameplay actions. + Vector2 direction = Input.GetVector("ui_left", "ui_right", "ui_up", "ui_down"); + float friction_multiplier = 1.0f * getFloorFriction(); + if (!IsOnFloor()){ + friction_multiplier *= AirFrictionMultiplier; + } + if (direction != Vector2.Zero) + { + velocity.X += direction.X * Acceleration * (float)delta * friction_multiplier; + velocity.X = Math.Min(Speed, velocity.X); + } + else + { + + velocity.X = Mathf.MoveToward(Velocity.X, 0, Decelleration * (float)delta * friction_multiplier); + } + + Velocity = velocity; + MoveAndSlide(); + } + + private float getFloorFriction() { + Marker2D floorCheck = GetNode("FloorCheck"); + Vector2 checkedPosition = floorCheck.GlobalPosition; + GD.Print(checkedPosition); + + for (int i = 0; i < GetSlideCollisionCount(); i++) + { + var collision = GetSlideCollision(i); + var collider = collision.GetCollider(); + if (collider is TileMapLayer tileMap) + { + TileData data = tileMap.GetCellTileData( + tileMap.LocalToMap( + tileMap.ToLocal(checkedPosition))); + GD.Print(collider.ToString()); + if (data != null) + { + return (float)data.GetCustomData("frictionMul"); + } + } + } + return 1.0f; + } +} diff --git a/code/Blorbo.cs.uid b/code/Blorbo.cs.uid new file mode 100644 index 0000000..e911eb7 --- /dev/null +++ b/code/Blorbo.cs.uid @@ -0,0 +1 @@ +uid://bl3pxakeoapd2 diff --git a/funny-platformer-test.csproj b/funny-platformer-test.csproj new file mode 100644 index 0000000..6978fb0 --- /dev/null +++ b/funny-platformer-test.csproj @@ -0,0 +1,8 @@ + + + net8.0 + net9.0 + true + funnyplatformertest + + \ No newline at end of file diff --git a/funny-platformer-test.sln b/funny-platformer-test.sln new file mode 100644 index 0000000..7171dfb --- /dev/null +++ b/funny-platformer-test.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "funny-platformer-test", "funny-platformer-test.csproj", "{36BD6405-AC97-4E60-B10A-F036901DBC8E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + ExportDebug|Any CPU = ExportDebug|Any CPU + ExportRelease|Any CPU = ExportRelease|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {36BD6405-AC97-4E60-B10A-F036901DBC8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {36BD6405-AC97-4E60-B10A-F036901DBC8E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {36BD6405-AC97-4E60-B10A-F036901DBC8E}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU + {36BD6405-AC97-4E60-B10A-F036901DBC8E}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU + {36BD6405-AC97-4E60-B10A-F036901DBC8E}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU + {36BD6405-AC97-4E60-B10A-F036901DBC8E}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU + EndGlobalSection +EndGlobal diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..c6bbb7d --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + diff --git a/icon.svg.import b/icon.svg.import new file mode 100644 index 0000000..2005ca1 --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,43 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bs8l3d8dqiojf" +path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.svg" +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/icons/mob/blorbo.png b/icons/mob/blorbo.png new file mode 100644 index 0000000..c403615 Binary files /dev/null and b/icons/mob/blorbo.png differ diff --git a/icons/mob/blorbo.png.import b/icons/mob/blorbo.png.import new file mode 100644 index 0000000..dd1d126 --- /dev/null +++ b/icons/mob/blorbo.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bu43jlfcn6utc" +path="res://.godot/imported/blorbo.png-fa2feb106dcafa361191aabc22c4d5f9.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icons/mob/blorbo.png" +dest_files=["res://.godot/imported/blorbo.png-fa2feb106dcafa361191aabc22c4d5f9.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/icons/tiles/tileset.png b/icons/tiles/tileset.png new file mode 100644 index 0000000..cbf1096 Binary files /dev/null and b/icons/tiles/tileset.png differ diff --git a/icons/tiles/tileset.png.import b/icons/tiles/tileset.png.import new file mode 100644 index 0000000..db328d3 --- /dev/null +++ b/icons/tiles/tileset.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ct2nodxxidsxi" +path="res://.godot/imported/tileset.png-73f5675dd765da508cb18be4efc563ee.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icons/tiles/tileset.png" +dest_files=["res://.godot/imported/tileset.png-73f5675dd765da508cb18be4efc563ee.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..2b84e82 --- /dev/null +++ b/project.godot @@ -0,0 +1,38 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="funny-platformer-test" +run/main_scene="uid://b1gniim34ay75" +config/features=PackedStringArray("4.6", "C#", "GL Compatibility") +config/icon="res://icon.svg" + +[dotnet] + +project/assembly_name="funny-platformer-test" + +[layer_names] + +2d_physics/layer_1="AlwaysCollide" +2d_physics/layer_2="Killision" +2d_physics/layer_3="Player" + +[physics] + +3d/physics_engine="Jolt Physics" +2d/default_gravity=350.0 + +[rendering] + +textures/canvas_textures/default_texture_filter=0 +rendering_device/driver.windows="d3d12" +renderer/rendering_method="gl_compatibility" +renderer/rendering_method.mobile="gl_compatibility" diff --git a/scenes/blorbo.tscn b/scenes/blorbo.tscn new file mode 100644 index 0000000..54e9ab7 --- /dev/null +++ b/scenes/blorbo.tscn @@ -0,0 +1,23 @@ +[gd_scene format=3 uid="uid://6hvtko6ur466"] + +[ext_resource type="Script" uid="uid://bl3pxakeoapd2" path="res://code/Blorbo.cs" id="1_mfum6"] +[ext_resource type="Texture2D" uid="uid://bu43jlfcn6utc" path="res://icons/mob/blorbo.png" id="2_3sc2b"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_dn5c8"] +size = Vector2(14, 15) + +[node name="Blorbo" type="CharacterBody2D" unique_id=297375332] +platform_floor_layers = 4294967041 +platform_wall_layers = 1 +script = ExtResource("1_mfum6") + +[node name="Blorbo-Icon" type="Sprite2D" parent="." unique_id=383159907] +texture_filter = 1 +texture = ExtResource("2_3sc2b") + +[node name="Collider" type="CollisionShape2D" parent="." unique_id=368836316] +position = Vector2(0, 0.5) +shape = SubResource("RectangleShape2D_dn5c8") + +[node name="FloorCheck" type="Marker2D" parent="." unique_id=1675033941] +position = Vector2(0, 9) diff --git a/scenes/mainscene.tscn b/scenes/mainscene.tscn new file mode 100644 index 0000000..56adc79 --- /dev/null +++ b/scenes/mainscene.tscn @@ -0,0 +1,58 @@ +[gd_scene format=4 uid="uid://b1gniim34ay75"] + +[ext_resource type="PackedScene" uid="uid://6hvtko6ur466" path="res://scenes/blorbo.tscn" id="1_golqe"] +[ext_resource type="Texture2D" uid="uid://ct2nodxxidsxi" path="res://icons/tiles/tileset.png" id="2_golqe"] + +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_nx3wj"] +texture = ExtResource("2_golqe") +0:0/0 = 0 +0:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +0:0/0/custom_data_0 = 1.0 +1:0/0 = 0 +1:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +1:0/0/custom_data_0 = 1.0 +3:0/0 = 0 +3:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +3:0/0/custom_data_0 = 0.1 + +[sub_resource type="TileSet" id="TileSet_dn5c8"] +physics_layer_0/collision_layer = 1 +physics_layer_0/collision_mask = 0 +custom_data_layer_0/name = "frictionMul" +custom_data_layer_0/type = 3 +sources/1 = SubResource("TileSetAtlasSource_nx3wj") + +[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_nx3wj"] +distance = -81.0 + +[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_golqe"] +normal = Vector2(1, 0) +distance = -145.0 + +[node name="Node2D" type="Node2D" unique_id=2013336402] + +[node name="Blorbo" parent="." unique_id=297375332 instance=ExtResource("1_golqe")] +position = Vector2(-134, 6) +collision_layer = 5 +collision_mask = 7 + +[node name="Layer0" type="TileMapLayer" parent="." unique_id=1892214682] +texture_filter = 1 +tile_map_data = PackedByteArray("AAD+/wQAAQADAAAAAAD9/wQAAQADAAAAAAD5/wQAAQAAAAAAAAD4/wQAAQAAAAAAAAD3/wQAAQAAAAAAAAADAAEAAQABAAAAAAAEAAEAAQABAAAAAAD3/wEAAQABAAAAAAD4/wEAAQABAAAAAAD5/wEAAQABAAAAAAD5/wIAAQAAAAAAAAD5/wMAAQAAAAAAAAD4/wMAAQAAAAAAAAD4/wIAAQAAAAAAAAD3/wIAAQAAAAAAAAD3/wMAAQAAAAAAAAD9/wMAAQADAAAAAAD+/wMAAQADAAAAAAD+/wIAAQADAAAAAAD9/wIAAQADAAAAAAADAAIAAQAAAAAAAAADAAMAAQAAAAAAAAADAAQAAQAAAAAAAAAEAAQAAQAAAAAAAAAEAAMAAQAAAAAAAAAEAAIAAQAAAAAAAAD//wIAAQADAAAAAAD//wMAAQADAAAAAAD//wQAAQADAAAAAAAAAAQAAQADAAAAAAAAAAMAAQADAAAAAAAAAAIAAQADAAAAAAABAP3/AQADAAAAAAACAP3/AQADAAAAAAADAP3/AQADAAAAAAAGAP//AQAAAAAAAAAHAP//AQAAAAAAAAD+//3/AQADAAAAAAD9//3/AQADAAAAAAD6//3/AQADAAAAAAD5//3/AQADAAAAAAA=") +tile_set = SubResource("TileSet_dn5c8") + +[node name="WorldKill" type="RigidBody2D" parent="." unique_id=930846306] +collision_layer = 2 +collision_mask = 0 + +[node name="Kill" type="CollisionShape2D" parent="WorldKill" unique_id=418013596] +shape = SubResource("WorldBoundaryShape2D_nx3wj") + +[node name="WorldWalls" type="StaticBody2D" parent="." unique_id=1591273250] +collision_mask = 0 + +[node name="Side" type="CollisionShape2D" parent="WorldWalls" unique_id=185994871] +shape = SubResource("WorldBoundaryShape2D_golqe") + +[node name="MainCam" type="Camera2D" parent="." unique_id=290301959] +zoom = Vector2(4, 4) diff --git a/tileset.png b/tileset.png new file mode 100644 index 0000000..d9195a7 Binary files /dev/null and b/tileset.png differ diff --git a/tileset.png.import b/tileset.png.import new file mode 100644 index 0000000..dd5cb2d --- /dev/null +++ b/tileset.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://chy3r2u2lsr18" +path="res://.godot/imported/tileset.png-a39e944f25b35d62f55d4f98a36e2b5e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://tileset.png" +dest_files=["res://.godot/imported/tileset.png-a39e944f25b35d62f55d4f98a36e2b5e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1