Tutorial8

master
Sascha 2023-09-12 17:06:09 +07:00
parent 7b2bdc6d9f
commit 356f3bbffb
17 changed files with 163 additions and 5 deletions

Binary file not shown.

@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://dk56ingpxu1bn"
path="res://.godot/imported/Music.ogg-956be33a73d9fab5a3f6ac39a667a4b9.oggvorbisstr"
[deps]
source_file="res://Audio/Music.ogg"
dest_files=["res://.godot/imported/Music.ogg-956be33a73d9fab5a3f6ac39a667a4b9.oggvorbisstr"]
[params]
loop=true
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://bad3sgxp8w71p"
path="res://.godot/imported/SFX_footstep01_01.wav-5a5d6681b333c000b7772cbe18584144.sample"
[deps]
source_file="res://Audio/SFX_footstep01_01.wav"
dest_files=["res://.godot/imported/SFX_footstep01_01.wav-5a5d6681b333c000b7772cbe18584144.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

Binary file not shown.

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://bmwqhempgwh82"
path="res://.godot/imported/SFX_footstep01_02.wav-3f1441192f96cd245b241b041c6b096e.sample"
[deps]
source_file="res://Audio/SFX_footstep01_02.wav"
dest_files=["res://.godot/imported/SFX_footstep01_02.wav-3f1441192f96cd245b241b041c6b096e.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

Binary file not shown.

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://cltl0wct3ep3k"
path="res://.godot/imported/SFX_footstep02_01.wav-d547c084fc19ab6cef553cef01d4b9d1.sample"
[deps]
source_file="res://Audio/SFX_footstep02_01.wav"
dest_files=["res://.godot/imported/SFX_footstep02_01.wav-d547c084fc19ab6cef553cef01d4b9d1.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

Binary file not shown.

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://cwb8shbqicowk"
path="res://.godot/imported/SFX_footstep02_02.wav-33f9b6d4fb482bcb0513e1fe50eb6b42.sample"
[deps]
source_file="res://Audio/SFX_footstep02_02.wav"
dest_files=["res://.godot/imported/SFX_footstep02_02.wav-33f9b6d4fb482bcb0513e1fe50eb6b42.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

@ -1,6 +1,7 @@
[gd_scene load_steps=3 format=3 uid="uid://bkvgqv8jki0us"]
[gd_scene load_steps=4 format=3 uid="uid://bkvgqv8jki0us"]
[ext_resource type="Script" path="res://Scripts/Character.cs" id="2_7gv41"]
[ext_resource type="AudioStream" uid="uid://bad3sgxp8w71p" path="res://Audio/SFX_footstep01_01.wav" id="3_53rr5"]
[ext_resource type="Texture2D" uid="uid://driormxb3in5o" path="res://Icons/Male_2_Idle0.png" id="3_w4es2"]
[node name="Character" type="Node"]
@ -34,3 +35,6 @@ max_value = 354.0
step = 1.0
value = 67.0
rounded = true
[node name="WalkingSound" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("3_53rr5")

@ -0,0 +1,7 @@
{
"disabled_classes": [],
"disabled_editors": [],
"disabled_features": [],
"disabled_properties": [],
"type": "feature_profile"
}

@ -3,6 +3,7 @@ using Godot;
namespace Tutorial1.Scripts;
public partial class Button : Godot.Button {
private RandomNumberGenerator random = new();
private PackedScene packedScene;
public override void _Ready() {
Pressed += OnPressed;
@ -14,7 +15,6 @@ public partial class Button : Godot.Button {
AddChild(character);
Sprite2D sprite2D = character.GetChild<Sprite2D>(0);
RandomNumberGenerator random = new();
random.Randomize();
sprite2D.GlobalPosition = new(random.RandiRange(100,1000), random.RandiRange(100,1000));

@ -1,12 +1,32 @@
using System.Collections.Generic;
using System.Linq;
using Godot;
namespace Tutorial1.Scripts;
public partial class Character : Node {
[Export] private float speed = 300;
private Sprite2D sprite2D;
public override void _Ready() => sprite2D = GetChild<Sprite2D>(0);
private AudioStreamPlayer2D walkingSound;
public override void _Ready() {
sprite2D = GetChild<Sprite2D>(0);
walkingSound = GetChildren().First(node => node.Name == "WalkingSound") as AudioStreamPlayer2D;
walkingSound.Stream = GD.Load<AudioStream>("res://Audio/SFX_footstep01_01.wav");
}
public override void _UnhandledInput(InputEvent @event) {
if (@event is InputEventMouseButton { Pressed: true } buttonEvent) sprite2D.Position = buttonEvent.GlobalPosition;
}
public override void _Process(double delta) {
float moveAmount = speed * (float)delta;
Vector2 moveVector = new();
if (Input.IsKeyPressed(Key.W)) moveVector.Y -= moveAmount;
if (Input.IsKeyPressed(Key.S)) moveVector.Y += moveAmount;
if (Input.IsKeyPressed(Key.A)) moveVector.X -= moveAmount;
if (Input.IsKeyPressed(Key.D)) moveVector.X += moveAmount;
sprite2D.Position += moveVector;
if (moveVector != Vector2.Zero && !walkingSound.Playing) walkingSound.Play();
}
}

@ -1,6 +1,7 @@
<Project Sdk="Godot.NET.Sdk/4.1.1">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
<LangVersion>11</LangVersion>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
</Project>

@ -1,8 +1,9 @@
[gd_scene load_steps=5 format=3 uid="uid://cefeqjem0f3wo"]
[gd_scene load_steps=6 format=3 uid="uid://cefeqjem0f3wo"]
[ext_resource type="Script" path="res://Scripts/World.cs" id="1_4gg20"]
[ext_resource type="Texture2D" uid="uid://dc1t7wtq620d" path="res://Icons/barrels_E.png" id="2_i6vvh"]
[ext_resource type="Texture2D" uid="uid://d0ft51rdr6k02" path="res://Icons/Godot.svg" id="3_6nyvq"]
[ext_resource type="AudioStream" uid="uid://dk56ingpxu1bn" path="res://Audio/Music.ogg" id="5_mfedj"]
[ext_resource type="Script" path="res://Scripts/Button.cs" id="5_tbcjx"]
[node name="World" type="Node2D"]
@ -90,3 +91,9 @@ size_flags_horizontal = 3
size_flags_vertical = 1
size_flags_stretch_ratio = 2.0
value = 33.0
[node name="BackgroundMusic" type="AudioStreamPlayer2D" parent="."]
position = Vector2(588, 313)
stream = ExtResource("5_mfedj")
volume_db = -15.0
attenuation = 0.5

@ -18,3 +18,7 @@ config/icon="res://Icons/Godot.svg"
[dotnet]
project/assembly_name="Tutorial1"
[layer_names]
2d_physics/layer_1="Background"