Skip to content

Commit

Permalink
ci:fix rust ci
Browse files Browse the repository at this point in the history
feat:improve rust antimation
feat:star wrath development
  • Loading branch information
limuy2022 committed Jun 29, 2024
1 parent 5f4e189 commit af8d6ef
Show file tree
Hide file tree
Showing 13 changed files with 145 additions and 78 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/rust_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
- name: Config Env
run: rustup install nightly && rustup default nightly && rustup component add rustfmt
- name: Build
run: cd gdrust && cargo build --all
run: cd gdrust && cargo build --package proto --features protobuf_feature --all
- name: Build Release
run: cd gdrust && cargo build --all --release
run: cd gdrust && cargo build --package proto --features protobuf_feature --all --release
- name: Run tests Debug
run: cd gdrust && cargo test --all
- name: Run tests Release
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rust_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
- name: Config Env
run: rustup install nightly && rustup default nightly
- name: Build
run: cd gdrust && cargo build --all
run: cd gdrust && cargo build --package proto --features protobuf_feature --all
- name: Build Release
run: cd gdrust && cargo build --all --release
run: cd gdrust && cargo build --package proto --features protobuf_feature --all --release
- name: Run tests Debug
run: cd gdrust && cargo test --all
- name: Run tests Release
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rust_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
- name: Config Env
run: rustup install nightly && rustup default nightly
- name: Build
run: cd gdrust && cargo build --all
run: cd gdrust && cargo build --package proto --features protobuf_feature --all
- name: Build Release
run: cd gdrust && cargo build --all --release
run: cd gdrust && cargo build --package proto --features protobuf_feature --all --release
- name: Run tests Debug
run: cd gdrust && cargo test --all
- name: Run tests Release
Expand Down
2 changes: 1 addition & 1 deletion docs/build-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Rust Compiler |

Regarding the Protobuf Compiler, we first check for the existence of a local protoc executable. If a usable compiler is found, it will be utilized directly. For certain special requirements, such as when the protoc version is too low, we also provide an option to
automatically compile a bundled protoc. This option is turned off by default and can be enabled by using cargo build --package proto --features protobuf_feature. Note that this option may significantly increase your build directory size and extend the build time by
automatically compile a bundled protoc. This option is turned off by default and can be enabled by using `cargo build --package proto --features protobuf_feature`. Note that this option may significantly increase your build directory size and extend the build time by
several times. It is still recommended to install protoc in advance.

Then you can run `cd script && python build.py` to build the extension (both Debug and Release)
Expand Down
14 changes: 12 additions & 2 deletions gdrust/src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,19 +235,29 @@ impl Player {
self.base().get_node_as("Shield")
}

const GENERAL_HIDE:&'static str = "general_hide";
const SHOW_WRAPPER:&'static str = "show_wrapper";

#[debug]
fn check_method(&self) {
let shield = self.get_shield();
assert!(shield.has_method(Self::GENERAL_HIDE.into()));
assert!(shield.has_method(Self::SHOW_WRAPPER.into()));
}

/// 启动克盾保护
#[func]
fn turn_on_shield(&mut self) {
let mut shield = self.get_shield();
shield.set_rotation(self.cthulhu_rad());
shield.show();
shield.call(Self::SHOW_WRAPPER.into(), &[]);
}

/// 关闭克盾保护
#[func]
fn turn_off_shield(&mut self) {
let mut shield = self.get_shield();
shield.hide();
shield.call(Self::GENERAL_HIDE.into(), &[]);
}

#[debug]
Expand Down
26 changes: 10 additions & 16 deletions gdrust/src/weapons/star_wrath.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::bullets::star_wrath_bullet::StarWrathBullet;
use crate::debug_check;
use godot::classes::{AnimationTree, Area2D, IArea2D, Timer};
use godot::engine::AnimationPlayer;
use godot::obj::WithBaseField;
use godot::prelude::*;

Expand Down Expand Up @@ -33,7 +34,7 @@ impl IArea2D for StarWrath {
}

