mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 08:55:35 +00:00
Parenting changes
This commit is contained in:
parent
b7fb003b70
commit
6fbbe7ee4c
7 changed files with 225 additions and 160 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,2 +1,3 @@
|
|||
# Godot 4+ specific ignores
|
||||
.godot/
|
||||
.vscode/
|
||||
|
|
@ -1,16 +1,20 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://b1qnfiuokpvsr"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://b1qnfiuokpvsr"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://cybpmpb0d8yva" path="res://Sprites/Projectile.png" id="1_2eu87"]
|
||||
[ext_resource type="Script" path="res://Scripts/Bullet.cs" id="1_jvxw3"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_jxptd"]
|
||||
radius = 2.23607
|
||||
|
||||
[node name="Bullet" type="Node2D"]
|
||||
[node name="Bullet" type="Area2D"]
|
||||
script = ExtResource("1_jvxw3")
|
||||
metadata/_edit_group_ = true
|
||||
|
||||
[node name="RigidBody2D" type="RigidBody2D" parent="."]
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="RigidBody2D"]
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("1_2eu87")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_jxptd")
|
||||
|
||||
[node name="Node2D" type="Node2D" parent="."]
|
||||
editor_description = "Player Bullet"
|
||||
|
|
|
|||
160
Scenes/player.tscn
Normal file
160
Scenes/player.tscn
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
[gd_scene load_steps=20 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"]
|
||||
[ext_resource type="PackedScene" uid="uid://b1qnfiuokpvsr" path="res://Scenes/bullet.tscn" id="2_ov36d"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_omx2u"]
|
||||
atlas = ExtResource("2_bwf6x")
|
||||
region = Rect2(0, 0, 8, 16)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ai4rh"]
|
||||
size = Vector2(6, 8)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_pdst4"]
|
||||
atlas = ExtResource("2_bwf6x")
|
||||
region = Rect2(0, 0, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_s7dqe"]
|
||||
atlas = ExtResource("2_bwf6x")
|
||||
region = Rect2(0, 0, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_irmjj"]
|
||||
atlas = ExtResource("2_bwf6x")
|
||||
region = Rect2(8, 0, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_chuua"]
|
||||
atlas = ExtResource("2_bwf6x")
|
||||
region = Rect2(16, 0, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_nhxfa"]
|
||||
atlas = ExtResource("2_bwf6x")
|
||||
region = Rect2(0, 32, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tnyrl"]
|
||||
atlas = ExtResource("2_bwf6x")
|
||||
region = Rect2(8, 32, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_awe4i"]
|
||||
atlas = ExtResource("2_bwf6x")
|
||||
region = Rect2(16, 32, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_n0dww"]
|
||||
atlas = ExtResource("2_bwf6x")
|
||||
region = Rect2(0, 48, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_pq4ul"]
|
||||
atlas = ExtResource("2_bwf6x")
|
||||
region = Rect2(8, 48, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_w3vni"]
|
||||
atlas = ExtResource("2_bwf6x")
|
||||
region = Rect2(16, 48, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_kg1c7"]
|
||||
atlas = ExtResource("2_bwf6x")
|
||||
region = Rect2(0, 16, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qe0jv"]
|
||||
atlas = ExtResource("2_bwf6x")
|
||||
region = Rect2(8, 16, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_6pgul"]
|
||||
atlas = ExtResource("2_bwf6x")
|
||||
region = Rect2(16, 16, 8, 16)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_q0rt3"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_pdst4")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_s7dqe")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_irmjj")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_chuua")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"walk_down",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_nhxfa")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_tnyrl")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_awe4i")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"walk_left",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_n0dww")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_pq4ul")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_w3vni")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"walk_right",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_kg1c7")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qe0jv")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_6pgul")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"walk_up",
|
||||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("Muzzle")]
|
||||
collision_layer = 2
|
||||
collision_mask = 3
|
||||
script = ExtResource("1_m27vu")
|
||||
Speed = 1800
|
||||
BulletScene = ExtResource("2_ov36d")
|
||||
Muzzle = NodePath("Muzzle")
|
||||
metadata/_edit_group_ = true
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
visible = false
|
||||
scale = Vector2(2.5, 1.75)
|
||||
texture = SubResource("AtlasTexture_omx2u")
|
||||
hframes = 3
|
||||
vframes = 4
|
||||
frame = 1
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("RectangleShape2D_ai4rh")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
sprite_frames = SubResource("SpriteFrames_q0rt3")
|
||||
animation = &"walk_left"
|
||||
|
||||
[node name="Muzzle" type="Marker2D" parent="."]
|
||||
position = Vector2(5, 0)
|
||||
|
||||
[node name="Node2D" type="Node2D" parent="."]
|
||||
165
Scenes/test.tscn
165
Scenes/test.tscn
|
|
@ -1,136 +1,8 @@
|
|||
[gd_scene load_steps=25 format=3 uid="uid://bv451a8wgty4u"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://bv451a8wgty4u"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scripts/PlayerMovement.cs" id="1_fwei5"]
|
||||
[ext_resource type="Texture2D" uid="uid://la06powu57hu" path="res://Sprites/Cirno_Big.png" id="2_7wt5q"]
|
||||
[ext_resource type="PackedScene" uid="uid://b1qnfiuokpvsr" path="res://Scenes/bullet.tscn" id="4_nwkfm"]
|
||||
[ext_resource type="PackedScene" uid="uid://bghghp5ep4w2j" path="res://Scenes/player.tscn" id="2_8mh54"]
|
||||
[ext_resource type="PackedScene" uid="uid://rp4jhx0tuh24" path="res://Scenes/fragola.tscn" id="4_s7wq6"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_46wey"]
|
||||
atlas = ExtResource("2_7wt5q")
|
||||
region = Rect2(0, 0, 8, 16)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_2gpmr"]
|
||||
size = Vector2(6, 8)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_pdst4"]
|
||||
atlas = ExtResource("2_7wt5q")
|
||||
region = Rect2(0, 0, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_s7dqe"]
|
||||
atlas = ExtResource("2_7wt5q")
|
||||
region = Rect2(0, 0, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_irmjj"]
|
||||
atlas = ExtResource("2_7wt5q")
|
||||
region = Rect2(8, 0, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_chuua"]
|
||||
atlas = ExtResource("2_7wt5q")
|
||||
region = Rect2(16, 0, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_nhxfa"]
|
||||
atlas = ExtResource("2_7wt5q")
|
||||
region = Rect2(0, 32, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tnyrl"]
|
||||
atlas = ExtResource("2_7wt5q")
|
||||
region = Rect2(8, 32, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_awe4i"]
|
||||
atlas = ExtResource("2_7wt5q")
|
||||
region = Rect2(16, 32, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_n0dww"]
|
||||
atlas = ExtResource("2_7wt5q")
|
||||
region = Rect2(0, 48, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_pq4ul"]
|
||||
atlas = ExtResource("2_7wt5q")
|
||||
region = Rect2(8, 48, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_w3vni"]
|
||||
atlas = ExtResource("2_7wt5q")
|
||||
region = Rect2(16, 48, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_kg1c7"]
|
||||
atlas = ExtResource("2_7wt5q")
|
||||
region = Rect2(0, 16, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qe0jv"]
|
||||
atlas = ExtResource("2_7wt5q")
|
||||
region = Rect2(8, 16, 8, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_6pgul"]
|
||||
atlas = ExtResource("2_7wt5q")
|
||||
region = Rect2(16, 16, 8, 16)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_ur7bf"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_pdst4")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_s7dqe")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_irmjj")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_chuua")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"walk_down",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_nhxfa")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_tnyrl")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_awe4i")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"walk_left",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_n0dww")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_pq4ul")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_w3vni")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"walk_right",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_kg1c7")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qe0jv")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_6pgul")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"walk_up",
|
||||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_qui05"]
|
||||
size = Vector2(20, 153)
|
||||
|
||||
|
|
@ -146,33 +18,18 @@ size = Vector2(134, 7)
|
|||
[node name="Node2D" type="Node2D"]
|
||||
position = Vector2(38, 39)
|
||||
|
||||
[node name="ReferenceRect" type="ReferenceRect" parent="."]
|
||||
offset_left = -38.0
|
||||
offset_top = -39.0
|
||||
offset_right = 124.0
|
||||
offset_bottom = 44.0
|
||||
|
||||
[node name="Polygon2D" type="Polygon2D" parent="."]
|
||||
position = Vector2(41, -4.31633)
|
||||
scale = Vector2(1, 1.23469)
|
||||
color = Color(0.278431, 0.8, 0.396078, 1)
|
||||
polygon = PackedVector2Array(95, 57, 46, 58, -83, 61, -91, -37, 88, -37, 114, -1)
|
||||
|
||||
[node name="Player" type="CharacterBody2D" parent="."]
|
||||
collision_layer = 2
|
||||
collision_mask = 3
|
||||
script = ExtResource("1_fwei5")
|
||||
Speed = 1800
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="Player"]
|
||||
visible = false
|
||||
scale = Vector2(2.5, 1.75)
|
||||
texture = SubResource("AtlasTexture_46wey")
|
||||
hframes = 3
|
||||
vframes = 4
|
||||
frame = 1
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player"]
|
||||
shape = SubResource("RectangleShape2D_2gpmr")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="Player"]
|
||||
sprite_frames = SubResource("SpriteFrames_ur7bf")
|
||||
animation = &"walk_left"
|
||||
|
||||
[node name="StaticBody2D" type="StaticBody2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
|
||||
|
|
@ -198,8 +55,8 @@ shape = SubResource("RectangleShape2D_5ir3o")
|
|||
position = Vector2(37, -35.5)
|
||||
shape = SubResource("RectangleShape2D_e3rcm")
|
||||
|
||||
[node name="Bullet" parent="." instance=ExtResource("4_nwkfm")]
|
||||
position = Vector2(36, 2)
|
||||
|
||||
[node name="Fragola" parent="." instance=ExtResource("4_s7wq6")]
|
||||
position = Vector2(62, 10)
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("2_8mh54")]
|
||||
position = Vector2(-7, -15)
|
||||
|
|
|
|||
18
Scripts/Bullet.cs
Normal file
18
Scripts/Bullet.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
public partial class Bullet : RigidBody2D
|
||||
{
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
Debug.WriteLine("Bullet Shot");
|
||||
}
|
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,18 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
public partial class PlayerMovement : CharacterBody2D
|
||||
{
|
||||
[Export]
|
||||
public int Speed { get; set; } = 400;
|
||||
|
||||
[Export]
|
||||
public PackedScene BulletScene { get; set; }
|
||||
|
||||
[Export]
|
||||
public Marker2D Muzzle {get;set;}
|
||||
|
||||
private AnimatedSprite2D _animatedSprite;
|
||||
|
||||
public override void _Ready()
|
||||
|
|
@ -27,9 +34,22 @@ public partial class PlayerMovement : CharacterBody2D
|
|||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
HandleShoot();
|
||||
SetAnimation();
|
||||
}
|
||||
|
||||
private void HandleShoot()
|
||||
{
|
||||
if (Input.IsActionJustPressed("shoot"))
|
||||
{
|
||||
Bullet bullet = BulletScene.Instantiate<Bullet>();
|
||||
Owner.AddChild(bullet);
|
||||
bullet.Transform = Muzzle.GlobalTransform;
|
||||
bullet.Position = this.Position;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void SetAnimation()
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -58,6 +58,11 @@ click={
|
|||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(112, 10),"global_position":Vector2(116, 51),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
shoot={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[layer_names]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue