diff --git a/assets/textures/test_background_tileset.png b/assets/textures/test_background_tileset.png index a594baf..25b4cc0 100644 Binary files a/assets/textures/test_background_tileset.png and b/assets/textures/test_background_tileset.png differ diff --git a/project.godot b/project.godot index 1faf0a9..e737fd5 100644 --- a/project.godot +++ b/project.godot @@ -80,4 +80,5 @@ common/enable_pause_aware_picking=true [rendering] +2d/snapping/use_gpu_pixel_snap=true environment/default_environment="res://default_env.tres" diff --git a/scenes/Player.tscn b/scenes/Player.tscn index 4394d55..5c510cd 100644 --- a/scenes/Player.tscn +++ b/scenes/Player.tscn @@ -11,15 +11,11 @@ animations = [ { "speed": 5.0 } ] -[sub_resource type="CapsuleShape2D" id=2] -radius = 30.0 -height = 4.0 +[sub_resource type="RectangleShape2D" id=2] +extents = Vector2( 30.5, 30.5 ) -[node name="Player" type="Area2D"] +[node name="Player" type="KinematicBody2D"] script = ExtResource( 2 ) -__meta__ = { -"_edit_group_": true -} [node name="AnimatedSprite" type="AnimatedSprite" parent="."] frames = SubResource( 1 ) diff --git a/scenes/World.tscn b/scenes/World.tscn index deb8cda..6d0a8d7 100644 --- a/scenes/World.tscn +++ b/scenes/World.tscn @@ -8,9 +8,9 @@ tile_set = ExtResource( 1 ) cell_size = Vector2( 512, 512 ) cell_quadrant_size = 128 format = 1 -tile_data = PoolIntArray( -196612, 0, 0, -196611, 0, 1, -196610, 0, 1, -196609, 0, 1, -262144, 0, 1, -262143, 0, 1, -262142, 0, 1, -262141, 0, 2, -131076, 0, 65536, -131075, 0, 65537, -131074, 0, 131073, -131073, 0, 131073, -196608, 0, 131073, -196607, 0, 131073, -196606, 0, 65537, -196605, 0, 65538, -65540, 0, 65536, -65539, 0, 65538, -131070, 0, 65536, -131069, 0, 65538, -4, 0, 65536, -3, 0, 65537, -2, 0, 1, -1, 0, 1, -65536, 0, 1, -65535, 0, 1, -65534, 0, 65537, -65533, 0, 65538, 65532, 0, 65536, 65533, 0, 65537, 65534, 0, 65537, 65535, 0, 65537, 0, 0, 65537, 1, 0, 65537, 2, 0, 65537, 3, 0, 65538, 131068, 0, 65536, 131069, 0, 65537, 131070, 0, 65537, 131071, 0, 65537, 65536, 0, 65537, 65537, 0, 65537, 65538, 0, 65537, 65539, 0, 65538, 196604, 0, 131072, 196605, 0, 131073, 196606, 0, 131073, 196607, 0, 131073, 131072, 0, 131073, 131073, 0, 131073, 131074, 0, 131073, 131075, 0, 131074 ) +tile_data = PoolIntArray( -196612, 0, 0, -196611, 0, 1, -196610, 0, 1, -196609, 0, 1, -262144, 0, 1, -262143, 0, 1, -262142, 0, 1, -262141, 0, 2, -131076, 0, 65536, -131075, 0, 65537, -131074, 0, 131073, -131073, 0, 131073, -196608, 0, 131073, -196607, 0, 131073, -196606, 0, 65537, -196605, 0, 65538, -65540, 0, 65536, -65539, 0, 65538, -131070, 0, 65536, -131069, 0, 65538, -4, 0, 65536, -3, 0, 65537, -2, 0, 1, -1, 0, 1, -65536, 536870912, 1, -65535, 0, 1, -65534, 0, 65537, -65533, 0, 65538, 65532, 0, 65536, 65533, 0, 65537, 65534, 0, 65537, 65535, 0, 65537, 0, 0, 65537, 1, 0, 65537, 2, 0, 65537, 3, 0, 65538, 131068, 0, 65536, 131069, 0, 65537, 131070, 0, 65537, 131071, 0, 65537, 65536, 0, 65537, 65537, 0, 65537, 65538, 0, 65537, 65539, 0, 65538, 196604, 0, 131072, 196605, 0, 131073, 196606, 0, 131073, 196607, 0, 131073, 131072, 0, 131073, 131073, 0, 131073, 131074, 0, 131073, 131075, 0, 131074 ) [node name="Foreground" type="TileMap" parent="."] tile_set = ExtResource( 2 ) format = 1 -tile_data = PoolIntArray( 196607, 0, 0, 131072, 0, 0, 131073, 0, 0, 196608, 0, 0, 196609, 0, 0, 327678, 0, 0, 327679, 0, 0, 262144, 0, 0, 262145, 0, 0, 393214, 0, 0, 393215, 0, 0, 327680, 0, 0, 327681, 0, 0, 327682, 0, 0, 393216, 0, 0, 393217, 0, 0, 393218, 0, 0, 458752, 0, 0, 458753, 0, 0, 458754, 0, 0, 524289, 0, 0, 524290, 0, 0, 589826, 0, 0 ) +tile_data = PoolIntArray( -1769494, 0, 0, -1769493, 0, 0, -1703959, 0, 0, -1703958, 0, 0, -1703957, 0, 0, -1703956, 0, 0, -1638426, 0, 0, -1638425, 0, 0, -1638424, 0, 0, -1638423, 0, 0, -1638420, 0, 0, -1572891, 0, 0, -1572890, 0, 0, -1572888, 0, 0, -1572884, 0, 0, -1507355, 0, 0, -1507349, 0, 0, -1507348, 0, 0, -1441819, 0, 0, -1441814, 0, 0, -1441813, 0, 0, -1376283, 0, 0, -1376282, 0, 0, -1376278, 0, 0, -1310746, 0, 0, -1310745, 0, 0, -1310743, 0, 0, -1310742, 0, 0, -1245209, 0, 0, -1245208, 0, 0, -1245207, 0, 0, -458775, 0, 0, -393239, 0, 0, -393235, 0, 0, -327708, 0, 0, -327707, 0, 0, -327700, 0, 0, -327699, 0, 0, -262168, 0, 0, -262167, 0, 0, -262165, 0, 0, -262164, 0, 0, -196633, 0, 0, -196632, 0, 0, -196631, 0, 0, -131097, 0, 0, -131096, 0, 0, -131095, 0, 0, -131094, 0, 0, -196595, 0, 0, -196586, 0, 0, -65561, 0, 0, -65560, 0, 0, -65559, 0, 0, -65558, 0, 0, -131059, 0, 0, -131056, 0, 0, -131055, 0, 0, -131050, 0, 0, -29, 0, 0, -28, 0, 0, -27, 0, 0, -20, 0, 0, -65524, 0, 0, -65520, 0, 0, 65507, 0, 0, 65511, 0, 0, 65516, 0, 0, 65517, 0, 0, 12, 0, 0, 13, 0, 0, 14, 0, 0, 15, 0, 0, 16, 0, 0, 21, 0, 0, 131047, 0, 0, 131048, 0, 0, 131053, 0, 0, 65547, 0, 0, 65548, 0, 0, 65550, 0, 0, 65551, 0, 0, 65557, 0, 0, 131083, 0, 0, 131085, 0, 0, 131092, 0, 0, 196627, 0, 0, 196628, 0, 0, 327678, 0, 0, 327679, 0, 0, 262144, 0, 0, 262145, 0, 0, 393193, 0, 0, 393194, 0, 0, 393214, 0, 0, 327680, 0, 0, 327681, 0, 0, 327682, 0, 0, 458729, 0, 0, 458730, 0, 0, 458734, 0, 0, 458735, 0, 0, 458736, 0, 0, 458750, 0, 0, 458751, 0, 0, 393216, 0, 0, 393217, 0, 0, 393218, 0, 0, 524265, 0, 0, 524266, 0, 0, 524269, 0, 0, 524270, 0, 0, 524271, 0, 0, 524272, 0, 0, 524273, 0, 0, 524286, 0, 0, 524287, 0, 0, 458752, 0, 0, 458753, 0, 0, 458754, 0, 0, 589805, 0, 0, 589806, 0, 0, 589807, 0, 0, 589808, 0, 0, 589809, 0, 0, 589822, 0, 0, 524289, 0, 0, 655342, 0, 0, 655343, 0, 0, 655344, 0, 0, 655358, 0, 0, 589825, 0, 0, 786408, 0, 0, 851943, 0, 0, 851944, 0, 0, 851951, 0, 0, 851952, 0, 0, 917478, 0, 0, 917479, 0, 0, 917480, 0, 0, 917486, 0, 0, 917487, 0, 0, 917488, 0, 0, 851983, 0, 0, 851984, 0, 0, 851985, 0, 0, 851986, 0, 0, 851987, 0, 0, 851988, 0, 0, 851989, 0, 0, 851990, 0, 0, 851991, 0, 0, 851992, 0, 0, 851993, 0, 0, 851994, 0, 0, 983015, 0, 0, 983016, 0, 0, 983017, 0, 0, 983018, 0, 0, 983019, 0, 0, 983020, 0, 0, 983021, 0, 0, 983022, 0, 0, 917518, 0, 0, 917521, 0, 0, 917522, 0, 0, 917524, 0, 0, 917525, 0, 0, 917527, 0, 0, 917528, 0, 0, 917530, 0, 0, 1048552, 0, 0, 1048553, 0, 0, 1048554, 0, 0, 1048555, 0, 0, 983047, 0, 0, 983048, 0, 0, 983049, 0, 0, 983050, 0, 0, 983051, 0, 0, 983052, 0, 0, 983053, 0, 0, 983054, 0, 0, 983055, 0, 0, 983056, 0, 0, 983057, 0, 0, 983058, 0, 0, 983060, 0, 0, 983061, 0, 0, 983063, 0, 0, 983064, 0, 0, 983065, 0, 0, 983066, 0, 0, 983067, 0, 0, 1048582, 0, 0, 1048583, 0, 0, 1048584, 0, 0, 1048585, 0, 0, 1048586, 0, 0, 1048587, 0, 0, 1048588, 0, 0, 1048590, 0, 0, 1048592, 0, 0, 1048593, 0, 0, 1048594, 0, 0, 1048599, 0, 0, 1048600, 0, 0, 1048601, 0, 0, 1048602, 0, 0, 1048603, 0, 0, 1114117, 0, 0, 1114118, 0, 0, 1114120, 0, 0, 1114121, 0, 0, 1114122, 0, 0, 1114123, 0, 0, 1114124, 0, 0, 1114126, 0, 0, 1114127, 0, 0, 1179656, 0, 0, 1179657, 0, 0, 1179658, 0, 0, 1179659, 0, 0, 1179660, 0, 0 ) diff --git a/src/Player.cs b/src/Player.cs index b8cc73f..9ff59d8 100644 --- a/src/Player.cs +++ b/src/Player.cs @@ -1,32 +1,39 @@ using Godot; using System; -public class Player : Area2D +public class Player : KinematicBody2D { + private Vector2 velocity; + [Export] public int speed = 400; - public override void _Ready() - { - - } - public override void _Process(float delta) - { + public override void _PhysicsProcess(float delta) + { + GetInput(); + MoveAndCollide(velocity * delta); + } + + public void GetInput() + { + velocity = new Vector2(); if (Input.IsActionPressed("move_left")) { - Position -= new Vector2(speed, 0) * delta; + velocity.x -= speed; } if (Input.IsActionPressed("move_right")) { - Position += new Vector2(speed, 0) * delta; + velocity.x += speed; } if (Input.IsActionPressed("move_up")) { - Position -= new Vector2(0, speed) * delta; + velocity.y -= speed; } if (Input.IsActionPressed("move_down")) { - Position += new Vector2(0, speed) * delta; + velocity.y += speed; } } + + } diff --git a/tilesets/foreground_test.tres b/tilesets/foreground_test.tres index ecbb8f3..2a5f155 100644 --- a/tilesets/foreground_test.tres +++ b/tilesets/foreground_test.tres @@ -1,7 +1,23 @@ -[gd_resource type="TileSet" load_steps=2 format=2] +[gd_resource type="TileSet" load_steps=7 format=2] [ext_resource path="res://assets/textures/cupcake.png" type="Texture" id=1] +[sub_resource type="NavigationPolygon" id=1] +vertices = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) +polygons = [ PoolIntArray( 0, 1, 2, 3 ) ] +outlines = [ PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) ] + +[sub_resource type="OccluderPolygon2D" id=2] +polygon = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConcavePolygonShape2D" id=3] +segments = PoolVector2Array( 0, 0, 64, 0, 64, 0, 64, 64, 64, 64, 0, 64, 0, 64, 0, 0 ) + +[sub_resource type="ConcavePolygonShape2D" id=4] +segments = PoolVector2Array( 64, 64, 0, 64, 0, 64, 0, 0, 0, 0, 64, 0, 64, 0, 64, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=5] + [resource] 0/name = "cupcake.png 0" 0/texture = ExtResource( 1 ) @@ -10,16 +26,31 @@ 0/region = Rect2( 0, 0, 64, 64 ) 0/tile_mode = 0 0/occluder_offset = Vector2( 0, 0 ) +0/occluder = SubResource( 2 ) 0/navigation_offset = Vector2( 0, 0 ) +0/navigation = SubResource( 1 ) 0/shape_offset = Vector2( 0, 0 ) 0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) +0/shape = SubResource( 3 ) 0/shape_one_way = false 0/shape_one_way_margin = 1.0 0/shapes = [ { "autotile_coord": Vector2( 0, 0 ), "one_way": false, "one_way_margin": 1.0, -"shape": null, +"shape": SubResource( 3 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 0, 0 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 4 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 0, 0 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 5 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) } ] 0/z_index = 0