fn process(&mut self, delta: f64) {
let mut animation = self.get_animation();
// let mut animation = self.get_animation();
// animation.play_ex().name("Wave".into()).done();
// if !animation.is_playing() {
// animation.play_ex().name("Float".into()).done();
Expand All @@ -48,16 +49,7 @@ impl IArea2D for StarWrath {
}

fn ready(&mut self) {
// for debug
// 检查是否是当前场景
debug_check!(self);
if self.base().get_tree().unwrap().get_current_scene().unwrap()
== self.base().clone().upcast()
{
self.start();
} else {
self.base_mut().hide();
}
}
}

Expand All @@ -84,22 +76,24 @@ impl StarWrath {
self.new_bullet()
}

#[debug]
fn get_fight_timer(&self) -> Gd<Timer> {
self.base().get_node_as::<Timer>("FightTimer")
#[func]
fn get_animation(&self) -> Gd<AnimationPlayer> {
self.base().get_node_as("AnimationPlayer")
}

#[debug]
fn get_animation(&self) -> Gd<AnimationTree> {
self.base().get_node_as::<AnimationTree>("AnimationTree")
fn get_fight_timer(&self) -> Gd<Timer> {
self.base().get_node_as::<Timer>("FightTimer")
}

#[func]
fn start(&mut self) {
let mut fight_time = self.get_fight_timer();
fight_time.start();
self.start_flag = true;
self.new_bullet()
self.new_bullet();
let mut anmi = self.get_animation();
anmi.play_ex().name("enter_scene".into()).done();
}

#[signal]
Expand Down
Binary file modified resources/images/shields/shield.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/images/shields/shield.xcf
Binary file not shown.
16 changes: 11 additions & 5 deletions scenes/fight.tscn
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[gd_scene load_steps=24 format=3 uid="uid://cibwxaqnuodid"]
[gd_scene load_steps=25 format=3 uid="uid://cibwxaqnuodid"]

[ext_resource type="Texture2D" uid="uid://cqp3l8q7xbxrt" path="res://resources/images/weapons/Zenith.webp" id="3_2spkb"]
[ext_resource type="Texture2D" uid="uid://b5jjl8np5jm6q" path="res://resources/images/shields/shield.png" id="3_bdq2j"]
[ext_resource type="PackedScene" uid="uid://dn2ixin15jtt3" path="res://scenes/weapons/star_wrath.tscn" id="4_8ipx5"]
[ext_resource type="Texture2D" uid="uid://c71fsdux0i1r3" path="res://resources/images/PlayerHeart/Default/000.png" id="5_3ufqu"]
[ext_resource type="Script" path="res://scripts/shield.gd" id="5_q7jwc"]
[ext_resource type="Texture2D" uid="uid://b37v3b41jrx1x" path="res://resources/images/UI/UIFight/Default/000.png" id="6_5cs44"]
[ext_resource type="Texture2D" uid="uid://dscxanl5ikwrj" path="res://resources/images/UI/UIFight/Highlight/000.png" id="7_rklqi"]
[ext_resource type="Texture2D" uid="uid://cvx31mw3e38mx" path="res://resources/images/UI/UIAct/Default/000.png" id="8_yjyfq"]
Expand All @@ -18,7 +19,7 @@
[ext_resource type="Texture2D" uid="uid://drljhif31i83o" path="res://resources/images/UI/CategoryPanel.png" id="14_miw1s"]

[sub_resource type="Gradient" id="Gradient_w6p7b"]
offsets = PackedFloat32Array(0.315, 0.38125, 0.7, 0.814583, 1)
offsets = PackedFloat32Array(0.386487, 0.391892, 0.397297, 0.683784, 1)
colors = PackedColorArray(0, 0, 0, 1, 0, 0, 0, 1, 0.327103, 0.327103, 0.327103, 1, 0.584112, 0.584112, 0.584112, 1, 1, 1, 1, 1)

[sub_resource type="GradientTexture1D" id="GradientTexture1D_0mtog"]
Expand Down Expand Up @@ -85,13 +86,15 @@ platform_floor_layers = 0
platform_wall_layers = 4294967295

[node name="virtual" type="GPUParticles2D" parent="Player"]
scale = Vector2(0.996328, 1)
emitting = false
amount = 6
amount = 10
process_material = SubResource("ParticleProcessMaterial_adfmi")
texture = ExtResource("5_3ufqu")
lifetime = 0.1
lifetime = 0.2
speed_scale = 2.0
trail_lifetime = 0.5
trail_sections = 100

[node name="HitPoint" type="CollisionShape2D" parent="Player"]
shape = SubResource("CircleShape2D_yfrnq")
Expand All @@ -115,14 +118,17 @@ one_shot = true

[node name="Shield" type="Area2D" parent="Player"]
visible = false
z_index = 1
script = ExtResource("5_q7jwc")

[node name="Shield" type="Sprite2D" parent="Player/Shield"]
position = Vector2(95, -5)
scale = Vector2(5, 6)
scale = Vector2(8.37652, 17.2)
texture = ExtResource("3_bdq2j")

[node name="Protect" type="CollisionShape2D" parent="Player/Shield"]
position = Vector2(110, -5)
scale = Vector2(2.81964, 2.6714)
shape = SubResource("CapsuleShape2D_g5ci8")

[node name="BlockDrawer" type="BlockDrawer" parent="."]
Expand Down
90 changes: 42 additions & 48 deletions scenes/weapons/star_wrath.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
[gd_scene load_steps=11 format=3 uid="uid://dn2ixin15jtt3"]

[ext_resource type="Script" path="res://scripts/weapons/star_wrath.gd" id="1_bo25j"]
[ext_resource type="Texture2D" uid="uid://wf3fpixhk4by" path="res://resources/images/weapons/Star_Wrath.webp" id="1_rb7dw"]
[ext_resource type="Shader" path="res://shaders/purple.gdshader" id="2_xksic"]

[sub_resource type="ShaderMaterial" id="ShaderMaterial_t64wj"]
shader = ExtResource("2_xksic")

[sub_resource type="RectangleShape2D" id="RectangleShape2D_qm46a"]
size = Vector2(28.6936, 31.8029)
Expand Down Expand Up @@ -64,73 +69,62 @@ tracks/1/keys = {
"values": []
}

[sub_resource type="Animation" id="Animation_j4myy"]
resource_name = "enter_scene"
length = 0.5
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.5),
"transitions": PackedFloat32Array(1, 2.54912),
"update": 0,
"values": [Vector2(-6.10352e-05, 1.99994), Vector2(250, 165)]
}

