Focus sprites

This commit is contained in:
MaddoScientisto 2025-02-16 16:55:33 +01:00
commit 9717ca8a55
5 changed files with 90 additions and 76 deletions

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=30 format=3 uid="uid://bghghp5ep4w2j"]
[gd_scene load_steps=33 format=3 uid="uid://bghghp5ep4w2j"]
[ext_resource type="Script" path="res://Scripts/PlayerMovement.cs" id="1_m27vu"]
[ext_resource type="Texture2D" uid="uid://la06powu57hu" path="res://Sprites/Cirno_Big.png" id="2_bwf6x"]
@ -9,6 +9,7 @@
[ext_resource type="PackedScene" uid="uid://cfb3nsay84xdb" path="res://Scenes/Weapons/crosshair.tscn" id="6_l43rf"]
[ext_resource type="Texture2D" uid="uid://bf37ce6jskdel" path="res://Sprites/SmallHitbox.png" id="7_msn8i"]
[ext_resource type="Script" path="res://Scenes/InteractionController.cs" id="7_uvgjg"]
[ext_resource type="Texture2D" uid="uid://bwjrdlnysft15" path="res://Sprites/Actors/Focus_Circle.png" id="8_1og8b"]
[ext_resource type="Resource" uid="uid://b8apu0l5fm4k" path="res://Resources/Weapons/IcicleGun.tres" id="9_84o8f"]
[ext_resource type="PackedScene" uid="uid://crry0rgk7a8sm" path="res://Scenes/Weapons/BaseWeapon.tscn" id="9_wblq0"]
@ -138,13 +139,28 @@ animations = [{
"speed": 5.0
}]
[sub_resource type="AtlasTexture" id="AtlasTexture_lsyrf"]
atlas = ExtResource("8_1og8b")
region = Rect2(0, 0, 32, 32)
[sub_resource type="SpriteFrames" id="SpriteFrames_27k5e"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_lsyrf")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]
[sub_resource type="CircleShape2D" id="CircleShape2D_oevaq"]
radius = 17.2627
[sub_resource type="CircleShape2D" id="CircleShape2D_e6woi"]
radius = 1.0
[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("Muzzle") groups=["Destroyable", "player"]]
[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("Muzzle", "HitboxSprite") groups=["Destroyable", "player"]]
y_sort_enabled = true
collision_layer = 2
collision_mask = 99
@ -155,6 +171,7 @@ CrosshairDistance = 35.0
SelectorScene = ExtResource("3_8wt6s")
GameOverScene = "res://Scenes/GameOver.tscn"
Muzzle = NodePath("Muzzle")
HitboxSprite = NodePath("Smoothing2D/HitboxSprite")
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
@ -189,9 +206,14 @@ frame_progress = 0.984651
z_index = 100
[node name="HitboxSprite" type="Sprite2D" parent="Smoothing2D"]
visible = false
z_index = 2
texture = ExtResource("7_msn8i")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="Smoothing2D/HitboxSprite"]
self_modulate = Color(1, 1, 1, 0.423529)
show_behind_parent = true
sprite_frames = SubResource("SpriteFrames_27k5e")
[node name="InteractionController" type="Area2D" parent="."]
visible = false
collision_layer = 2

View file

@ -112,15 +112,13 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
_animatedSprite = GetNode<AnimatedSprite2D>("./Smoothing2D/AnimatedSprite2D");
_crosshair = GetNode<Sprite2D>("./Smoothing2D/Crosshair");
//_inventoryManager = GetNode<InventoryManager>("/root/GameScene/InventoryManager");
_movementDirection = Vector2.Zero;
_facingDirection = Vector2.Zero;
_rightStickInput = Vector2.Zero;
_isStrafing = false;
_gameManager = this.GetGameManager(); //GetNode<GameManager>("/root/GameScene");
_gameManager = this.GetGameManager();
_inventoryManager = this.GetInventoryManager();
_gameManager.GameStateChange += GameManagerOnGameStateChange;
@ -167,28 +165,6 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
}
}
/*public override _Process(float _delta)
{
if (Input.IsActionPressed("ui_right"))
{
_animatedSprite.Play("run");
}
else
{
_animatedSprite.Stop();
}
}*/
// public void ItemAdded(LootItem item, int amount)
// {
// switch (item.Item)
// {
// case ItemTypes.Weapon:
// AddWeapon(item.WeaponData);
// break;
// }
// }
public void AddWeapon(Weapon weapon)
{
EquippedWeapons.Add(weapon);
@ -222,25 +198,6 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
EquipWeapon(EquippedWeapons[CurrentWeaponIndex]);
}
public override void _Process(double delta)
{
SetAnimation();
if (!_canMove) return;
HandleShoot();
FindInteractable();
if (Input.IsActionJustPressed("next_weapon"))
{
NextWeapon();
}
if (Input.IsActionJustPressed("previous_weapon"))
{
PreviousWeapon();
}
}
private void FindInteractable()
{
if (!Input.IsActionJustPressed("Use") || _selector.SelectedInteractable == null) return;
@ -266,13 +223,6 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
EquippedWeapon.ShootDirection = this._facingDirection;
EquippedWeapon.Shoot();
// //Debug.WriteLine("Shoot");
// var bullet = BulletScene.Instantiate<Bullet>();
// Owner.AddChild(bullet);
// bullet.Transform = Muzzle.GlobalTransform;
// bullet.Position = this.Position;
// bullet.SetDirection(this._facingDirection);
}
private void SetAnimation()
@ -333,25 +283,13 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
}
// public override void _Draw()
// {
// if (_isStrafing)
// {
// HitboxSprite.Visible = true;
// }
// else
// {
// HitboxSprite.Visible = false;
// }
// base._Draw();
// }
public override void _PhysicsProcess(double delta)
public override void _Process(double delta)
{
SetAnimation();
if (!_canMove) return;
_movementDirection = GetInput();
_isStrafing = Input.IsActionPressed("strafe");
// Toggle visibility of the hitbox sprite based on strafing
if (HitboxSprite != null)
@ -373,16 +311,30 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
_facingDirection = _movementDirection;
}
}
HandleShoot();
FindInteractable();
if (Input.IsActionJustPressed("next_weapon"))
{
NextWeapon();
}
if (Input.IsActionJustPressed("previous_weapon"))
{
PreviousWeapon();
}
_crosshair.Position = CalculateCrosshairPosition();
}
public override void _PhysicsProcess(double delta)
{
if (!_canMove) return;
// if (_movementDirection != Vector2.Zero)
// {
// _facingDirection = _movementDirection;
// }
Velocity = _movementDirection * (float)( MovementSpeed/* * delta*/);
MoveAndSlide();
_crosshair.Position = CalculateCrosshairPosition();
}
private void _on_interaction_controller_area_entered(Area2D area)

BIN
Sprites/Actors/Focus_Circle.aseprite (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Sprites/Actors/Focus_Circle.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bwjrdlnysft15"
path="res://.godot/imported/Focus_Circle.png-86ca500c18cc9b51128617925453c9df.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Actors/Focus_Circle.png"
dest_files=["res://.godot/imported/Focus_Circle.png-86ca500c18cc9b51128617925453c9df.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