diff --git a/DungeonShooting_Godot/project.godot b/DungeonShooting_Godot/project.godot index 83159ea..5224fa6 100644 --- a/DungeonShooting_Godot/project.godot +++ b/DungeonShooting_Godot/project.godot @@ -11,7 +11,7 @@ [application] config/name="DungeonShooting" -run/main_scene="res://scene/Main.tscn" +run/main_scene="res://scene/test/TestDrawSprite.tscn" config/features=PackedStringArray("4.2", "C#") config/icon="res://icon.png" @@ -21,8 +21,8 @@ [display] -window/size/viewport_width=1920 -window/size/viewport_height=1080 +window/size/viewport_width=1600 +window/size/viewport_height=900 window/stretch/aspect="keep_width" window/vsync/use_vsync=false diff --git a/DungeonShooting_Godot/scene/test/TestDrawSprite.tscn b/DungeonShooting_Godot/scene/test/TestDrawSprite.tscn new file mode 100644 index 0000000..a777b39 --- /dev/null +++ b/DungeonShooting_Godot/scene/test/TestDrawSprite.tscn @@ -0,0 +1,31 @@ +[gd_scene load_steps=3 format=3 uid="uid://gby5bfwuu4kx"] + +[ext_resource type="Script" path="res://src/test/TestDrawSprite.cs" id="1_tplub"] + +[sub_resource type="Curve2D" id="Curve2D_ft6ap"] +_data = { +"points": PackedVector2Array(0, 0, 0, 0, 29, 41, 0, 0, 0, 0, 1547, 34, 0, 0, 0, 0, 1544, 863, 0, 0, 0, 0, 39, 848, 0, 0, 0, 0, 828, 387, 0, 0, 0, 0, 42, 54) +} +point_count = 6 + +[node name="TestDrawSprite" type="Node2D" node_paths=PackedStringArray("FpsLabel", "PathFollow2D")] +script = ExtResource("1_tplub") +FpsLabel = NodePath("CanvasLayer/Fps") +PathFollow2D = NodePath("Path2D/PathFollow2D") + +[node name="CanvasLayer" type="CanvasLayer" parent="."] + +[node name="Fps" type="Label" parent="CanvasLayer"] +offset_left = 34.0 +offset_top = 31.0 +offset_right = 43.0 +offset_bottom = 71.0 + +[node name="Path2D" type="Path2D" parent="."] +curve = SubResource("Curve2D_ft6ap") + +[node name="PathFollow2D" type="PathFollow2D" parent="Path2D"] +position = Vector2(29, 41) +rotation = -0.0046113 + +[node name="Camera2D" type="Camera2D" parent="Path2D/PathFollow2D"] diff --git a/DungeonShooting_Godot/src/framework/activity/ActivityMaterial.cs b/DungeonShooting_Godot/src/framework/activity/ActivityMaterial.cs index a233c8e..2bfe027 100644 --- a/DungeonShooting_Godot/src/framework/activity/ActivityMaterial.cs +++ b/DungeonShooting_Godot/src/framework/activity/ActivityMaterial.cs @@ -7,7 +7,7 @@ /// /// 摩擦力 /// - public float Friction { get; set; } = 100; + public float Friction { get; set; } = 120; /// /// 落地之后是否回弹 diff --git a/DungeonShooting_Godot/src/test/TestDrawSprite.cs b/DungeonShooting_Godot/src/test/TestDrawSprite.cs new file mode 100644 index 0000000..a6afacf --- /dev/null +++ b/DungeonShooting_Godot/src/test/TestDrawSprite.cs @@ -0,0 +1,82 @@ +using Godot; +using System; +using System.Collections.Generic; + +public partial class TestDrawSprite : Node2D +{ + [Export] + public Label FpsLabel; + + [Export] + public PathFollow2D PathFollow2D; + + public override void _Ready() + { + + } + + public override void _Process(double delta) + { + FpsLabel.Text = "FPS: " + 1 / delta; + PathFollow2D.Progress += 200 * (float)delta; + } + + //使用sprite2d绘制精灵 + // public override void _Ready() + // { + // for (int i = 0; i < 20000; i++) + // { + // var image = Image.Create(50, 50, false, Image.Format.Rgba8); + // image.Fill(new Color(Utils.Random.RandomRangeFloat(0, 1), Utils.Random.RandomRangeFloat(0, 1), Utils.Random.RandomRangeFloat(0, 1), Utils.Random.RandomRangeFloat(0, 1))); + // var imageTexture = ImageTexture.CreateFromImage(image); + // var sprite2D = new Sprite2D(); + // sprite2D.Texture = imageTexture; + // sprite2D.Centered = false; + // sprite2D.Scale = new Vector2(Utils.Random.RandomRangeFloat(0.2f, 2f), Utils.Random.RandomRangeFloat(0.2f, 2f)); + // sprite2D.Rotation = Utils.Random.RandomRangeFloat(0, Mathf.Pi); + // sprite2D.Position = new Vector2(Utils.Random.RandomRangeInt(0, 1600), Utils.Random.RandomRangeInt(0, 900)); + // AddChild(sprite2D); + // } + // } + + //尝试使用DrawTexture绘制texture,结果发现性比sprite2d还差 + // private class DrawTextureData + // { + // public Texture2D Texture2D; + // public Vector2 Position; + // public float Rotation; + // public Vector2 Scale; + // } + // private List _texture2Ds = new List(); + + // public override void _Ready() + // { + // for (int i = 0; i < 10000; i++) + // { + // var image = Image.Create(100, 100, false, Image.Format.Rgba8); + // image.Fill(new Color(Utils.Random.RandomRangeFloat(0, 1), Utils.Random.RandomRangeFloat(0, 1), Utils.Random.RandomRangeFloat(0, 1), Utils.Random.RandomRangeFloat(0, 1))); + // var imageTexture = ImageTexture.CreateFromImage(image); + // _texture2Ds.Add(new DrawTextureData() + // { + // Texture2D = imageTexture, + // Position = new Vector2(Utils.Random.RandomRangeInt(0, 1600), Utils.Random.RandomRangeInt(0, 900)), + // Rotation = Utils.Random.RandomRangeFloat(0, Mathf.Pi), + // Scale = new Vector2(Utils.Random.RandomRangeFloat(0.2f, 2f), Utils.Random.RandomRangeFloat(0.2f, 2f)) + // }); + // } + // } + // + // public override void _Process(double delta) + // { + // QueueRedraw(); + // } + // + // public override void _Draw() + // { + // foreach (var texture2D in _texture2Ds) + // { + // DrawSetTransform(texture2D.Position, texture2D.Rotation, texture2D.Scale); + // DrawTexture(texture2D.Texture2D, Vector2.Zero); + // } + // } +}