[sub_resource type="AnimationLibrary" id="AnimationLibrary_julpp"]
_data = {
"Float": SubResource("Animation_i5jfn"),
"RESET": SubResource("Animation_ftjfs"),
"Wave": SubResource("Animation_o8rnv")
"Wave": SubResource("Animation_o8rnv"),
"enter_scene": SubResource("Animation_j4myy")
}

[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_f2u5f"]
animation = &"Wave"

[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_eoxxg"]
animation = &"Float"

[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_xm082"]
[node name="StarWrath" type="Node"]
script = ExtResource("1_bo25j")

[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_rpkys"]
nodes/Animation/node = SubResource("AnimationNodeAnimation_eoxxg")
nodes/Animation/position = Vector2(40, 0)
"nodes/Animation 2/node" = SubResource("AnimationNodeAnimation_f2u5f")
"nodes/Animation 2/position" = Vector2(40, 140)
nodes/Blend2/node = SubResource("AnimationNodeBlend2_xm082")
nodes/Blend2/position = Vector2(280, 0)
nodes/output/position = Vector2(480, 60)
node_connections = [&"Blend2", 0, &"Animation", &"Blend2", 1, &"Animation 2", &"output", 0, &"Blend2"]
[node name="ColorRect" type="ColorRect" parent="."]
material = SubResource("ShaderMaterial_t64wj")
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -1.52588e-05
grow_horizontal = 2
grow_vertical = 2

[node name="StarWrath" type="StarWrath"]
[node name="StarWrath" type="StarWrath" parent="."]
z_index = 1
position = Vector2(554, 286)
rotation = 0.202369
rotation = -0.253092

[node name="StarWrath" type="Sprite2D" parent="."]
[node name="StarWrath" type="Sprite2D" parent="StarWrath"]
scale = Vector2(2.97559, 2.97559)
texture = ExtResource("1_rb7dw")
offset = Vector2(-0.33606, -1.0082)
flip_h = true

[node name="FightTimer" type="Timer" parent="."]
[node name="FightTimer" type="Timer" parent="StarWrath"]
editor_description = "Debug"

[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(-20.1263, -13.6814)
rotation = 0.792934
[node name="CollisionShape2D" type="CollisionShape2D" parent="StarWrath"]
rotation = 2.30812
scale = Vector2(4.2, 1)
shape = SubResource("RectangleShape2D_qm46a")

[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
[node name="AnimationPlayer" type="AnimationPlayer" parent="StarWrath"]
libraries = {
"": SubResource("AnimationLibrary_julpp")
}

[node name="AnimationTree" type="AnimationTree" parent="."]
tree_root = SubResource("AnimationNodeBlendTree_rpkys")
anim_player = NodePath("../AnimationPlayer")
parameters/current_length = 1.5
parameters/current_position = 0.449277
parameters/current_delta = 0.0166667
parameters/Animation/current_length = 1.5
parameters/Animation/current_position = 0.449277
parameters/Animation/current_delta = 0.0166667
"parameters/Animation 2/current_length" = 1.0
"parameters/Animation 2/current_position" = 1.0
"parameters/Animation 2/current_delta" = 0.0
parameters/Blend2/current_length = 1.5
parameters/Blend2/current_position = 0.449277
parameters/Blend2/current_delta = 0.0166667
parameters/Blend2/blend_amount = 0.5
parameters/output/current_length = 1.5
parameters/output/current_position = 0.449277
parameters/output/current_delta = 0.0166667

[connection signal="timeout" from="FightTimer" to="." method="on_fight_timer_timeout"]
[connection signal="timeout" from="StarWrath/FightTimer" to="StarWrath" method="on_fight_timer_timeout"]
25 changes: 25 additions & 0 deletions scripts/shield.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
extends Area2D


# Called when the node enters the scene tree for the first time.
func _ready() -> void:
#print(self.modulate.a)
pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta: float) -> void:
pass


func general_hide():
var tween = create_tween()
var cp = self.modulate
cp.a = 0
tween.tween_property(self, "modulate", cp, 0.15)
tween.tween_callback(self.hide)


func show_wrapper():
self.modulate.a = 1
show()
14 changes: 14 additions & 0 deletions scripts/weapons/star_wrath.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
extends Node


# Called when the node enters the scene tree for the first time.
func _ready() -> void:
if get_tree().current_scene == self:
$StarWrath.start()
else:
$StarWrath.hide()


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta: float) -> void:
pass
24 changes: 24 additions & 0 deletions shaders/purple.gdshader
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
shader_type canvas_item;

void vertex() {
// Called for every vertex the material is visible on.
}

void fragment() {
// Called for every pixel the material is visible on.
vec2 screen_coords = SCREEN_UV;
// 垂直翻转Y坐标
screen_coords.y = (1.0 - screen_coords.y);
// 紫色
vec4 purple_color = vec4(0.5, 0.0, 0.5, 1.0);
// 半透明紫色
vec4 transparent_purple = vec4(0.5, 0.0, 0.5, 0.5);
vec4 gradient_color = purple_color + (transparent_purple - purple_color) * screen_coords.y * 3.6;
// 设置最终颜色
COLOR = gradient_color;
}

//void light() {
// Called for every pixel for every light affecting the CanvasItem.
// Uncomment to replace the default light processing function with this one.
//}

0 comments on commit af8d6ef

Please sign in to comment.