Got cast indicator working

- Also added a couple of spells
- Got started on animation system
This commit is contained in:
nc5432 2024-05-03 07:56:32 -04:00
parent a440a60383
commit b0508379c6
22 changed files with 354 additions and 33 deletions

View File

@ -1,15 +1,16 @@
[gd_resource type="Resource" script_class="Spellbook" load_steps=5 format=3 uid="uid://bxtiv2esuer8v"]
[gd_resource type="Resource" script_class="Spellbook" load_steps=6 format=3 uid="uid://bxtiv2esuer8v"]
[ext_resource type="Script" path="res://Resources/spellbook.gd" id="1_t8h8m"]
[ext_resource type="Resource" uid="uid://1xbik4qndtkh" path="res://Resources/Spells/firebolt.tres" id="2_ln222"]
[ext_resource type="Resource" uid="uid://dl6nv6lp460n3" path="res://Resources/Spells/rockThrow.tres" id="3_ocgmh"]
[ext_resource type="Resource" uid="uid://bmpu6k55bckdv" path="res://Resources/Spells/fireball.tres" id="4_kv0hs"]
[ext_resource type="Resource" uid="uid://c6mwbnutxm3vb" path="res://Resources/Spells/icyWind.tres" id="5_05vnn"]
[resource]
script = ExtResource("1_t8h8m")
name = "Old Book"
description = "An old spellbook you found on the side of the road"
spells = Array[Resource("res://Resources/spell.gd")]([ExtResource("2_ln222"), ExtResource("3_ocgmh"), ExtResource("4_kv0hs")])
spells = Array[Resource("res://Resources/spell.gd")]([ExtResource("2_ln222"), ExtResource("3_ocgmh"), ExtResource("4_kv0hs"), ExtResource("5_05vnn")])
damageMod = 1.0
defenseMod = 1.0
element = 0

View File

@ -16,4 +16,4 @@ castProgress = 0
element = 1
stunning = false
timeout = 10.0
cooldown = 1.0
cooldown = 2.0

View File

@ -0,0 +1,19 @@
[gd_resource type="Resource" script_class="Spell" load_steps=3 format=3 uid="uid://c6mwbnutxm3vb"]
[ext_resource type="Texture2D" uid="uid://ciwwmx45v5o85" path="res://Sprites/Spells/Ice & Fire Spells Pack by Captainskeleto/Ice Spells by Captainskeleto/Ice Spells/Ice Spells23.png" id="1_0yb3x"]
[ext_resource type="Script" path="res://Resources/spell.gd" id="1_r2m62"]
[resource]
script = ExtResource("1_r2m62")
icon = ExtResource("1_0yb3x")
name = "Icy Wind"
description = "Blows frigid wind at your opponent"
animation = ""
damage = 4.0
backfireStrength = 2.0
castCombo = Array[String](["left", "left", "left", "down", "left"])
castProgress = 0
element = 2
stunning = false
timeout = 5.0
cooldown = 5.0

View File

@ -0,0 +1,19 @@
[gd_resource type="Resource" script_class="Spell" load_steps=3 format=3 uid="uid://b1c2yi3rk1rhw"]
[ext_resource type="Script" path="res://Resources/spell.gd" id="1_7p6oj"]
[ext_resource type="Texture2D" uid="uid://cthn7tp1s1aoc" path="res://Sprites/Spells/Ice & Fire Spells Pack by Captainskeleto/Ice Spells by Captainskeleto/Ice Spells/Ice Spells80.png" id="1_lo7uk"]
[resource]
script = ExtResource("1_7p6oj")
icon = ExtResource("1_lo7uk")
name = "Lightning Bolt"
description = "A bolt of lightning"
animation = ""
damage = 10.0
backfireStrength = 8.0
castCombo = Array[String](["left", "up", "right", "down", "left", "up", "right", "down", "up", "down"])
castProgress = 0
element = 1
stunning = true
timeout = 4.0
cooldown = 10.0

View File

@ -16,4 +16,4 @@ castProgress = 0
element = 4
stunning = true
timeout = 10.0
cooldown = 1.0
cooldown = 2.0

