diff --git a/Scenes/bullet.tscn b/Scenes/bullet.tscn index 27a6c42e..c030b3a6 100644 --- a/Scenes/bullet.tscn +++ b/Scenes/bullet.tscn @@ -8,6 +8,7 @@ radius = 2.23607 [node name="Bullet" type="Area2D"] script = ExtResource("1_jvxw3") +Speed = 200.0 metadata/_edit_group_ = true [node name="Sprite2D" type="Sprite2D" parent="."] diff --git a/Scenes/player.tscn b/Scenes/player.tscn index e6383be5..a8cc1c9e 100644 --- a/Scenes/player.tscn +++ b/Scenes/player.tscn @@ -136,7 +136,7 @@ animations = [{ collision_layer = 2 collision_mask = 3 script = ExtResource("1_m27vu") -Speed = 1800 +Speed = 2000 BulletScene = ExtResource("2_ov36d") Muzzle = NodePath("Muzzle") metadata/_edit_group_ = true diff --git a/Scenes/test.tscn b/Scenes/test.tscn index ed5108b1..544b0db9 100644 --- a/Scenes/test.tscn +++ b/Scenes/test.tscn @@ -1,5 +1,6 @@ -[gd_scene load_steps=9 format=3 uid="uid://bv451a8wgty4u"] +[gd_scene load_steps=12 format=3 uid="uid://bv451a8wgty4u"] +[ext_resource type="Texture2D" uid="uid://bxclo2fg3ulur" path="res://Sprites/tinyBlocks_NOiL_1.1update.png" id="1_43rfa"] [ext_resource type="TileSet" uid="uid://c26fvvju514rc" path="res://Tilesets/test_tileset.tres" id="1_k3ie3"] [ext_resource type="PackedScene" uid="uid://bghghp5ep4w2j" path="res://Scenes/player.tscn" id="2_8mh54"] [ext_resource type="PackedScene" uid="uid://cxmcqehjjy82j" path="res://Scenes/reisen.tscn" id="3_8k37m"] @@ -7,6 +8,88 @@ [ext_resource type="Texture2D" uid="uid://boi73xiydtslu" path="res://Sprites/MCBlocksBlackOutline.png" id="4_xm6li"] [ext_resource type="Script" path="res://Scenes/CameraController.gd" id="6_t8ide"] +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_poyp6"] +resource_name = "tinyBlocks" +texture = ExtResource("1_43rfa") +texture_region_size = Vector2i(18, 18) +0:0/0 = 0 +0:0/0/texture_origin = Vector2i(0, -4) +1:0/0 = 0 +1:0/0/texture_origin = Vector2i(0, -4) +2:0/0 = 0 +2:0/0/texture_origin = Vector2i(0, -4) +3:0/0 = 0 +3:0/0/texture_origin = Vector2i(0, -4) +4:0/0 = 0 +4:0/0/texture_origin = Vector2i(0, -4) +5:0/0 = 0 +5:0/0/texture_origin = Vector2i(0, -4) +0:1/0 = 0 +0:1/0/texture_origin = Vector2i(0, -4) +1:1/0 = 0 +1:1/0/texture_origin = Vector2i(0, -4) +2:1/0 = 0 +2:1/0/texture_origin = Vector2i(0, -4) +3:1/0 = 0 +3:1/0/texture_origin = Vector2i(0, -4) +4:1/0 = 0 +4:1/0/texture_origin = Vector2i(0, -4) +5:1/0 = 0 +5:1/0/texture_origin = Vector2i(0, -4) +0:2/0 = 0 +0:2/0/texture_origin = Vector2i(0, -4) +1:2/0 = 0 +1:2/0/texture_origin = Vector2i(0, -4) +2:2/0 = 0 +2:2/0/texture_origin = Vector2i(0, -4) +3:2/0 = 0 +3:2/0/texture_origin = Vector2i(0, -4) +4:2/0 = 0 +4:2/0/texture_origin = Vector2i(0, -4) +5:2/0 = 0 +5:2/0/texture_origin = Vector2i(0, -4) +0:3/0 = 0 +0:3/0/texture_origin = Vector2i(0, -4) +1:3/0 = 0 +1:3/0/texture_origin = Vector2i(0, -4) +2:3/0 = 0 +2:3/0/texture_origin = Vector2i(0, -4) +3:3/0 = 0 +3:3/0/texture_origin = Vector2i(0, -4) +4:3/0 = 0 +4:3/0/texture_origin = Vector2i(0, -4) +5:3/0 = 0 +5:3/0/texture_origin = Vector2i(0, -4) +0:4/0 = 0 +0:4/0/texture_origin = Vector2i(0, -4) +1:4/0 = 0 +1:4/0/texture_origin = Vector2i(0, -4) +2:4/0 = 0 +2:4/0/texture_origin = Vector2i(0, -4) +3:4/0 = 0 +3:4/0/texture_origin = Vector2i(0, -4) +4:4/0 = 0 +4:4/0/texture_origin = Vector2i(0, -4) +5:4/0 = 0 +5:4/0/texture_origin = Vector2i(0, -4) +0:5/0 = 0 +0:5/0/texture_origin = Vector2i(0, -4) +1:5/0 = 0 +1:5/0/texture_origin = Vector2i(0, -4) +2:5/0 = 0 +2:5/0/texture_origin = Vector2i(0, -4) +3:5/0 = 0 +3:5/0/texture_origin = Vector2i(0, -4) +4:5/0 = 0 +4:5/0/texture_origin = Vector2i(0, -4) +5:5/0 = 0 +5:5/0/texture_origin = Vector2i(0, -4) + +[sub_resource type="TileSet" id="TileSet_aganr"] +tile_shape = 1 +tile_size = Vector2i(16, 9) +sources/0 = SubResource("TileSetAtlasSource_poyp6") + [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_kegq5"] texture = ExtResource("4_xm6li") margins = Vector2i(4, 4) @@ -6047,6 +6130,13 @@ sources/0 = SubResource("TileSetAtlasSource_kegq5") [node name="GameScene" type="Node2D"] position = Vector2(38, 39) +[node name="Tm2" type="TileMap" parent="."] +y_sort_enabled = true +tile_set = SubResource("TileSet_aganr") +format = 2 +layer_0/y_sort_enabled = true +layer_0/tile_data = PackedInt32Array(2555917, 0, 0, 2621453, 0, 1, 2686989, 0, 0, 2752525, 0, 1, 2818060, 0, 0, 2752524, 0, 1, 2686987, 0, 0, 2621451, 0, 0, 2555915, 0, 0, 2490380, 0, 0, 2424844, 0, 0, 2490381, 0, 1, 2424845, 0, 0, 2490382, 0, 0, 2490384, 0, 0, 2424848, 0, 0, 2359313, 0, 0, 2424849, 0, 0, 2490386, 0, 0, 2555921, 0, 0, 2621457, 0, 0, 2555920, 0, 0, 2293780, 131072, 0, 2228245, 131072, 0, 2162709, 0, 0, 2097174, 0, 0, 2162710, 0, 0, 2228247, 0, 0, 2293783, 0, 0, 2359319, 0, 0, 2424855, 0, 0, 2490391, 0, 0, 2555927, 0, 0, 2621463, 0, 0, 2555926, 0, 0, 2621462, 0, 0, 2555925, 0, 0, 2490389, 0, 0, 2424852, 131072, 0, 2359316, 0, 0, 2686995, 65536, 0, 2752532, 65536, 0, 2818068, 65536, 0, 2883605, 65536, 0, 2949140, 65536, 0, 2883604, 65536, 0, 2949139, 65536, 0, 2883603, 0, 1, 2949138, 65536, 0, 3014674, 65536, 0, 2949137, 0, 1, 2883601, 0, 1, 2818065, 0, 1, 2752530, 65536, 0, 2686994, 65536, 0, 2621459, 65536, 0, 2162702, 0, 1, 2097167, 0, 1, 2031631, 0, 1, 1966096, 0, 1, 2031632, 0, 1, 2097169, 0, 1, 2162705, 0, 1, 2228241, 0, 1, 2162704, 0, 1, 2228240, 0, 1, 2293775, 0, 1, 2359311, 0, 1, 2228239, 0, 1, 2162703, 0, 1, 2097168, 0, 1, 2555916, 0, 1, 2686988, 0, 1, 2818059, 0, 1, 2883595, 0, 1, 2752526, 0, 1, 2818062, 0, 1, 2752527, 0, 1, 2818063, 0, 1, 2818064, 0, 1, 2883602, 0, 1, 2818066, 0, 1, 3014673, 0, 1, 3014672, 0, 1, 3080207, 0, 1, 3145743, 0, 1, 3080206, 0, 1, 3145742, 0, 1, 3080205, 0, 1, 3145741, 0, 1, 3080204, 0, 1, 3014669, 0, 1, 2949133, 0, 1, 3014670, 0, 1, 2949134, 0, 1, 3014671, 0, 1, 2949135, 0, 1, 2949136, 0, 1, 1703955, 0, 1, 1638419, 0, 1, 1572884, 0, 1, 1507348, 0, 1, 1441813, 0, 1, 1376277, 0, 1, 1310742, 0, 1, 1376278, 0, 1, 1441815, 0, 1, 1507351, 0, 1, 1572888, 0, 1, 1638424, 0, 1, 1703961, 0, 1, 1769496, 0, 1, 1835032, 0, 1, 1900567, 0, 1, 1966103, 0, 1, 1900566, 0, 1, 1835030, 0, 1, 1769493, 0, 1, 1703957, 0, 1, 1638420, 0, 1, 1572885, 0, 1, 1441814, 0, 1, 1507350, 0, 1, 1572886, 0, 1, 1638422, 0, 1, 1703958, 0, 1, 1638421, 0, 1, 1507349, 0, 1, 1572887, 0, 1, 1703959, 0, 1, 1769494, 0, 1, 1638423, 0, 1, 1703960, 0, 1, 1769495, 0, 1, 1835031, 0, 1, 1310736, 0, 1, 1376271, 0, 1, 1441807, 0, 1, 1507342, 0, 1, 1572878, 0, 1, 1638413, 0, 1, 1703949, 0, 1, 1769485, 0, 1, 1835021, 0, 1, 1900557, 0, 1, 1966093, 0, 1, 2031628, 0, 1, 1966092, 0, 1, 2031627, 0, 1, 2097163, 0, 1, 2031626, 0, 1, 1966091, 0, 1, 2097162, 0, 1, 2162698, 0, 1, 2228234, 0, 1, 2293769, 0, 1, 2359305, 0, 1, 2424840, 0, 1, 2490376, 0, 1, 2555912, 0, 1, 2621448, 0, 1, 2686984, 0, 1, 2752520, 0, 1, 2621449, 0, 1, 2686985, 0, 1, 2752521, 0, 1, 2818056, 0, 1, 2883592, 0, 1, 2883593, 0, 1, 2818055, 0, 1, 2686982, 0, 1, 2752517, 0, 1, 2752518, 0, 1, 2818053, 0, 1, 2883590, 0, 1, 3342346, 131072, 4, 3407883, 196608, 4, 3407882, 196608, 4, 3276810, 196608, 4, 3276811, 196608, 3, 3342347, 196608, 3, 3407884, 196608, 3, 3407889, 65536, 2, 3342353, 65536, 2, 3342354, 65536, 2, 3407890, 65536, 2, 3473426, 65536, 2, 3538962, 65536, 2, 3407891, 65536, 2, 3342355, 65536, 2, 3407892, 65536, 2, 3342356, 65536, 2, 2621458, 65536, 2, 2293773, 0, 0, 2228237, 0, 0, 2162701, 0, 0, 2228238, 0, 0, 2293774, 0, 0, 2162706, 131072, 0, 2097171, 131072, 0, 2031635, 131072, 0, 2097172, 131072, 0, 2162707, 131072, 0, 2228243, 131072, 0, 2293779, 131072, 0, 2228244, 131072, 0, 2359317, 131072, 0, 2424853, 131072, 0, 2490390, 131072, 0, 2555923, 131072, 0, 2490388, 131072, 0, 3670016, 131072, 0, 3604480, 131072, 0, 3538945, 131072, 0, 3670017, 131072, 0, 3735553, 131072, 0, 3407874, 131072, 0, 3473410, 131072, 0, 3538947, 131072, 0, 3604483, 131072, 0, 3604484, 131072, 0, 3538949, 131072, 0, 3670020, 131072, 0, 3473412, 131072, 0, 3407876, 131072, 0, 3342339, 131072, 0, 3276803, 131072, 0, 3342338, 131072, 0, 3801090, 131072, 0, 3932162, 131072, 0, 4456449, 0, 1, 4390913, 0, 1, 4325378, 0, 1, 4456450, 0, 1, 4521986, 0, 1, 4587523, 0, 1, 4653059, 0, 1, 4194307, 0, 1, 4259843, 0, 1, 4325380, 0, 1, 4390916, 0, 1, 4390917, 0, 1, 4259845, 0, 1, 4063236, 0, 1, 4128772, 0, 1, 4194309, 0, 1, 4194311, 0, 1, 4128774, 0, 1, 4063238, 0, 1, 3997701, 0, 1, 3932165, 0, 1, 3866629, 0, 1, 4128775, 0, 1, 3866630, 0, 1, 3997702, 0, 1, 3997703, 0, 1, 3997706, 0, 1, 3932171, 0, 1, 4063243, 0, 1, 4128779, 0, 1, 4194315, 0, 1, 4259851, 0, 1, 4325387, 0, 1, 4259850, 0, 1, 4128778, 0, 1, 3866634, 0, 1, 3801099, 0, 1, 3866635, 0, 1, 3932172, 0, 1, 3997707, 0, 1, 4063244, 0, 1, 4063245, 0, 1, 4063246, 0, 1, 3997710, 0, 1, 4063247, 0, 1, -983053, 131072, 2, -917517, 131072, 2, -851981, 131072, 2, -786446, 131072, 2, -720910, 131072, 2, -851982, 131072, 2, -917518, 131072, 2, -983054, 131072, 2, -917519, 131072, 2, -851983, 131072, 2, -917520, 131072, 2, -983055, 131072, 2, -1048592, 131072, 2, -1114127, 131072, 2, -1179664, 131072, 2, -1245199, 131072, 2, -1179663, 131072, 2, -1245198, 131072, 2, -1310734, 131072, 2, -1245197, 131072, 2, -720914, 65536, 0, -655378, 65536, 0, -589842, 65536, 0, -524306, 65536, 0, -458770, 65536, 0, -393235, 65536, 0, -327699, 65536, 0, -262163, 65536, 0, -196626, 65536, 0, 4259832, 65536, 0, 4194296, 65536, 0, 4128761, 65536, 0, 4456438, 0, 2, 4521975, 0, 2, 4587511, 0, 2, 4653047, 0, 2, 4587510, 0, 2, 4521974, 0, 2, 4587509, 0, 2, 4653046, 0, 2, 4718582, 0, 2, 4784118, 0, 2, 4718581, 0, 2, 4653045, 0, 2, 4521973, 0, 2, 4587508, 0, 2, 4390902, 0, 2, 4456437, 0, 2, 4325372, 0, 2, 4128756, 65536, 1, 4194291, 65536, 1, 4259827, 65536, 1, 4194290, 65536, 1, 4128755, 65536, 1, 4063218, 65536, 1, 3997683, 65536, 1, 4063219, 65536, 1, 4128754, 65536, 1, 3932147, 65536, 1, 3997684, 65536, 1, 4063220, 65536, 1, 4128757, 65536, 1, 4194292, 65536, 1, 4259828, 65536, 1, 4325363, 65536, 1, 4390899, 65536, 1, 4325362, 65536, 1, 4259826, 65536, 1, 4194289, 65536, 1, 4456434, 131072, 4, 4390898, 131072, 4, 4325361, 131072, 4, 4390897, 131072, 4, 4456432, 131072, 4, 4390896, 131072, 4, 4325360, 131072, 4, 4259824, 131072, 4, 4194288, 131072, 4, 4259825, 131072, 4, 4521971, 131072, 4, 4587506, 131072, 4, 4521970, 131072, 4, 4587505, 131072, 4, 4521969, 131072, 4, 4456433, 131072, 4, 4128753, 131072, 4, 4063217, 131072, 4, 3997681, 131072, 4, 3932145, 131072, 4, 3866610, 131072, 4, 3932146, 131072, 4, 3866611, 131072, 4, 3997682, 131072, 4, 4063216, 131072, 4, 4128752, 131072, 4, 4063215, 131072, 4, 4128751, 131072, 4, 4194287, 131072, 4, 3801074, 131072, 4, 3735539, 131072, 4, 3801075, 131072, 4, 3866612, 131072, 4, 3801076, 131072, 4, 3866613, 131072, 4, 3932149, 131072, 4, 3997685, 131072, 4, 4063221, 131072, 4, 4128758, 131072, 4, 4194294, 131072, 4, 4063222, 131072, 4, 3997686, 131072, 4, 3932148, 131072, 4, 3866614, 131072, 4, 3801077, 131072, 4, 3735541, 131072, 4, 3670004, 0, 1, 3670003, 131072, 4, 3735540, 131072, 4, 4194293, 131072, 4, 4259829, 131072, 4, 4325364, 131072, 4, 4390900, 131072, 4, 4456435, 131072, 4, 4587507, 131072, 4, 4653043, 131072, 4, 4521972, 131072, 4, 4259830, 131072, 4, 4325365, 131072, 4, 4390901, 131072, 4, 4456436, 131072, 4, 4325366, 131072, 4, 4390903, 131072, 4, 4456439, 131072, 4, 4521976, 131072, 4, 4587512, 131072, 4, 4456440, 131072, 4, 4390904, 131072, 4, 4325367, 131072, 4, 4259831, 131072, 4, 4194295, 131072, 4, 4128760, 131072, 4, 4063223, 131072, 4, 3997688, 131072, 4, 3932152, 131072, 4, 3866617, 131072, 4, 4128759, 131072, 4, 4063224, 131072, 4, 3997687, 131072, 4, 3932150, 131072, 4, 3866615, 131072, 4, 3932151, 131072, 4, 3866616, 131072, 4, 3997689, 131072, 4, 4063225, 131072, 4, 4128762, 131072, 4, 4194297, 131072, 4, 4259833, 131072, 4, 4325368, 131072, 4, 4390905, 131072, 4, 4325369, 131072, 4, 4259834, 131072, 4, 4390906, 131072, 4, 4456441, 131072, 4, 4521977, 131072, 4, 4194298, 131072, 4, 3801079, 131072, 4, 3735543, 131072, 4, 3801078, 131072, 4, 3735542, 131072, 4, 3604468, 0, 1, 3538932, 0, 1, 3604469, 0, 1, 3538933, 131072, 4, 3604470, 131072, 4, 3670006, 131072, 4, 3670005, 131072, 4, 3735538, 131072, 4, 3801073, 131072, 4, 3866609, 131072, 4, 3932144, 131072, 4, 3997680, 131072, 4, 3670002, 131072, 4, 3604467, 131072, 4, 3538931, 131072, 4, 3473396, 131072, 4, 3473397, 131072, 4, 3407860, 131072, 4) + [node name="TileMap" type="TileMap" parent="."] y_sort_enabled = true tile_set = ExtResource("1_k3ie3") @@ -6068,8 +6158,8 @@ layer_0/tile_data = PackedInt32Array(-196610, 262144, 1, -131075, 262144, 1, -65 [node name="CameraController" type="Camera2D" parent="."] script = ExtResource("6_t8ide") -[node name="Player" parent="." groups=["player"] instance=ExtResource("2_8mh54")] -position = Vector2(12, 0) +[node name="Player" parent="." instance=ExtResource("2_8mh54")] +position = Vector2(7, 1) [node name="ReferenceRect" type="ReferenceRect" parent="."] visible = false diff --git a/Scripts/Bullet.cs b/Scripts/Bullet.cs index 311bac96..9cc2fa5e 100644 --- a/Scripts/Bullet.cs +++ b/Scripts/Bullet.cs @@ -12,9 +12,19 @@ public partial class Bullet : Area2D // Called when the node enters the scene tree for the first time. public override void _Ready() { - Debug.WriteLine("Bullet Shot"); + } + public void SetDirection(Vector2 direction) + { + var normalized = direction.Normalized(); + + _direction = normalized; + + Debug.WriteLine($"Bullet Shot at direction {direction.X} {direction.Y}"); + } + + // Called every frame. 'delta' is the elapsed time since the previous frame. public override void _Process(double delta) { diff --git a/Scripts/PlayerMovement.cs b/Scripts/PlayerMovement.cs index 88bc3690..d117fe4b 100644 --- a/Scripts/PlayerMovement.cs +++ b/Scripts/PlayerMovement.cs @@ -11,13 +11,19 @@ public partial class PlayerMovement : CharacterBody2D public PackedScene BulletScene { get; set; } [Export] - public Marker2D Muzzle {get;set;} + public Marker2D Muzzle { get; set; } private AnimatedSprite2D _animatedSprite; + private Vector2 _movementDirection { get; set; } + + private Vector2 _facingDirection { get; set; } + public override void _Ready() { _animatedSprite = GetNode("AnimatedSprite2D"); + _movementDirection = Vector2.Zero; + _facingDirection = Vector2.Zero; } /*public override _Process(float _delta) @@ -41,12 +47,13 @@ public partial class PlayerMovement : CharacterBody2D private void HandleShoot() { if (Input.IsActionJustPressed("shoot")) - { + { Debug.WriteLine("Shoot"); Bullet bullet = BulletScene.Instantiate(); Owner.AddChild(bullet); bullet.Transform = Muzzle.GlobalTransform; bullet.Position = this.Position; + bullet.SetDirection(this._movementDirection); } } @@ -89,9 +96,12 @@ public partial class PlayerMovement : CharacterBody2D } public override void _PhysicsProcess(double delta) - { - var inputDirection = GetInput(); - Velocity = inputDirection * (float)(Speed * delta); + { + _movementDirection = GetInput(); + if (_movementDirection != Vector2.Zero) { + _facingDirection = _movementDirection; + } + Velocity = _movementDirection * (float)(Speed * delta); MoveAndSlide(); } diff --git a/Sprites/tinyBlocks_NOiL_1.1update.png b/Sprites/tinyBlocks_NOiL_1.1update.png new file mode 100644 index 00000000..3533059a --- /dev/null +++ b/Sprites/tinyBlocks_NOiL_1.1update.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:497f295a9cb4f7871620c7071619237126cfafd3986d24103f38b19ef4ee3f77 +size 8037 diff --git a/Sprites/tinyBlocks_NOiL_1.1update.png.import b/Sprites/tinyBlocks_NOiL_1.1update.png.import new file mode 100644 index 00000000..691c00de --- /dev/null +++ b/Sprites/tinyBlocks_NOiL_1.1update.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bxclo2fg3ulur" +path="res://.godot/imported/tinyBlocks_NOiL_1.1update.png-50a5b3cb0e9f95f564631e9103861ec5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Sprites/tinyBlocks_NOiL_1.1update.png" +dest_files=["res://.godot/imported/tinyBlocks_NOiL_1.1update.png-50a5b3cb0e9f95f564631e9103861ec5.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