From 183c678d69320a16d2ccd6af251fb66fd466e2d1 Mon Sep 17 00:00:00 2001 From: vaporvee Date: Sat, 10 Dec 2022 14:54:00 +0100 Subject: [PATCH] new player avatar --- assets/textures/debug/dummy-player-normal.png | Bin 0 -> 567 bytes .../debug/dummy-player-normal.png.import | 34 ++++++++++++++++++ scenes/player.tscn | 11 +++--- src/scene-scripts/player.cs | 13 +++---- 4 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 assets/textures/debug/dummy-player-normal.png create mode 100644 assets/textures/debug/dummy-player-normal.png.import diff --git a/assets/textures/debug/dummy-player-normal.png b/assets/textures/debug/dummy-player-normal.png new file mode 100644 index 0000000000000000000000000000000000000000..4bd813b78e1b294a848a9ce598860a39f28a52d6 GIT binary patch literal 567 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H3?#oinD`S&F%}28J29*~C-V}>VM%xNb!1@J z*w6hZkrl`n4e$wZ1=8;h&st+-Bqk)!6HwceO6r% zFO*)ee%IajXJH2}az`Y%GFs)!v&!t9bnH7zN#uk7tS@eeT>tRIN9#W0iERg}SwvPf zoo~v}(KvrhRcFH@2a`X6>sh0@V|)}&yGBlW{cCoQC(w+>mc{H}XR@x-KJbZ?JK_M- zby0z(M>vw79%2&Pa6pU6X<<{JnvLb;Q{@bsbU)ZNy0Cu9wFsXRk)X;bsuIt;qw2s7 zMzILThCOMS{KxpDbPRSgNG?Aue9T%GB)TT?mE_yb?1aXdtWl0SyI;&r$ZkB!>eANX zVbic&x+5o{@h0o1cIAbOx&50T%ZqWZQBc?-R#NitW!kh8Y+^G)6@>mNJPv4hy(2xd zk(e1@7kbP0l+XkKP7vOx literal 0 HcmV?d00001 diff --git a/assets/textures/debug/dummy-player-normal.png.import b/assets/textures/debug/dummy-player-normal.png.import new file mode 100644 index 0000000..868c79a --- /dev/null +++ b/assets/textures/debug/dummy-player-normal.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c3ep33iycax04" +path="res://.godot/imported/dummy-player-normal.png-45a5eb1f003876b79db5d133686dde95.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/debug/dummy-player-normal.png" +dest_files=["res://.godot/imported/dummy-player-normal.png-45a5eb1f003876b79db5d133686dde95.ctex"] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +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/scenes/player.tscn b/scenes/player.tscn index 6cdc1b8..cf446b8 100644 --- a/scenes/player.tscn +++ b/scenes/player.tscn @@ -1,19 +1,19 @@ [gd_scene load_steps=5 format=3 uid="uid://ujfhvssvbgpg"] [ext_resource type="Script" path="res://src/scene-scripts/player.cs" id="1_qehox"] -[ext_resource type="Texture2D" uid="uid://ciidukjv5k6oa" path="res://assets/textures/debug/banana.png" id="2_1l1co"] +[ext_resource type="Texture2D" uid="uid://c3ep33iycax04" path="res://assets/textures/debug/dummy-player-normal.png" id="2_48656"] [sub_resource type="SpriteFrames" id="SpriteFrames_2x1cy"] animations = [{ -"frames": [ExtResource("2_1l1co")], +"frames": [ExtResource("2_48656")], "loop": true, "name": &"default", "speed": 5.0 }] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_38v5o"] -radius = 21.0 -height = 66.0 +radius = 43.0 +height = 132.0 [node name="player" type="CharacterBody2D"] process_mode = 1 @@ -23,6 +23,7 @@ script = ExtResource("1_qehox") frames = SubResource("SpriteFrames_2x1cy") [node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(0, 1) shape = SubResource("CapsuleShape2D_38v5o") [node name="Camera2D" type="Camera2D" parent="."] @@ -30,6 +31,6 @@ current = true zoom = Vector2(0.8, 0.8) [node name="ray_cast_2d" type="RayCast2D" parent="."] -target_position = Vector2(0, 64) +target_position = Vector2(0, 128) collision_mask = 2 collide_with_areas = true diff --git a/src/scene-scripts/player.cs b/src/scene-scripts/player.cs index 399cbec..7fb9eb9 100644 --- a/src/scene-scripts/player.cs +++ b/src/scene-scripts/player.cs @@ -25,16 +25,13 @@ public partial class player : CharacterBody2D public override void _Process(double delta) { //set ray_cast target position - if (Input.IsActionJustPressed("move_right")) GetNode("ray_cast_2d").TargetPosition = new Vector2(64, 0); - if (Input.IsActionJustPressed("move_left")) GetNode("ray_cast_2d").TargetPosition = new Vector2(-64, 0); - if (Input.IsActionJustPressed("move_down")) GetNode("ray_cast_2d").TargetPosition = new Vector2(0, 64); - if (Input.IsActionJustPressed("move_up")) GetNode("ray_cast_2d").TargetPosition = new Vector2(0, -64); + if (Input.IsActionJustPressed("move_right")) GetNode("ray_cast_2d").TargetPosition = new Vector2(128, 0); + if (Input.IsActionJustPressed("move_left")) GetNode("ray_cast_2d").TargetPosition = new Vector2(-128, 0); + if (Input.IsActionJustPressed("move_down")) GetNode("ray_cast_2d").TargetPosition = new Vector2(0, 128); + if (Input.IsActionJustPressed("move_up")) GetNode("ray_cast_2d").TargetPosition = new Vector2(0, -128); //call event in raycasted object if (Input.IsActionJustPressed("ui_accept") && GetNode("ray_cast_2d").IsColliding()) - { - var raycastedObject = GetNode("ray_cast_2d").GetCollider(); - raycastedObject.Call("OnInteraction", playerName); - } + GetNode("ray_cast_2d").GetCollider().Call("OnInteraction", playerName); } }