diff --git a/Assets/Textures/Tilesets/colony.png b/Assets/Textures/Tilesets/colony.png index 576c4f2..28c9967 100644 Binary files a/Assets/Textures/Tilesets/colony.png and b/Assets/Textures/Tilesets/colony.png differ diff --git a/Assets/Textures/basic_enemy.png b/Assets/Textures/basic_enemy.png new file mode 100644 index 0000000..e8c3be4 Binary files /dev/null and b/Assets/Textures/basic_enemy.png differ diff --git a/Assets/Textures/basic_enemy.png.import b/Assets/Textures/basic_enemy.png.import new file mode 100644 index 0000000..dd1b928 --- /dev/null +++ b/Assets/Textures/basic_enemy.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dx5k5qa1pwbfl" +path="res://.godot/imported/basic_enemy.png-86528a00f666ed79fdb26797653efdd4.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Textures/basic_enemy.png" +dest_files=["res://.godot/imported/basic_enemy.png-86528a00f666ed79fdb26797653efdd4.ctex"] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +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 diff --git a/Scenes/Test Scene.tscn b/Scenes/Test Scene.tscn index ede47eb..15c839e 100644 --- a/Scenes/Test Scene.tscn +++ b/Scenes/Test Scene.tscn @@ -1,21 +1,26 @@ -[gd_scene load_steps=5 format=3 uid="uid://0m5qkeqoo62l"] +[gd_scene load_steps=8 format=3 uid="uid://0m5qkeqoo62l"] [ext_resource type="TileSet" uid="uid://bf1eb4aogv8ru" path="res://Assets/Tilesets/colony.tres" id="2"] [ext_resource type="Texture2D" uid="uid://dp4tdg3fxe5bf" path="res://Assets/Textures/color_cube.png" id="2_0flm2"] [ext_resource type="Script" path="res://Scripts/Player/PlayerMovement.gd" id="2_gw00d"] +[ext_resource type="Texture2D" uid="uid://dx5k5qa1pwbfl" path="res://Assets/Textures/basic_enemy.png" id="4_4sn7h"] +[ext_resource type="Script" path="res://Scripts/Enemy/EnemyMovement.gd" id="4_kd58a"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_6t40h"] size = Vector2(5.5, 5.5) +[sub_resource type="RectangleShape2D" id="RectangleShape2D_nxgkb"] +size = Vector2(6, 6) + [node name="Test Scene" type="Node2D"] [node name="TileMap" type="TileMap" parent="."] position = Vector2(0, 1) +scale = Vector2(0.898075, 0.866089) tile_set = ExtResource("2") -collision_visibility_mode = 1 format = 2 layer_0/name = "Ground" -layer_0/tile_data = PackedInt32Array(1114138, 262144, 1, 1048602, 0, 1, 983066, 0, 1, 1114137, 65536, 0, 1114136, 65536, 0, 1048603, 131072, 1, 1179675, 131072, 2, 1114139, 589824, 0, 983067, 131072, 1, 917531, 589824, 0, 1179674, 65536, 2, 917530, 262144, 0, 1179673, 1572864, 3, 917529, 65536, 2, 1179672, 65536, 2, 917528, 65536, 2, 1179671, 0, 2, 1114135, 655360, 3, 1048599, 131072, 1, 983063, 131072, 1, 917527, 196608, 0, 851995, 131072, 1, 851994, 196608, 3, 851993, 65536, 1, 851992, 196608, 3, 851991, 65536, 1, 917532, 327680, 2, 917533, 458752, 1, 983069, 327680, 1, 1048605, 327680, 1, 1114141, 458752, 2, 1114140, 327680, 2, 917525, 0, 0, 983061, 1769472, 1, 1048597, 0, 1, 1114133, 0, 2, 1114134, 65536, 2, 786456, 196608, 3, 786457, 196608, 2, 720921, 262144, 3, 720920, 262144, 3, 720919, 262144, 2, 655383, 262144, 2, 655382, 0, 1, 589848, 65536, 1, 589849, 196608, 2, 655385, 65536, 1, 655384, 262144, 3, 655386, 65536, 1, 720922, 65536, 1, 589850, 65536, 1, 524313, 65536, 1, 524312, 196608, 2, 524311, 262144, 1, 524310, 65536, 0, 589846, 262144, 0, 589847, 65536, 1, 524314, 196608, 1, 655387, 131072, 1, 589851, 131072, 1, 458776, 1638400, 1, 458777, 65536, 0, 458778, 131072, 0, 524315, 131072, 0, 458775, 0, 0, 720916, 983040, 3, 655380, 983040, 1, 589844, 917504, 1, 524308, 917504, 1, 458772, 983040, 0, 458771, 851968, 1, 524307, 1048576, 2, 589843, 851968, 1, 655379, 1048576, 3, 720915, 851968, 1, 589845, 0, 2, 524309, 0, 0, 524306, 786432, 1, 458770, 1048576, 0, 589842, 786432, 1, 655378, 1048576, 1, 655377, 851968, 0, 458769, 851968, 2, 720914, 851968, 1, 720913, 983040, 2, 655376, 851968, 0, 589839, 917504, 1, 655375, 1441792, 3, 524303, 917504, 1, 524302, 786432, 1, 589838, 786432, 1, 458768, 851968, 2, 458767, 983040, 0, 393233, 1048576, 1, 393234, 983040, 2, 393235, 851968, 1, 393236, 983040, 3, 458773, 851968, 2, 720917, 2031616, 2, 655381, 917504, 0, 393237, 851968, 1, 786452, 851968, 1, 786453, 2031616, 3, 720918, 2097152, 2, 786454, 2097152, 3, 851990, 0, 1, 851989, 917504, 2, 851988, 983040, 0, 851987, 983040, 2, 786451, 983040, 2, 458774, 917504, 2, 393238, 983040, 0, 393239, 851968, 2, 393240, 1638400, 0, 393241, 851968, 2, 393242, 917504, 2, 327706, 917504, 0, 327705, 851968, 0, 327704, 851968, 0, 327703, 851968, 0, 327702, 851968, 0, 327701, 851968, 0, 327700, 851968, 0, 327699, 851968, 0, 327698, 983040, 1, 786455, 196608, 3, 786450, 851968, 1, 917522, 786432, 2, 917524, 917504, 1, 917523, 1048576, 0, 1048596, 917504, 2, 983059, 786432, 1, 1048595, 786432, 2, 851986, 1048576, 0, 851985, 786432, 2, 786449, 1048576, 0, 786448, 786432, 2, 720912, 1048576, 0, 720911, 786432, 2, 655374, 786432, 2, 458766, 786432, 1, 393231, 851968, 0, 393232, 851968, 0, 327697, 786432, 1, 327694, 917504, 1, 327693, 1310720, 0, 262157, 786432, 1, 262158, 983040, 0, 393230, 1441792, 3, 393229, 786432, 2, 262159, 851968, 2, 262160, 851968, 2, 262161, 1048576, 0, 196625, 851968, 1, 196624, 1048576, 3, 196623, 851968, 1, 196622, 1048576, 1, 262162, 917504, 1, 196626, 983040, 0, 196627, 851968, 2, 196628, 851968, 2, 196629, 917504, 2, 131093, 917504, 0, 131092, 851968, 0, 131091, 851968, 0, 131090, 851968, 0, 131089, 851968, 0, 131088, 851968, 0, 131086, 786432, 0, 131087, 851968, 0, 196621, 786432, 0, 327692, 1114112, 2, 327691, 1114112, 2, 262154, 917504, 0, 327690, 1376256, 0, 393226, 917504, 2, 262153, 851968, 0, 327689, 851968, 1, 393225, 851968, 2, 393224, 786432, 2, 327688, 786432, 1, 262152, 786432, 0, 589855, 0, 0, 655391, 0, 2, 589856, 65536, 0, 655393, 131072, 2, 589857, 131072, 0, 786464, 851968, 1, 786463, 1048576, 3, 786465, 917504, 1, 917537, 917504, 2, 852001, 917504, 1, 852000, 983040, 2, 851999, 1048576, 0, 917535, 786432, 2, 917536, 851968, 2, 720927, 851968, 0, 720929, 917504, 0, 720928, 1572864, 1, 655392, 1572864, 0, 786462, 851968, 1, 786461, 983040, 3, 786460, 1769472, 0, 720924, 786432, 0, 720925, 851968, 0, 720926, 851968, 0, 851996, 786432, 2, 851997, 851968, 2, 851998, 851968, 2, 786458, 65536, 1, 786459, 1703936, 0, 720923, 131072, 1, 983062, 65536, 1, 1048598, 65536, 1, 983060, 1703936, 1, 917526, 262144, 1, 1245209, 1572864, 4, 1245208, 786432, 0, 1310744, 786432, 1, 1310745, 851968, 1, 1310746, 917504, 1, 1245210, 917504, 0, 1376282, 983040, 1, 1376281, 851968, 1, 1376280, 1048576, 1, 1441816, 983040, 3, 1441817, 851968, 1, 1441818, 851968, 1, 1507353, 851968, 1, 1507352, 1048576, 0, 1507354, 983040, 0, 1376279, 851968, 0, 1441815, 1048576, 2, 1507351, 851968, 2, 1572888, 786432, 1, 1572889, 851968, 1, 1572890, 917504, 1, 1507355, 851968, 2, 1441819, 851968, 1, 1376283, 851968, 0, 1376284, 917504, 0, 1441820, 1703936, 4, 1507356, 917504, 2, 1376278, 786432, 0, 1441814, 1769472, 3, 1507350, 786432, 2, 1638424, 786432, 2, 1638425, 1638400, 3, 1638426, 917504, 2, 1507349, 131072, 2, 1441813, 1703936, 3, 1376277, 131072, 0, 1376276, 65536, 0, 1376275, 65536, 0, 1441811, 65536, 1, 1507347, 2293760, 0, 1507348, 65536, 2, 1441812, 65536, 1, 1376285, 0, 0, 1376286, 65536, 0, 1441822, 196608, 3, 1441823, 65536, 1, 1507358, 65536, 2, 1507357, 0, 2, 1441821, 1769472, 4, 1376287, 65536, 0, 1507359, 2228224, 0, 1507360, 2293760, 0, 1441824, 196608, 1, 1376288, 131072, 0, 1376274, 0, 0, 1441810, 262144, 1, 1507346, 2228224, 0, 1703960, 0, 0, 1703961, 1638400, 4, 1703962, 131072, 0, 1769498, 131072, 1, 1769497, 65536, 1, 1769496, 0, 1, 1835032, 0, 1, 1835033, 262144, 3, 1900569, 65536, 1, 1835034, 131072, 1, 1900570, 131072, 1, 1900568, 0, 1, 1572884, 917504, 0, 1572883, 2293760, 1, 1572882, 2228224, 1, 1638418, 851968, 1, 1703954, 851968, 2, 1638419, 851968, 1, 1638420, 917504, 1, 1703956, 917504, 2, 1703955, 851968, 2, 1703953, 786432, 2, 1638417, 786432, 1, 1572881, 786432, 0, 1572894, 786432, 0, 1638430, 786432, 2, 1638432, 851968, 2, 1638433, 917504, 2, 1638431, 851968, 2, 1572895, 2228224, 1, 1572896, 2293760, 1, 1572897, 917504, 0, 1507345, 0, 2, 1441809, 0, 0, 1507361, 131072, 2, 1441825, 131072, 0, 2097178, 2228224, 3, 2031641, 65536, 1, 1966104, 0, 1, 2162714, 131072, 2, 2031642, 2228224, 2, 1966106, 131072, 1, 2162713, 65536, 2, 2097177, 65536, 1, 1966105, 65536, 1, 2162712, 0, 2, 2097176, 2424832, 3, 2031640, 2424832, 2, 2162711, 917504, 2, 2097175, 2359296, 3, 2031639, 2359296, 2, 1966103, 917504, 0, 1966102, 851968, 0, 1966101, 851968, 0, 1966100, 851968, 0, 1966099, 786432, 0, 2162710, 851968, 2, 2097174, 1048576, 2, 2031638, 1048576, 3, 2162709, 851968, 2, 2097173, 1048576, 2, 2031637, 1048576, 3, 2162708, 851968, 2, 2097172, 983040, 2, 2031636, 851968, 1, 2162707, 786432, 2, 2097171, 786432, 1, 2031635, 786432, 1, 1966107, 786432, 0, 2031643, 2293760, 2, 2031644, 851968, 1, 2097180, 851968, 1, 2097181, 983040, 2, 2162718, 851968, 2, 2162719, 917504, 2, 2097183, 917504, 1, 2031647, 917504, 1, 1966111, 917504, 0, 2097182, 983040, 3, 2031646, 851968, 1, 1966110, 851968, 0, 2162717, 851968, 2, 2031645, 851968, 1, 1966109, 851968, 0, 2162716, 851968, 2, 1966108, 851968, 0, 2162715, 786432, 2, 2097179, 2293760, 3) +layer_0/tile_data = PackedInt32Array(1114138, 262144, 1, 1048602, 0, 1, 983066, 0, 1, 1114137, 65536, 0, 1114136, 65536, 0, 1048603, 131072, 1, 1179675, 131072, 2, 1114139, 589824, 0, 983067, 131072, 1, 917531, 589824, 0, 1179674, 65536, 2, 917530, 262144, 0, 1179673, 1572864, 3, 917529, 65536, 2, 1179672, 65536, 2, 917528, 65536, 2, 1179671, 0, 2, 1114135, 655360, 3, 1048599, 131072, 1, 983063, 131072, 1, 917527, 196608, 0, 851995, 131072, 1, 851994, 196608, 3, 851993, 65536, 1, 851992, 196608, 3, 851991, 65536, 1, 917532, 327680, 2, 917533, 458752, 1, 983069, 327680, 1, 1048605, 327680, 1, 1114141, 458752, 2, 1114140, 327680, 2, 917525, 0, 0, 983061, 1769472, 1, 1048597, 0, 1, 1114133, 0, 2, 1114134, 65536, 2, 786456, 196608, 3, 786457, 196608, 2, 720921, 262144, 3, 720920, 262144, 3, 720919, 262144, 2, 655383, 262144, 2, 655382, 0, 1, 589848, 65536, 1, 589849, 196608, 2, 655385, 65536, 1, 655384, 262144, 3, 655386, 65536, 1, 720922, 65536, 1, 589850, 65536, 1, 524313, 65536, 1, 524312, 196608, 2, 524311, 262144, 1, 524310, 65536, 0, 589846, 262144, 0, 589847, 65536, 1, 524314, 196608, 1, 655387, 131072, 1, 589851, 131072, 1, 458776, 1638400, 1, 458777, 65536, 0, 458778, 131072, 0, 524315, 131072, 0, 458775, 0, 0, 720916, 983040, 3, 655380, 983040, 1, 589844, 917504, 1, 524308, 917504, 1, 458772, 983040, 0, 458771, 851968, 1, 524307, 1048576, 2, 589843, 851968, 1, 655379, 1048576, 3, 720915, 851968, 1, 589845, 0, 2, 524309, 0, 0, 524306, 786432, 1, 458770, 1048576, 0, 589842, 786432, 1, 655378, 1048576, 1, 655377, 851968, 0, 458769, 851968, 2, 720914, 851968, 1, 720913, 983040, 2, 655376, 851968, 0, 589839, 917504, 1, 655375, 1441792, 3, 524303, 917504, 1, 524302, 786432, 1, 589838, 786432, 1, 458768, 851968, 2, 458767, 983040, 0, 393233, 1048576, 1, 393234, 983040, 2, 393235, 851968, 1, 393236, 983040, 3, 458773, 851968, 2, 720917, 2031616, 2, 655381, 917504, 0, 393237, 851968, 1, 786452, 851968, 1, 786453, 2031616, 3, 720918, 2097152, 2, 786454, 2097152, 3, 851990, 0, 1, 851989, 917504, 2, 851988, 983040, 0, 851987, 983040, 2, 786451, 983040, 2, 458774, 917504, 2, 393238, 983040, 0, 393239, 851968, 2, 393240, 1638400, 0, 393241, 851968, 2, 393242, 917504, 2, 327706, 917504, 0, 327705, 851968, 0, 327704, 851968, 0, 327703, 851968, 0, 327702, 851968, 0, 327701, 851968, 0, 327700, 851968, 0, 327699, 851968, 0, 327698, 983040, 1, 786455, 196608, 3, 786450, 851968, 1, 917522, 786432, 2, 917524, 917504, 1, 917523, 1048576, 0, 1048596, 917504, 2, 983059, 786432, 1, 1048595, 786432, 2, 851986, 1048576, 0, 851985, 786432, 2, 786449, 1048576, 0, 786448, 786432, 2, 720912, 1048576, 0, 720911, 786432, 2, 655374, 786432, 2, 458766, 786432, 1, 393231, 851968, 0, 393232, 851968, 0, 327697, 786432, 1, 327694, 917504, 1, 327693, 1310720, 0, 262157, 786432, 1, 262158, 983040, 0, 393230, 1441792, 3, 393229, 786432, 2, 262159, 851968, 2, 262160, 851968, 2, 262161, 1048576, 0, 196625, 851968, 1, 196624, 1048576, 3, 196623, 851968, 1, 196622, 1048576, 1, 262162, 917504, 1, 196626, 983040, 0, 196627, 851968, 2, 196628, 851968, 2, 196629, 917504, 2, 131093, 917504, 0, 131092, 851968, 0, 131091, 851968, 0, 131090, 851968, 0, 131089, 851968, 0, 131088, 851968, 0, 131086, 786432, 0, 131087, 851968, 0, 196621, 786432, 0, 327692, 1114112, 2, 327691, 1114112, 2, 262154, 917504, 0, 327690, 1376256, 0, 393226, 917504, 2, 262153, 851968, 0, 327689, 851968, 1, 393225, 851968, 2, 393224, 786432, 2, 327688, 786432, 1, 262152, 786432, 0, 589855, 0, 0, 655391, 0, 2, 589856, 65536, 0, 655393, 131072, 2, 589857, 131072, 0, 786464, 851968, 1, 786463, 1048576, 3, 786465, 917504, 1, 917537, 917504, 2, 852001, 917504, 1, 852000, 983040, 2, 851999, 1048576, 0, 917535, 786432, 2, 917536, 851968, 2, 720927, 851968, 0, 720929, 917504, 0, 720928, 1572864, 1, 655392, 1572864, 0, 786462, 851968, 1, 786461, 983040, 3, 786460, 1769472, 0, 720924, 786432, 0, 720925, 851968, 0, 720926, 851968, 0, 851996, 786432, 2, 851997, 851968, 2, 851998, 851968, 2, 786458, 65536, 1, 786459, 1703936, 0, 720923, 131072, 1, 983062, 65536, 1, 1048598, 65536, 1, 983060, 1703936, 1, 917526, 262144, 1, 1245209, 1572864, 4, 1245208, 786432, 0, 1310744, 786432, 1, 1310745, 851968, 1, 1310746, 917504, 1, 1245210, 917504, 0, 1376282, 983040, 1, 1376281, 851968, 1, 1376280, 1048576, 1, 1441816, 983040, 3, 1441817, 851968, 1, 1441818, 851968, 1, 1507353, 851968, 1, 1507352, 1048576, 0, 1507354, 983040, 0, 1376279, 851968, 0, 1441815, 1048576, 2, 1507351, 851968, 2, 1572888, 786432, 1, 1572889, 851968, 1, 1572890, 917504, 1, 1441819, 1048576, 2, 1376283, 851968, 0, 1376278, 786432, 0, 1441814, 1769472, 3, 1507350, 786432, 2, 1638424, 786432, 2, 1638425, 1638400, 3, 1638426, 917504, 2, 1507349, 131072, 2, 1441813, 1703936, 3, 1376277, 131072, 0, 1376276, 65536, 0, 1376275, 65536, 0, 1441811, 65536, 1, 1507347, 2293760, 0, 1507348, 65536, 2, 1441812, 65536, 1, 1376286, 65536, 0, 1441822, 262144, 3, 1441823, 65536, 1, 1507358, 65536, 2, 1376287, 65536, 0, 1507359, 2228224, 0, 1507360, 2293760, 0, 1441824, 196608, 1, 1376288, 131072, 0, 1376274, 0, 0, 1441810, 262144, 1, 1507346, 2228224, 0, 1703960, 0, 0, 1703961, 1638400, 4, 1703962, 131072, 0, 1769498, 131072, 1, 1769497, 65536, 1, 1769496, 0, 1, 1835032, 0, 1, 1835033, 262144, 3, 1900569, 65536, 1, 1835034, 131072, 1, 1900570, 131072, 1, 1900568, 0, 1, 1572884, 917504, 0, 1572883, 2293760, 1, 1572882, 2228224, 1, 1638418, 851968, 1, 1703954, 851968, 2, 1638419, 851968, 1, 1638420, 917504, 1, 1703956, 917504, 2, 1703955, 851968, 2, 1703953, 786432, 2, 1638417, 786432, 1, 1572881, 786432, 0, 1572894, 786432, 0, 1638430, 786432, 2, 1638432, 851968, 2, 1638433, 917504, 2, 1638431, 851968, 2, 1572895, 2228224, 1, 1572896, 2293760, 1, 1572897, 917504, 0, 1507345, 0, 2, 1441809, 0, 0, 1507361, 131072, 2, 1441825, 131072, 0, 2097178, 2228224, 3, 2031641, 65536, 1, 1966104, 0, 1, 2162714, 131072, 2, 2031642, 2228224, 2, 1966106, 131072, 1, 2162713, 65536, 2, 2097177, 65536, 1, 1966105, 65536, 1, 2162712, 0, 2, 2097176, 2424832, 3, 2031640, 2424832, 2, 2162711, 917504, 2, 2097175, 2359296, 3, 2031639, 2359296, 2, 1966103, 917504, 0, 1966102, 851968, 0, 1966101, 851968, 0, 1966100, 851968, 0, 1966099, 786432, 0, 2162710, 851968, 2, 2097174, 1048576, 2, 2031638, 1048576, 3, 2162709, 851968, 2, 2097173, 1048576, 2, 2031637, 1048576, 3, 2162708, 851968, 2, 2097172, 983040, 2, 2031636, 851968, 1, 2162707, 786432, 2, 2097171, 786432, 1, 2031635, 786432, 1, 1966107, 786432, 0, 2031643, 2293760, 2, 2031644, 851968, 1, 2097180, 851968, 1, 2097181, 983040, 2, 2162718, 851968, 2, 2162719, 917504, 2, 2097183, 917504, 1, 2031647, 917504, 1, 1966111, 917504, 0, 2097182, 983040, 3, 2031646, 851968, 1, 1966110, 851968, 0, 2162717, 851968, 2, 2031645, 851968, 1, 1966109, 851968, 0, 2162716, 851968, 2, 1966108, 851968, 0, 2162715, 786432, 2, 2097179, 2293760, 3, 1376285, 0, 0, 1441821, 1769472, 4, 1376284, 917504, 0, 1441820, 1703936, 4, 1507355, 851968, 2, 1507356, 917504, 2, 1507357, 0, 2) [node name="Player" type="CharacterBody2D" parent="."] script = ExtResource("2_gw00d") @@ -38,3 +43,14 @@ editor_draw_drag_margin = true [node name="CollisionShape2D" type="CollisionShape2D" parent="Player"] position = Vector2(149, 86) shape = SubResource("RectangleShape2D_6t40h") + +[node name="BasicEnemy" type="CharacterBody2D" parent="."] +script = ExtResource("4_kd58a") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="BasicEnemy"] +position = Vector2(206, 65) +shape = SubResource("RectangleShape2D_nxgkb") + +[node name="Sprite2D" type="Sprite2D" parent="BasicEnemy"] +position = Vector2(206, 65) +texture = ExtResource("4_4sn7h") diff --git a/Scripts/Enemy/EnemyMovement.gd b/Scripts/Enemy/EnemyMovement.gd new file mode 100644 index 0000000..febcb84 --- /dev/null +++ b/Scripts/Enemy/EnemyMovement.gd @@ -0,0 +1,19 @@ +extends CharacterBody2D + +@export var speed = 25 + +# 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 _physics_process(delta): + var sprite = self.get_child(1) + self.velocity = Vector2(cos(sprite.get_rotation() - PI / 2), sin(sprite.get_rotation() - PI / 2)).normalized() * speed + + + if self.move_and_slide(): + sprite.rotate(PI) + + diff --git a/Scripts/Player/PlayerMovement.gd b/Scripts/Player/PlayerMovement.gd index e80a06a..3fb1c03 100644 --- a/Scripts/Player/PlayerMovement.gd +++ b/Scripts/Player/PlayerMovement.gd @@ -2,17 +2,17 @@ extends CharacterBody2D @export var speed = 50 -# Called when the node enters the scene tree for the first time. +# Called when the node enters the scene tree for the first time. func _ready(): pass # Replace with function body. func get_input(): - var input_direction = Input.get_vector("move_left", "move_right", "move_up", "move_down") - velocity = input_direction * speed + var input_direction = Input.get_vector("move_left", "move_right", "move_up", "move_down").normalized() + return input_direction # Called every frame. 'delta' is the elapsed time since the previous frame. func _physics_process(delta): - get_input() - move_and_slide() + self.velocity = get_input() * speed + self.move_and_slide()