View File

@ -43,10 +43,6 @@ region = Rect2(1386, 0, 231, 190)
atlas = ExtResource("1_2xk2o")
region = Rect2(1617, 0, 231, 190)
[sub_resource type="AtlasTexture" id="AtlasTexture_6telm"]
atlas = ExtResource("2_2f0nh")
region = Rect2(0, 0, 231, 190)
[sub_resource type="AtlasTexture" id="AtlasTexture_8pl14"]
atlas = ExtResource("2_2f0nh")
region = Rect2(231, 0, 231, 190)
@ -75,6 +71,10 @@ region = Rect2(1386, 0, 231, 190)
atlas = ExtResource("2_2f0nh")
region = Rect2(1617, 0, 231, 190)
[sub_resource type="AtlasTexture" id="AtlasTexture_6telm"]
atlas = ExtResource("2_2f0nh")
region = Rect2(0, 0, 231, 190)
[sub_resource type="AtlasTexture" id="AtlasTexture_el7sl"]
atlas = ExtResource("3_7wnck")
region = Rect2(0, 0, 231, 190)
@ -224,9 +224,6 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_6telm")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_8pl14")
}, {
"duration": 1.0,
@ -246,6 +243,9 @@ animations = [{
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_uyqo3")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_6telm")
}],
"loop": false,
"name": &"attack2",
@ -375,7 +375,7 @@ script = ExtResource("1_tgd3u")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
sprite_frames = SubResource("SpriteFrames_pk2mw")
animation = &"idle"
animation = &"hit"
autoplay = "idle"
[node name="chargingParticles" parent="." instance=ExtResource("10_stcqi")]

View File

