Skip to content

Commit

Permalink
fade into battle
Browse files Browse the repository at this point in the history
  • Loading branch information
Lamby777 committed May 13, 2024
1 parent 7d5481e commit 917939d
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 4 deletions.
54 changes: 53 additions & 1 deletion pets-gd/scenes/battle.tscn
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[gd_scene load_steps=12 format=3 uid="uid://kgl5788x405y"]
[gd_scene load_steps=17 format=3 uid="uid://kgl5788x405y"]

[ext_resource type="Shader" path="res://themes/opacity.gdshader" id="1_3pmac"]
[ext_resource type="Shader" path="res://themes/vdrugs/rainbow.gdshader" id="2_0m4jp"]
[ext_resource type="Shader" path="res://themes/vdrugs/common.gdshader" id="2_5b7lm"]
[ext_resource type="Texture2D" uid="uid://he44mug8lejt" path="res://assets/textures/misc/BattleIcons.png" id="3_k3xai"]
Expand Down Expand Up @@ -101,6 +102,47 @@ _data = {
"dualmenu_open": SubResource("Animation_0hj2l")
}

[sub_resource type="Animation" id="Animation_fgiup"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("IntroBlack:material:shader_parameter/opacity")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [0.0]
}

[sub_resource type="Animation" id="Animation_16138"]
resource_name = "fade_in"
length = 2.0
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("IntroBlack:material:shader_parameter/opacity")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(1, 2),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [1.0, 0.0]
}

[sub_resource type="AnimationLibrary" id="AnimationLibrary_cwld1"]
_data = {
"RESET": SubResource("Animation_fgiup"),
"fade_in": SubResource("Animation_16138")
}

[sub_resource type="ShaderMaterial" id="ShaderMaterial_lgbmi"]
shader = ExtResource("1_3pmac")
shader_parameter/opacity = 0.0

[node name="BattleEngine" type="BattleEngine"]

[node name="VideoDrugs" type="Control" parent="."]
Expand Down Expand Up @@ -393,3 +435,13 @@ libraries = {
}

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

[node name="IntroBlack" type="ColorRect" parent="."]
top_level = true
material = SubResource("ShaderMaterial_lgbmi")
offset_right = 1920.0
offset_bottom = 1080.0
color = Color(0, 0, 0, 1)
2 changes: 1 addition & 1 deletion pets-gd/scenes/world.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[ext_resource type="PackedScene" uid="uid://b0rlrppekv4vg" path="res://scenes/player_cb.tscn" id="2_r6tgb"]
[ext_resource type="PackedScene" uid="uid://c0jehwow4ein4" path="res://scenes/interaction_manager.tscn" id="2_uh12s"]
[ext_resource type="TileSet" uid="uid://dtft48lqhsjgr" path="res://assets/tilesets/cliff-dirt/tileset_cliff-dirt.tres" id="3_14512"]
[ext_resource type="Shader" path="res://themes/battle_intro.gdshader" id="3_a3d4r"]
[ext_resource type="Shader" path="res://themes/encounter.gdshader" id="3_a3d4r"]
[ext_resource type="Script" path="res://scenes/BattleIntroRect.gd" id="4_jple0"]
[ext_resource type="PackedScene" uid="uid://2i16xk27wro6" path="res://scenes/interaction_zone.tscn" id="5_uar2c"]
[ext_resource type="AudioStream" uid="uid://b83wws3dajmi5" path="res://assets/music/zone/routingout.ogg" id="5_x7nbf"]
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions pets-gd/themes/opacity.gdshader
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
shader_type canvas_item;

uniform float opacity : hint_range(0, 1) = 0.0;

void fragment() {
COLOR.a = mix(0.0, 1.0, opacity);
}
3 changes: 2 additions & 1 deletion pets-lib/src/battle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ impl BattleEngine {
/// slide the battle screen into view
#[func]
pub fn animate_in(&mut self) {
//
self.animator.set_assigned_animation("fade_in".into());
self.animator.play();
}

fn open_dualmenu(&mut self) {
Expand Down
2 changes: 1 addition & 1 deletion pets-lib/src/world/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ impl World {
// load the scene
let mut scene = self.instantiate_battle_scene();

scene.bind_mut().animate_in();
layer.add_child(scene.clone().upcast());
scene.bind_mut().animate_in();
}

#[func]
Expand Down

0 comments on commit 917939d

Please sign in to comment.