diff --git a/assets/apple.png b/assets/apple.png new file mode 100644 index 0000000..64335a3 Binary files /dev/null and b/assets/apple.png differ diff --git a/assets/apple.png.import b/assets/apple.png.import new file mode 100644 index 0000000..9e91e2e --- /dev/null +++ b/assets/apple.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dmmdu0ayhmlnk" +path="res://.godot/imported/apple.png-d0c5a0e024efc439723035186c67a74a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/apple.png" +dest_files=["res://.godot/imported/apple.png-d0c5a0e024efc439723035186c67a74a.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 diff --git a/assets/smallMap.png b/assets/smallMap.png new file mode 100644 index 0000000..c24d869 Binary files /dev/null and b/assets/smallMap.png differ diff --git a/assets/smallMap.png.import b/assets/smallMap.png.import new file mode 100644 index 0000000..a93e64d --- /dev/null +++ b/assets/smallMap.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b1sese4p8sck3" +path="res://.godot/imported/smallMap.png-d58217680d47594e6bef5c91f3e22694.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/smallMap.png" +dest_files=["res://.godot/imported/smallMap.png-d58217680d47594e6bef5c91f3e22694.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 diff --git a/braincell.gd b/braincell.gd index 4af03cd..2ede0ec 100644 --- a/braincell.gd +++ b/braincell.gd @@ -9,12 +9,12 @@ var ready_to_door : bool = true func _physics_process(delta: float) -> void: # Add the gravity. - if not is_on_floor(): - velocity += get_gravity() * delta - - # Handle jump. - if Input.is_action_just_pressed("ui_accept") and is_on_floor(): - velocity.y = JUMP_VELOCITY + #if not is_on_floor(): + #velocity += get_gravity() * delta +# + ## Handle jump. + #if Input.is_action_just_pressed("ui_accept") and is_on_floor(): + #velocity.y = JUMP_VELOCITY # Get the input direction and handle the movement/deceleration. # As good practice, you should replace UI actions with custom gameplay actions. diff --git a/camera_2d.gd b/camera_2d.gd index ac35fb3..6ca87f3 100644 --- a/camera_2d.gd +++ b/camera_2d.gd @@ -27,7 +27,7 @@ func _process(delta: float) -> void: snake_line.z_index = 9 else: position = Vector2(0,0) - zoom = Vector2(0.05,0.05) + zoom = Vector2(0.1,0.1) snake_line.modulate = Color(1,1,1,1) snake_line.z_index = 11 z_index = 1 diff --git a/prefabs/apple.tscn b/prefabs/apple.tscn new file mode 100644 index 0000000..5c6310d --- /dev/null +++ b/prefabs/apple.tscn @@ -0,0 +1,15 @@ +[gd_scene load_steps=3 format=3 uid="uid://qpjwodeafyno"] + +[ext_resource type="Texture2D" uid="uid://dmmdu0ayhmlnk" path="res://assets/apple.png" id="1_sblxh"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_5v1qd"] +radius = 50.0 + +[node name="Apple" type="Area2D" groups=["apple"]] + +[node name="Sprite2D" type="Sprite2D" parent="."] +scale = Vector2(10, 10) +texture = ExtResource("1_sblxh") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_5v1qd") diff --git a/prefabs/snake_segment.gd b/prefabs/snake_segment.gd index ebeefcf..60e1c31 100644 --- a/prefabs/snake_segment.gd +++ b/prefabs/snake_segment.gd @@ -61,3 +61,13 @@ func become_fake(): #modulate = Color.DIM_GRAY #collision_layer = 2 pass + + +func _on_eat_die_box_area_entered(area: Area2D) -> void: + if(area.is_in_group("apple")): + area.queue_free() + print("mmm tasty apple") + if(area.is_in_group("wall")): + print("i die") + get_tree().get_root().process_mode = Node.PROCESS_MODE_DISABLED + diff --git a/prefabs/snake_segment.tscn b/prefabs/snake_segment.tscn index dafddc1..ba1afbc 100644 --- a/prefabs/snake_segment.tscn +++ b/prefabs/snake_segment.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=7 format=3 uid="uid://bwoeu7ask0fck"] +[gd_scene load_steps=8 format=3 uid="uid://bwoeu7ask0fck"] [ext_resource type="Script" uid="uid://b5cqo12km1nh3" path="res://prefabs/snake_segment.gd" id="1_3ulhv"] [ext_resource type="Texture2D" uid="uid://l8x3dp68yyxr" path="res://assets/segement.png" id="1_6uqch"] @@ -9,6 +9,9 @@ [sub_resource type="RectangleShape2D" id="RectangleShape2D_08kyq"] size = Vector2(8, 64) +[sub_resource type="CircleShape2D" id="CircleShape2D_08kyq"] +radius = 50.0 + [node name="SnakeSegment" type="AnimatableBody2D" node_paths=PackedStringArray("door")] script = ExtResource("1_3ulhv") door = NodePath("DoorArm") @@ -49,3 +52,10 @@ shape = SubResource("RectangleShape2D_08kyq") [node name="Sprite2D" type="Sprite2D" parent="DoorArm/Door"] texture = ExtResource("4_34t3n") + +[node name="EatDieBox" type="Area2D" parent="."] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="EatDieBox"] +shape = SubResource("CircleShape2D_08kyq") + +[connection signal="area_entered" from="EatDieBox" to="." method="_on_eat_die_box_area_entered"] diff --git a/prefabs/wall.tscn b/prefabs/wall.tscn new file mode 100644 index 0000000..03dd534 --- /dev/null +++ b/prefabs/wall.tscn @@ -0,0 +1,9 @@ +[gd_scene load_steps=2 format=3 uid="uid://bl5py87o1qbgr"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_iy8pp"] +size = Vector2(6400, 320) + +[node name="Wall" type="Area2D" groups=["wall"]] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("RectangleShape2D_iy8pp") diff --git a/project.godot b/project.godot index a7d64c6..64d186b 100644 --- a/project.godot +++ b/project.godot @@ -29,6 +29,11 @@ window/stretch/mode="canvas_items" enabled=PackedStringArray("res://addons/godot-donut-collision-polygon-2d-7780d026ae3d4a37fe68f43cc1f97ba664dd775d/addons/donut_collision_polygon2D/plugin.cfg") +[global_group] + +apple="" +wall="" + [input] left={ diff --git a/test.tscn b/test.tscn index 584d897..e2ef8c5 100644 --- a/test.tscn +++ b/test.tscn @@ -1,22 +1,24 @@ -[gd_scene load_steps=6 format=3 uid="uid://daqqurdrnk61h"] +[gd_scene load_steps=8 format=3 uid="uid://daqqurdrnk61h"] [ext_resource type="Script" uid="uid://bue4xxejdsmqh" path="res://snakeManager.gd" id="1_6uqi0"] [ext_resource type="PackedScene" uid="uid://bwoeu7ask0fck" path="res://prefabs/snake_segment.tscn" id="1_8uh7m"] -[ext_resource type="Texture2D" uid="uid://byibhn8fi6ve0" path="res://assets/bg.png" id="1_ppyta"] +[ext_resource type="Texture2D" uid="uid://b1sese4p8sck3" path="res://assets/smallMap.png" id="1_vbegm"] [ext_resource type="PackedScene" uid="uid://cusdydgg4b1bo" path="res://prefabs/braincell.tscn" id="2_6uqi0"] [ext_resource type="Script" uid="uid://b0djy8fmq4qjq" path="res://camera_2d.gd" id="5_ykrsh"] +[ext_resource type="PackedScene" uid="uid://qpjwodeafyno" path="res://prefabs/apple.tscn" id="6_g14j6"] +[ext_resource type="PackedScene" uid="uid://bl5py87o1qbgr" path="res://prefabs/wall.tscn" id="7_vbegm"] [node name="Node2D" type="Node2D"] [node name="Sprite2D" type="Sprite2D" parent="."] position = Vector2(-160, -160) scale = Vector2(320, 320) -texture = ExtResource("1_ppyta") +texture = ExtResource("1_vbegm") [node name="Snake" type="Node2D" parent="." node_paths=PackedStringArray("segements_holder", "snake_line", "player")] script = ExtResource("1_6uqi0") segements_holder = NodePath("SegementHolder") -SNAKE_SPEED = 0.3 +SNAKE_SPEED = 0.6 snake_line = NodePath("Line2D") player = NodePath("SegementHolder/SnakeSegment/Braincell") @@ -43,7 +45,27 @@ begin_cap_mode = 2 end_cap_mode = 2 [node name="Camera2D" type="Camera2D" parent="." node_paths=PackedStringArray("snake_line", "player")] -zoom = Vector2(0.05, 0.05) +zoom = Vector2(0.1, 0.1) script = ExtResource("5_ykrsh") snake_line = NodePath("../Snake/Line2D") player = NodePath("../Snake/SegementHolder/SnakeSegment/Braincell") + +[node name="Apple" parent="." instance=ExtResource("6_g14j6")] +position = Vector2(1276, -954) + +[node name="Apple2" parent="." instance=ExtResource("6_g14j6")] +position = Vector2(960, 1280) + +[node name="Wall" parent="." instance=ExtResource("7_vbegm")] +position = Vector2(-160, -1920) + +[node name="Wall2" parent="." instance=ExtResource("7_vbegm")] +position = Vector2(-160, 1600) + +[node name="Wall3" parent="." instance=ExtResource("7_vbegm")] +position = Vector2(-1920, -160) +rotation = 1.5708 + +[node name="Wall4" parent="." instance=ExtResource("7_vbegm")] +position = Vector2(1600, -160) +rotation = 1.5708