@ -1,7 +1,8 @@
[gd_scene load_steps=3 format=3 uid="uid://dbhep5cgrqipa"]
[gd_scene load_steps=4 format=3 uid="uid://dbhep5cgrqipa"]
[ext_resource type="Texture2D" uid="uid://1duikwr2bln8" path="res://Sprites/Misc/WEAPON PACK by captainskeleto/weapon9.png" id="1_25tp1"]
[ext_resource type="Script" path="res://Scripts/castIndicator.gd" id="1_jkb2f"]
[ext_resource type="Texture2D" uid="uid://4xj273elck0d" path="res://Sprites/Spells/Ice & Fire Spells Pack by Captainskeleto/Fire Spell Pack by Captainskeleto/Fire Frame Template/Template Frame Fire.png" id="2_gfdaf"]
[node name="CastIndicator" type="Control"]
layout_mode = 3
@ -14,33 +15,92 @@ grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_jkb2f")
[node name="TextureRect2" type="TextureRect" parent="."]
modulate = Color(1, 1, 1, 0.345098)
[node name="border2" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -94.0
offset_top = -94.0
offset_right = 94.0
offset_bottom = 94.0
offset_left = -227.0
offset_top = -1.76886
offset_right = -182.0
offset_bottom = 43.2311
grow_horizontal = 2
grow_vertical = 2
scale = Vector2(2.6, 2.6)
texture = ExtResource("2_gfdaf")
[node name="TextureRect2" type="TextureRect" parent="border2"]
modulate = Color(1, 1, 1, 0.47451)
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -64.0
offset_top = -64.0
offset_right = 64.0
offset_bottom = 64.0
grow_horizontal = 2
grow_vertical = 2
scale = Vector2(0.192, 0.192)
pivot_offset = Vector2(64, 64)
texture = ExtResource("1_25tp1")
[node name="TextureRect" type="TextureRect" parent="."]
[node name="ColorRect" type="ColorRect" parent="border2"]
z_index = -1
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
pivot_offset = Vector2(43.8277, 43.8277)
color = Color(1, 0.945098, 0.709804, 1)
[node name="border" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -20.0
offset_top = -20.0
offset_right = 20.0
offset_bottom = 20.0
offset_left = -44.0
offset_top = -44.0
offset_right = 44.0
offset_bottom = 44.0
grow_horizontal = 2
grow_vertical = 2
scale = Vector2(2.6, 2.6)
pivot_offset = Vector2(43.8277, 43.8277)
texture = ExtResource("2_gfdaf")
[node name="TextureRect" type="TextureRect" parent="border"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -64.0
offset_top = -64.0
offset_right = 64.0
offset_bottom = 64.0
grow_horizontal = 2
grow_vertical = 2
scale = Vector2(0.455, 0.455)
pivot_offset = Vector2(64, 64)
texture = ExtResource("1_25tp1")
[node name="ColorRect" type="ColorRect" parent="border"]
z_index = -1
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
pivot_offset = Vector2(43.8277, 43.8277)
color = Color(1, 0.945098, 0.709804, 1)

View File

@ -1,10 +1,11 @@
[gd_scene load_steps=6 format=3 uid="uid://fgo2hd37towj"]
[gd_scene load_steps=7 format=3 uid="uid://fgo2hd37towj"]
[ext_resource type="PackedScene" uid="uid://d2owoq5q27v8q" path="res://Scenes/data.tscn" id="1_cjr1k"]
[ext_resource type="PackedScene" uid="uid://nckxh4vysmvv" path="res://Scenes/player_controller.tscn" id="2_ud5et"]
[ext_resource type="Texture2D" uid="uid://dnuh0fkgjhkkf" path="res://Sprites/Backgrounds/Mountain Pack by CaptainSkeleto/Mountain Pack6.png" id="2_wgdhh"]
[ext_resource type="PackedScene" uid="uid://c8wwq1hoj4sd5" path="res://Scenes/Characters/wizard.tscn" id="3_arqpv"]
[ext_resource type="Resource" uid="uid://bxtiv2esuer8v" path="res://Resources/Spellbooks/oldBook.tres" id="4_3cleg"]
[ext_resource type="PackedScene" uid="uid://dbhep5cgrqipa" path="res://Scenes/UI/castIndicator.tscn" id="6_hj5b3"]
[node name="Arena" type="Node2D"]
@ -19,10 +20,20 @@ position = Vector2(277, 419)
spellbook = ExtResource("4_3cleg")
player = true
[node name="CastIndicator" parent="." instance=ExtResource("6_hj5b3")]
visible = false
z_index = 2
offset_left = 576.0
offset_top = 324.0
offset_right = 576.0
offset_bottom = 324.0
[node name="CanvasLayer" type="CanvasLayer" parent="."]
layer = -1
[node name="TextureRect" type="TextureRect" parent="CanvasLayer"]
z_index = -10
z_as_relative = false
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0

View File

@ -0,0 +1,9 @@
extends "res://Scripts/animationBase.gd"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass

View File

@ -0,0 +1,10 @@
[gd_scene load_steps=2 format=3 uid="uid://c44hesqr12wxd"]
[ext_resource type="Script" path="res://Scripts/Animations/rockThrowAnim.gd" id="1_owh0v"]
[node name="RockThrowAnim" type="Node2D"]
script = ExtResource("1_owh0v")
[node name="TextureRect" type="TextureRect" parent="."]
offset_right = 40.0
offset_bottom = 40.0

6
Scripts/animationBase.gd Normal file
View File

@ -0,0 +1,6 @@
extends Node2D
@export var inverted: bool = false
func castFailed():
pass

View File

@ -1,13 +1,51 @@
extends Control
class_name CastIndicator
@onready var data = get_node("/root/Arena/Data")
@onready var primary = $TextureRect
@onready var secondary = $TextureRect2
@onready var primaryBox = $border
@onready var secondaryBox = $border2
@onready var primary = $border/TextureRect
@onready var secondary = $border2/TextureRect2
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
if data.difficulty > 1:
secondaryBox.hide()
if data.difficulty > 2:
primaryBox.hide()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func setDirs(current: String, next: String = "none"):
match current:
"none":
primary.hide()
"up":
primary.show()
primary.rotation_degrees = 0
"down":
primary.show()
primary.rotation_degrees = 180
"left":
primary.show()
primary.rotation_degrees = 270
"right":
primary.show()
primary.rotation_degrees = 90
match next:
"none":
secondary.hide()
"up":
secondary.show()
secondary.rotation_degrees = 0
"down":
secondary.show()
secondary.rotation_degrees = 180
"left":
secondary.show()
secondary.rotation_degrees = 270
"right":
secondary.show()
secondary.rotation_degrees = 90

View File

@ -1,7 +1,7 @@
extends Node
@onready var data = get_node("/root/Arena/Data")
@onready var castIndicator = get_node("/root/Arena/CanvasLayer/CastIndicator")
@onready var data: Data = get_node("/root/Arena/Data")
@onready var castIndicator: CastIndicator = get_node("/root/Arena/CastIndicator")
@export var avatar: Combatant
var casting = false
var spell: Spell
@ -20,23 +20,34 @@ func _process(delta):
casting = true
spell = data.spellbook.spells[i]
spellIndex = i
castIndicator.show()
castIndicator.setDirs(spell.castCombo[0], spell.castCombo[1])
avatar.particleSystem.emitting = true
timer = 0
else:
timer += delta
if (Input.is_action_just_pressed(spell.castCombo[spell.castProgress])):
spell.castProgress += 1
if spell.castProgress == spell.castCombo.size() - 1:
castIndicator.setDirs(spell.castCombo[spell.castProgress])
elif spell.castProgress < spell.castCombo.size() - 1:
castIndicator.setDirs(spell.castCombo[spell.castProgress], spell.castCombo[spell.castProgress + 1])
if spell.castProgress == spell.castCombo.size():
casting = false
avatar.particleSystem.emitting = false
spell.castProgress = 0
avatar.renderer.play("attack1")
data.spellbook.cooldowns[spellIndex] = spell.cooldown
castIndicator.hide()
elif (timer >= spell.timeout || Input.is_action_just_pressed("up") || Input.is_action_just_pressed("down") || Input.is_action_just_pressed("left") || Input.is_action_just_pressed("right")):
avatar.alterHealth(-spell.backfireStrength, true)
casting = false
avatar.particleSystem.emitting = false
spell.castProgress = 0
data.spellbook.cooldowns[spellIndex] = spell.cooldown * (spell.castProgress / spell.castCombo.size())
castIndicator.hide()
for i in range(data.spellbook.cooldowns.size()):
data.spellbook.cooldowns[i] -= delta

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dj7r3mp5p78q2"
path="res://.godot/imported/Rocks 128x128 by Captainskeleto.png-96692ddc31479bc7ea57ee789910776a.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Animations/Rock Pack/Rocks 128x128 by Captainskeleto.png"
dest_files=["res://.godot/imported/Rocks 128x128 by Captainskeleto.png-96692ddc31479bc7ea57ee789910776a.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dwsd0hggrxbdq"
path="res://.godot/imported/Rocks 64x64 by Captainskeleto.png-95820d70b80dcfe17c69c0409040bea1.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Animations/Rock Pack/Rocks 64x64 by Captainskeleto.png"
dest_files=["res://.godot/imported/Rocks 64x64 by Captainskeleto.png-95820d70b80dcfe17c69c0409040bea1.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://drpis63lerqdi"
path="res://.godot/imported/Rocks by Captainskeleto display.png-3963dccaa0b45c4c79197c713ece0f64.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Animations/Rock Pack/Rocks by Captainskeleto display.png"
dest_files=["res://.godot/imported/Rocks by Captainskeleto display.png-3963dccaa0b45c4c79197c713ece0f64.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ckl4kbnt7xeqs"
path="res://.godot/imported/Rocks by Captainskeleto no background.png-db57fd731960680d275dd84d11483708.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Animations/Rock Pack/Rocks by Captainskeleto no background.png"
dest_files=["res://.godot/imported/Rocks by Captainskeleto no background.png-db57fd731960680d275dd84d11483708.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
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

View File

@ -17,6 +17,7 @@ config/icon="res://icon.svg"
[display]
window/stretch/mode="viewport"
mouse_cursor/custom_image_hotspot=Vector2(64, 128)
[dotnet]