mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-12 20:45:54 +00:00
stuff
This commit is contained in:
parent
9e3c75ca1d
commit
2b53936f8b
6 changed files with 54 additions and 7 deletions
|
|
@ -6,7 +6,7 @@
|
|||
[sub_resource type="CircleShape2D" id="CircleShape2D_jxptd"]
|
||||
radius = 2.23607
|
||||
|
||||
[node name="Bullet" type="Area2D"]
|
||||
[node name="Bullet" type="Area2D" groups=["bullets"]]
|
||||
script = ExtResource("1_jvxw3")
|
||||
Speed = 200.0
|
||||
metadata/_edit_group_ = true
|
||||
|
|
|
|||
34
Scenes/fragola.cs
Normal file
34
Scenes/fragola.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
public partial class fragola : RigidBody2D
|
||||
{
|
||||
[Signal]
|
||||
public delegate void HitEventHandler();
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
}
|
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
}
|
||||
|
||||
private void _on_body_entered(Node body)
|
||||
{
|
||||
Debug.WriteLine("Collision");
|
||||
Hide();
|
||||
EmitSignal(SignalName.Hit);
|
||||
// Must be deferred as we can't change physics properties on a physics callback.
|
||||
GetNode<CollisionShape2D>("CollisionShape2D").SetDeferred(CollisionShape2D.PropertyName.Disabled, true);
|
||||
}
|
||||
private void _on_area_2d_area_entered(Area2D area)
|
||||
{
|
||||
// Replace with function body.
|
||||
Debug.WriteLine("Collision area");
|
||||
EmitSignal(SignalName.Hit);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
[gd_scene load_steps=10 format=3 uid="uid://rp4jhx0tuh24"]
|
||||
[gd_scene load_steps=12 format=3 uid="uid://rp4jhx0tuh24"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://cy5usvdeabi0t" path="res://Sprites/fragola.png" id="1_5wy11"]
|
||||
[ext_resource type="Script" path="res://Scenes/fragola.cs" id="1_773fi"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_j6kkb"]
|
||||
atlas = ExtResource("1_5wy11")
|
||||
|
|
@ -63,11 +64,15 @@ animations = [{
|
|||
[sub_resource type="CircleShape2D" id="CircleShape2D_bbnjh"]
|
||||
radius = 7.0
|
||||
|
||||
[node name="Fragola" type="RigidBody2D"]
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_svktn"]
|
||||
radius = 7.0
|
||||
|
||||
[node name="Fragola" type="RigidBody2D" groups=["enemies"]]
|
||||
collision_layer = 4
|
||||
collision_mask = 7
|
||||
mass = 0.03
|
||||
gravity_scale = 0.0
|
||||
script = ExtResource("1_773fi")
|
||||
metadata/_edit_group_ = true
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
|
|
@ -78,3 +83,11 @@ animation = &"idle"
|
|||
shape = SubResource("CircleShape2D_bbnjh")
|
||||
|
||||
[node name="Fragola" type="Node2D" parent="."]
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
shape = SubResource("CircleShape2D_svktn")
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||
[connection signal="area_entered" from="Area2D" to="." method="_on_area_2d_area_entered"]
|
||||
|
|
|
|||
|
|
@ -171,4 +171,4 @@ y_sort_enabled = true
|
|||
sprite_frames = SubResource("SpriteFrames_q0rt3")
|
||||
animation = &"walk_left"
|
||||
|
||||
[node name="Crosshair" parent="." instance=ExtResource("6_l43rf")]
|
||||
[node name="Crosshair" parent="Smoothing2D" instance=ExtResource("6_l43rf")]
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public partial class Bullet : Area2D
|
|||
|
||||
_direction = normalized;
|
||||
|
||||
Debug.WriteLine($"Bullet Shot at direction {direction.X} {direction.Y}");
|
||||
//Debug.WriteLine($"Bullet Shot at direction {direction.X} {direction.Y}");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ public partial class Bullet : Area2D
|
|||
|
||||
private void _on_visible_on_screen_notifier_2d_screen_exited()
|
||||
{
|
||||
Debug.WriteLine("Destroy bullet out of screen");
|
||||
//Debug.WriteLine("Destroy bullet out of screen");
|
||||
QueueFree();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public partial class PlayerMovement : CharacterBody2D
|
|||
public override void _Ready()
|
||||
{
|
||||
_animatedSprite = GetNode<AnimatedSprite2D>("./Smoothing2D/AnimatedSprite2D");
|
||||
_crosshair = GetNode<Sprite2D>("./Crosshair");
|
||||
_crosshair = GetNode<Sprite2D>("./Smoothing2D/Crosshair");
|
||||
|
||||
_movementDirection = Vector2.Zero;
|
||||
_facingDirection = Vector2.Zero;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue