From 11e291e867bd46a939d5d6f867845d0d68922de0 Mon Sep 17 00:00:00 2001 From: debugman18 Date: Sat, 17 Oct 2026 12:21:33 -0500 Subject: [PATCH] Dash dash baby --- art/hats/dunce1.png | Bin 0 -> 443 bytes art/hats/dunce1.png.import | 43 ++++++++++++++++++++++++ art/hats/dunce2.png | Bin 0 -> 442 bytes art/hats/dunce2.png.import | 43 ++++++++++++++++++++++++ player_2d.gd | 21 ++++++++++-- player_2d.tscn | 56 +++++++++++++++++++++++++++++-- project.godot | 3 +- shaders/warp_shader.gdshader | 20 +++++++++++ shaders/warp_shader.gdshader.uid | 1 + warp_shader.gd | 16 +++++++++ warp_shader.gd.uid | 1 + world.tscn | 48 +++++++++++++------------- 12 files changed, 222 insertions(+), 30 deletions(-) create mode 100644 art/hats/dunce1.png create mode 100644 art/hats/dunce1.png.import create mode 100644 art/hats/dunce2.png create mode 100644 art/hats/dunce2.png.import create mode 100644 shaders/warp_shader.gdshader create mode 100644 shaders/warp_shader.gdshader.uid create mode 100644 warp_shader.gd create mode 100644 warp_shader.gd.uid diff --git a/art/hats/dunce1.png b/art/hats/dunce1.png new file mode 100644 index 0000000000000000000000000000000000000000..d8b8013066ba3e0db66e64ee2831304ebb305a33 GIT binary patch literal 443 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}c0G|+7ApQUUe;`?Wtho?KF_#4S1p@`HpW+3oW#BCEh%9Dc;M)(vj25iH zDnLQW64!{5;QX|b^2DN4hJeJ(yb?V>*AN9$JwrW1BVk7O5}=|TsS%!Oo}O9^96$~$ zgA^kx10#^-1;o-&Hps~ujLcwhCLr68k%>VNNJjy2W;+X5JO{`Ifn{Zk3@?B_gVE@= z0$t9)FoB(c1*q1*$k>2!0mNL8ovaHWW=#XKL4XNpG80&3kfjBX1=VF}U;vWcBeJLB z>-AZ8flOyl7sn8d;L@HzJ_ZF2r;WemcPU<4vs9jE9?zQR28=Ss3<_`N*e_UPa%gIZ wSWKpai^64IfvvMA_`g?M@Re((6Z_k1Y}djW!+f*f@qmo>boFyt=akR{08oxzJpcdz literal 0 HcmV?d00001 diff --git a/art/hats/dunce1.png.import b/art/hats/dunce1.png.import new file mode 100644 index 0000000..957f482 --- /dev/null +++ b/art/hats/dunce1.png.import @@ -0,0 +1,43 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ba4kjeulthw1g" +path="res://.godot/imported/dunce1.png-de6f74ebb32d625ad52a8a4b955363f6.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://art/hats/dunce1.png" +dest_files=["res://.godot/imported/dunce1.png-de6f74ebb32d625ad52a8a4b955363f6.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/high_quality_mode=0 +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 +mipmaps/preserve_alpha_test_coverage=false +mipmaps/alpha_test_threshold=0.5 +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/art/hats/dunce2.png b/art/hats/dunce2.png new file mode 100644 index 0000000000000000000000000000000000000000..5e9d4bcbdab2bdc80498ae45e85ebda27333917f GIT binary patch literal 442 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}c0G|+7ApQUUe;`?Wtho?KF_#4S1p@`HpW+3oW#BCEh%9Dc;M)(vj25iH zDnLQW64!{5;QX|b^2DN4hJeJ(yb?V>*AN9$JwrW1BVk7O5}=|TsS%!Oo}O9^96$~$ zgA^kx10#^-1;o-&Hps~ujLcwhCLr68k%>VNNJjy2W;+X5JO{`Ifn{Zk3@?B_gVE@= z0$t9)FoB(c1*q1*$k>2!0mNL8ovaHWW=#XKL4XNpG80&3kfjBX1=VF}U;vWcBeJLB z>-AZ8flMb)7sn8d;L;W3^%3LGcM+SR4A@K46|AePYj( v^8u$>JRNRxE~t(TIsQdTYnkiOIJKUe*O?f@PN+D31)1#W>gTe~DWM4f#gt+z literal 0 HcmV?d00001 diff --git a/art/hats/dunce2.png.import b/art/hats/dunce2.png.import new file mode 100644 index 0000000..3629bc4 --- /dev/null +++ b/art/hats/dunce2.png.import @@ -0,0 +1,43 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cp1v5uhvbfws6" +path="res://.godot/imported/dunce2.png-37a87f65677f98425ffee71e6bd19029.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://art/hats/dunce2.png" +dest_files=["res://.godot/imported/dunce2.png-37a87f65677f98425ffee71e6bd19029.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/high_quality_mode=0 +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 +mipmaps/preserve_alpha_test_coverage=false +mipmaps/alpha_test_threshold=0.5 +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/player_2d.gd b/player_2d.gd index 8328a77..c8ea6cd 100644 --- a/player_2d.gd +++ b/player_2d.gd @@ -2,6 +2,7 @@ extends CharacterBody2D const SPEED = 380.0 const DASH_SPEED = 600 +const HORIZONTAL_DASH_MULT = 1.8 const FRICTION = 100 const GRAVITY_MULT = 0.8 @@ -20,8 +21,14 @@ var coins = 0 func _ready() -> void: pass +func refresh_dash(new_dashes): + if new_dashes: + dashes = new_dashes + else: + dashes = 1 + func refresh_jump(new_jumps): - if jumps: + if new_jumps: jumps = new_jumps else: jumps = 1 @@ -53,13 +60,16 @@ func _process(delta: float) -> void: if direction < 0: $Sprite2D.flip_h = true + $Sprite2D/HatSprite.flip_h = true elif direction > 0: $Sprite2D.flip_h = false + $Sprite2D/HatSprite.flip_h = false - if Input.is_action_just_pressed("dash"): + if Input.is_action_just_pressed("dash") and dashes > 0: dashing = true + dashes -= 1 velocity = Vector2( - Input.get_axis("dash_left","dash_right"), + Input.get_axis("dash_left","dash_right") * HORIZONTAL_DASH_MULT, Input.get_axis("dash_up","dash_down") ) * DASH_SPEED await get_tree().create_timer(DASH_LENGTH).timeout @@ -68,10 +78,12 @@ func _process(delta: float) -> void: elif direction and !dashing: velocity.x = direction * SPEED $Sprite2D.play("running") + $Sprite2D/HatSprite.play("running") elif !dashing: velocity.x = move_toward(velocity.x, 0, FRICTION) $Sprite2D.play("idle") + $Sprite2D/HatSprite.play("idle") #print("PLAYER X POSITION: " + str(position.y)) if position.y >= death_threshold: @@ -82,14 +94,17 @@ func _process(delta: float) -> void: if is_on_floor(): fall_timer = 0 refresh_jump(1) + refresh_dash(1) #%Player2D.get_node("Camera2D").position_smoothing_speed = %Player2D.CAMERA_SMOOTHING_SPEED if is_on_wall(): refresh_jump(1) + refresh_dash(1) #%Player2D.get_node("Camera2D").position_smoothing_speed = %Player2D.CAMERA_SMOOTHING_SPEED if is_on_ceiling(): refresh_jump(1) + refresh_dash(1) if fall_timer > 3: pass diff --git a/player_2d.tscn b/player_2d.tscn index 1008d11..6068900 100644 --- a/player_2d.tscn +++ b/player_2d.tscn @@ -1,12 +1,23 @@ [gd_scene format=3 uid="uid://pmnwck5v0ntm"] [ext_resource type="Script" uid="uid://cojhnj15psd2x" path="res://player_2d.gd" id="1_sy00s"] +[ext_resource type="Shader" uid="uid://mmf86jusrkrr" path="res://shaders/warp_shader.gdshader" id="3_gt2ls"] [ext_resource type="Texture2D" uid="uid://dpdxs6gjmexgh" path="res://art/background.png" id="3_p3026"] +[ext_resource type="Texture2D" uid="uid://biv3f67rqumak" path="res://art/level_start.png" id="4_nj6as"] +[ext_resource type="Script" uid="uid://3bqq3mfbby2c" path="res://warp_shader.gd" id="4_pmt5n"] [ext_resource type="Texture2D" uid="uid://lk0f1qyswyxv" path="res://art/player/running/frame1.png" id="5_6jyqn"] [ext_resource type="Texture2D" uid="uid://lmje8plw76e1" path="res://art/player/running/frame2.png" id="6_gt2ls"] [ext_resource type="AudioStream" uid="uid://8iiafankqo4i" path="res://sound/stepping.wav" id="7_cbsa3"] [ext_resource type="Texture2D" uid="uid://dh7a1knyqn5nd" path="res://art/player/running/frame3.png" id="7_pmt5n"] [ext_resource type="Texture2D" uid="uid://yf13nw31k8ua" path="res://art/player/running/frame4.png" id="8_nj6as"] +[ext_resource type="Texture2D" uid="uid://ba4kjeulthw1g" path="res://art/hats/dunce1.png" id="10_5s8kx"] +[ext_resource type="Texture2D" uid="uid://cp1v5uhvbfws6" path="res://art/hats/dunce2.png" id="11_4apft"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_pmt5n"] +shader = ExtResource("3_gt2ls") + +[sub_resource type="QuadMesh" id="QuadMesh_nj6as"] +size = Vector2(1280, 720) [sub_resource type="SpriteFrames" id="SpriteFrames_fvyjh"] animations = [{ @@ -39,12 +50,45 @@ animations = [{ "speed": 12.0 }] +[sub_resource type="SpriteFrames" id="SpriteFrames_pmt5n"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("10_5s8kx") +}], +"loop": 1, +"name": &"idle", +"speed": 6.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": ExtResource("11_4apft") +}, { +"duration": 1.0, +"texture": ExtResource("10_5s8kx") +}], +"loop": 1, +"name": &"running", +"speed": 6.0 +}] + [sub_resource type="RectangleShape2D" id="RectangleShape2D_fj7yv"] size = Vector2(10, 16) [node name="Player2D" type="CharacterBody2D" unique_id=889851478] script = ExtResource("1_sy00s") +[node name="CanvasLayer2" type="CanvasLayer" parent="." unique_id=1854423107] + +[node name="WarpShader" type="MeshInstance2D" parent="CanvasLayer2" unique_id=88397728] +material = SubResource("ShaderMaterial_pmt5n") +mesh = SubResource("QuadMesh_nj6as") +script = ExtResource("4_pmt5n") + +[node name="Sprite2D" type="Sprite2D" parent="CanvasLayer2/WarpShader" unique_id=1651549733] +visible = false +texture = ExtResource("4_nj6as") + [node name="Parallax2D" type="Parallax2D" parent="." unique_id=270393374] repeat_size = Vector2(1, 1) @@ -56,7 +100,6 @@ texture = ExtResource("3_p3026") zoom = Vector2(1.75, 1.75) process_callback = 0 position_smoothing_enabled = true -position_smoothing_speed = 3.0 [node name="Sprite2D" type="AnimatedSprite2D" parent="." unique_id=693422376] z_index = 1 @@ -65,7 +108,16 @@ position = Vector2(0, 2) sprite_frames = SubResource("SpriteFrames_fvyjh") animation = &"running" autoplay = "idle" -frame_progress = 0.48246452 +frame_progress = 0.87170494 + +[node name="HatSprite" type="AnimatedSprite2D" parent="Sprite2D" unique_id=1954184475] +visible = false +position = Vector2(0, -13) +scale = Vector2(0.9, 0.9) +sprite_frames = SubResource("SpriteFrames_pmt5n") +animation = &"running" +autoplay = "idle" +frame_progress = 0.1718222 [node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1294571021] shape = SubResource("RectangleShape2D_fj7yv") diff --git a/project.godot b/project.godot index 07f4a3f..523d414 100644 --- a/project.godot +++ b/project.godot @@ -17,8 +17,9 @@ config/icon="res://icon.svg" [display] +window/size/viewport_width=1280 +window/size/viewport_height=720 window/stretch/mode="canvas_items" -window/stretch/aspect="expand" [gui] diff --git a/shaders/warp_shader.gdshader b/shaders/warp_shader.gdshader new file mode 100644 index 0000000..46cb8b2 --- /dev/null +++ b/shaders/warp_shader.gdshader @@ -0,0 +1,20 @@ +// Thanks YouTube and DevPoodle +// https://www.youtube.com/watch?v=E401x98N6iA + +shader_type canvas_item; +render_mode unshaded, skip_vertex_transform; + +const float curvature = 3.2; + +uniform sampler2D screen_texture: hint_screen_texture; + +void fragment() { + vec2 centered_uv = SCREEN_UV * 2.0 - 1.0; + vec2 uv_offset = centered_uv.yx / curvature; + vec2 warped_uv = centered_uv + centered_uv * uv_offset * uv_offset; + vec3 cutoff = vec3(step(abs(warped_uv.x), 1.0) * step(abs(warped_uv.y), 1.0)); + + vec3 screen_color = texture(screen_texture, (warped_uv + 1.0) / 2.0).rgb; + //COLOR = vec4(warped_uv, 0.0, 1.0); + COLOR = texture(screen_texture, (warped_uv + 1.0) / 2.0); +} diff --git a/shaders/warp_shader.gdshader.uid b/shaders/warp_shader.gdshader.uid new file mode 100644 index 0000000..66f66a4 --- /dev/null +++ b/shaders/warp_shader.gdshader.uid @@ -0,0 +1 @@ +uid://mmf86jusrkrr diff --git a/warp_shader.gd b/warp_shader.gd new file mode 100644 index 0000000..77095fb --- /dev/null +++ b/warp_shader.gd @@ -0,0 +1,16 @@ +extends MeshInstance2D + +var crt_shader = preload("res://shaders/warp_shader.gdshader") + +func _ready() -> void: + pass + + # Adjust some uniforms + #material.set_shader_param("brightness", 1.2) + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + print(DisplayServer.window_get_size().x) + print(DisplayServer.window_get_size().y) + mesh.size.x = DisplayServer.window_get_size().x * 4 + mesh.size.y = DisplayServer.window_get_size().y * 4 diff --git a/warp_shader.gd.uid b/warp_shader.gd.uid new file mode 100644 index 0000000..d580b7c --- /dev/null +++ b/warp_shader.gd.uid @@ -0,0 +1 @@ +uid://3bqq3mfbby2c diff --git a/world.tscn b/world.tscn index cd23b58..095017f 100644 --- a/world.tscn +++ b/world.tscn @@ -16,30 +16,6 @@ process_mode = 3 scale = Vector2(1, 1.0155824) -[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1982310971] - -[node name="RichTextLabel2" type="RichTextLabel" parent="CanvasLayer" unique_id=1423365940] -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -bbcode_enabled = true -text = "FPS:" -script = ExtResource("2_dwbse") - -[node name="RichTextLabel3" type="RichTextLabel" parent="CanvasLayer" unique_id=1876455502] -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_top = 23.0 -offset_bottom = 23.0 -grow_horizontal = 2 -grow_vertical = 2 -bbcode_enabled = true -text = "COINS:" -script = ExtResource("3_wse8f") - [node name="Player2D" parent="." unique_id=889851478 instance=ExtResource("1_aqk2v")] unique_name_in_owner = true position = Vector2(55, 59) @@ -100,3 +76,27 @@ position = Vector2(166, 200) [node name="VerticalLongBlock" parent="ZoeLevel" unique_id=1984351408 instance=ExtResource("4_pkg7o")] position = Vector2(250, 141) + +[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1637221343] + +[node name="RichTextLabel2" type="RichTextLabel" parent="CanvasLayer" unique_id=1254950785] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +bbcode_enabled = true +text = "FPS:" +script = ExtResource("2_dwbse") + +[node name="RichTextLabel3" type="RichTextLabel" parent="CanvasLayer" unique_id=63830958] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = 23.0 +offset_bottom = 23.0 +grow_horizontal = 2 +grow_vertical = 2 +bbcode_enabled = true +text = "COINS:" +script = ExtResource("3_wse8f")