From 6b640f50905c04e45ed3189cb6196717ab51abe4 Mon Sep 17 00:00:00 2001 From: Misha Vicha Date: Sun, 22 Mar 2026 16:08:40 +0100 Subject: [PATCH] exampleShittyPlatformer --- code/Blorbo.cs | 75 +++++++++++++++++++++++++++++++++ code/Blorbo.cs.uid | 1 + funny-platformer-test.csproj | 8 ++++ funny-platformer-test.sln | 19 +++++++++ icon.svg | 1 + icon.svg.import | 43 +++++++++++++++++++ icons/mob/blorbo.png | Bin 0 -> 141 bytes icons/mob/blorbo.png.import | 40 ++++++++++++++++++ icons/tiles/tileset.png | Bin 0 -> 839 bytes icons/tiles/tileset.png.import | 40 ++++++++++++++++++ project.godot | 38 +++++++++++++++++ scenes/blorbo.tscn | 23 ++++++++++ scenes/mainscene.tscn | 58 +++++++++++++++++++++++++ tileset.png | Bin 0 -> 983 bytes tileset.png.import | 40 ++++++++++++++++++ 15 files changed, 386 insertions(+) create mode 100644 code/Blorbo.cs create mode 100644 code/Blorbo.cs.uid create mode 100644 funny-platformer-test.csproj create mode 100644 funny-platformer-test.sln create mode 100644 icon.svg create mode 100644 icon.svg.import create mode 100644 icons/mob/blorbo.png create mode 100644 icons/mob/blorbo.png.import create mode 100644 icons/tiles/tileset.png create mode 100644 icons/tiles/tileset.png.import create mode 100644 project.godot create mode 100644 scenes/blorbo.tscn create mode 100644 scenes/mainscene.tscn create mode 100644 tileset.png create mode 100644 tileset.png.import 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 0000000000000000000000000000000000000000..c40361514e4ca95b0a26c0258363e02937b4d03a GIT binary patch literal 141 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|+&x_!Lo9le zQyiEXA3gkk@#utuZPT?SH+r#jwEtIMBDvfu$>dRyrtnIs!dWis;<{oDvJNB|G&Ck2 n2v*wE`6NZHXN_l885_g$Z3@|oZQh9kjb!k2^>bP0l+XkKL^3Yj literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..cbf1096cb55b2e1edc98a70d9ce1b5af8a6fd042 GIT binary patch literal 839 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G!U;i$lZxy-8q?;3=GVSo-U3d z6?5L+_VIFBMcL==P$KC9@ zYZ8m1;1=$=S5p2-q`P^&{_K!oWUN2=?EByMei~iw>bUXxXl+PAo$T6%T<&VpIyd+e_kGY(CGQ0 zXcK9MPhw2@YL|BkOkWv&f6Jl|%=KrMmYM9GJ^SQi!y_->%*`qH7H5Bb&0JOg&%57> z+TY_FjtcA#x%+F^r$g(d8`kVJZOE%$YO=>Qo5A<$ezu40Ni$s!Y-(?s7I|fL^nI0w z?L|wo8D4%*jsCUkYw44_kHuT>S25VE_{L-KA^yY~#wnHSa@R-4UoY0JxB9$Ww}E{r zKT~L}=ZclTrbnn>C*?d_+|y@v^Njo73Q6tv|EvBSKd85#zh+m~b$tul?4qh`Ul!`MIo=Ob zV@cTmPDgBYcJuSqrN?}0AOF}^cHwS5*Pk@IQ(qoN7FkB-tmkO>yK+*BQD)J;sOMXv z)jXH+-||uOEt33oa>>b*ODVq=oZYcg2>ZTq)DSz;a6G2gj2XX|wz)#^UF zYQDrNmx3RERPy)N&3N~+drRrm>-J}h{#DFUiL|SndXhgrt?-Z0^Zw<3zt?>`D-IMZ zeXPa2!+LCvDud?T)uBu>Gbz?|9?(hXP@`# zk6E-8ON*^#MM=os^9m2{{!;pWd-q@Vw&#qKJumx<+!j8x{MvuJ{RWH&=H1bB)Je>H zy{g_e?^Vg`?vmF}w;sBjcayz#`>)sU8MiOilHC;@|D`##zJ6cS^0lk~?P{Q@b?fIj z26#We$MK?!U2X7DK7td~Q z`~H6SmEEije|K(T)i|ibUVeDvru_WZtL&d>KfJe9?neJU(dntxznb^Na2D>|_IvsA z?`3P*^Wy(2T-d*JmUP*>hcEvxzp}qVIvSW