diff --git a/apple_furnace_man.gd b/apple_furnace_man.gd index ec560b5..3790f2c 100644 --- a/apple_furnace_man.gd +++ b/apple_furnace_man.gd @@ -4,6 +4,7 @@ extends Node2D @export var count : Label @export var my_area : Area2D @export var brain : Node2D +@export var furnace_sprite : AnimatedSprite2D var player_detected : bool # Called when the node enters the scene tree for the first time. @@ -20,10 +21,14 @@ func _process(delta: float) -> void: if overlaps.is_in_group("braincell"): player_detected = true if player_detected: - modulate = Color.GREEN + modulate = Color (2,2,2) else: modulate = Color.WHITE - + + if snake_man.burn_apples > 0: + furnace_sprite.play("on") + else: + furnace_sprite.play("off") #print(str(player_detected) + " "+ str(snake_man.pit_apples) +" " +str(brain.holding_apple)) if player_detected and brain.holding_apple: diff --git a/apple_pit_man.gd b/apple_pit_man.gd index 10a3f1a..c46483e 100644 --- a/apple_pit_man.gd +++ b/apple_pit_man.gd @@ -4,6 +4,7 @@ extends Node2D @export var count : Label @export var my_area : Area2D @export var brain : Node2D +@export var pit_sprite : AnimatedSprite2D var player_detected : bool # Called when the node enters the scene tree for the first time. @@ -20,10 +21,13 @@ func _process(delta: float) -> void: if overlaps.is_in_group("braincell"): player_detected = true if player_detected: - modulate = Color.GREEN + modulate = Color (2,2,2) else: modulate = Color.WHITE - + if(snake_man.pit_apples <= 19): + pit_sprite.frame = snake_man.pit_apples + else: + pit_sprite.frame = 19 #print(str(player_detected) + " "+ str(snake_man.pit_apples) +" " +str(brain.holding_apple)) if player_detected and snake_man.pit_apples > 0 and not brain.holding_apple: diff --git a/assets/apple.png b/assets/apple.png index 64335a3..cade3c9 100644 Binary files a/assets/apple.png and b/assets/apple.png differ diff --git a/assets/apple.pxo b/assets/apple.pxo new file mode 100644 index 0000000..27a2a15 Binary files /dev/null and b/assets/apple.pxo differ diff --git a/assets/applePit.png b/assets/applePit.png new file mode 100644 index 0000000..001f893 Binary files /dev/null and b/assets/applePit.png differ diff --git a/assets/applePit.png.import b/assets/applePit.png.import new file mode 100644 index 0000000..de0ef63 --- /dev/null +++ b/assets/applePit.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://d1qnbjrs54epd" +path="res://.godot/imported/applePit.png-6d0ecf530f75a8e2e2106794487af091.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/applePit.png" +dest_files=["res://.godot/imported/applePit.png-6d0ecf530f75a8e2e2106794487af091.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/applePit.pxo b/assets/applePit.pxo new file mode 100644 index 0000000..3870722 Binary files /dev/null and b/assets/applePit.pxo differ diff --git a/assets/furnace.png b/assets/furnace.png new file mode 100644 index 0000000..416fb2c Binary files /dev/null and b/assets/furnace.png differ diff --git a/assets/furnace.png.import b/assets/furnace.png.import new file mode 100644 index 0000000..e6101ef --- /dev/null +++ b/assets/furnace.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dfsa7lnulqunr" +path="res://.godot/imported/furnace.png-54ddd48ded36677a685e662fa9ee9fdc.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/furnace.png" +dest_files=["res://.godot/imported/furnace.png-54ddd48ded36677a685e662fa9ee9fdc.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/furnace.pxo b/assets/furnace.pxo new file mode 100644 index 0000000..4b978cf Binary files /dev/null and b/assets/furnace.pxo differ diff --git a/project.godot b/project.godot index c5cbbc8..a668453 100644 --- a/project.godot +++ b/project.godot @@ -66,6 +66,7 @@ down={ test_switch_cam={ "deadzone": 0.2, "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":4194309,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, 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":88,"key_label":0,"unicode":120,"location":0,"echo":false,"script":null) ] } test_add_segment={ @@ -76,6 +77,7 @@ test_add_segment={ action={ "deadzone": 0.2, "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,"location":0,"echo":false,"script":null) +, 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":90,"key_label":0,"unicode":122,"location":0,"echo":false,"script":null) ] } diff --git a/scenes/menu.gd b/scenes/menu.gd index f141007..53686a4 100644 --- a/scenes/menu.gd +++ b/scenes/menu.gd @@ -12,4 +12,5 @@ func _process(delta: float) -> void: func _on_play_button_pressed() -> void: + Router.player_mode = false get_tree().change_scene_to_file("res://test.tscn") diff --git a/scenes/menu.tscn b/scenes/menu.tscn index e36ca83..4afcaf9 100644 --- a/scenes/menu.tscn +++ b/scenes/menu.tscn @@ -62,8 +62,8 @@ layout_mode = 2 layout_mode = 2 size_flags_vertical = 3 bbcode_enabled = true -text = "You are a snake, or rather, you are it's sincle braincell. press [color=green]Enter[/color] to switch between [i]controlling the snake[/i] and [i]controlling the braincell[/i]. -In snake form, Use the [color=green]Arrow Keys[/color] to direct the snake into apples. Then in braincell view, use the [color=green]Space[/color] key to pickup collected apples and put them in the [i]furnace[/i] - this will replenish your food, if you run of food you die!" +text = "You are a snake, or rather, you are it's sincle braincell. press [color=green]X[/color] to switch between [i]controlling the snake[/i] and [i]controlling the braincell[/i]. +In snake form, Use the [color=green]Arrow Keys[/color] to direct the snake into apples. Then in braincell view, use the [color=green]Z[/color] key to pickup collected apples and put them in the [i]furnace[/i] - this will replenish your food, if you run of food you die!" fit_content = true [node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer/PanelContainer/VBoxContainer"] @@ -82,7 +82,7 @@ size_flags_horizontal = 3 size_flags_vertical = 8 text = "Play" -[node name="Label" type="Label" parent="."] +[node name="version" type="Label" parent="."] layout_mode = 1 anchors_preset = 3 anchor_left = 1.0 @@ -93,6 +93,6 @@ offset_left = -40.0 offset_top = -23.0 grow_horizontal = 0 grow_vertical = 0 -text = "V 0.2" +text = "V 0.3" [connection signal="pressed" from="MarginContainer/VBoxContainer/PanelContainer/VBoxContainer/HBoxContainer/PlayButton" to="." method="_on_play_button_pressed"] diff --git a/test.tscn b/test.tscn index 9faaf42..3800f78 100644 --- a/test.tscn +++ b/test.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=20 format=3 uid="uid://daqqurdrnk61h"] +[gd_scene load_steps=50 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"] @@ -8,10 +8,159 @@ [ext_resource type="Script" uid="uid://b0djy8fmq4qjq" path="res://camera_2d.gd" id="5_ykrsh"] [ext_resource type="Script" uid="uid://btw5oi52pxy7d" path="res://apple_pit_man.gd" id="6_77dp3"] [ext_resource type="PackedScene" uid="uid://qpjwodeafyno" path="res://prefabs/apple.tscn" id="6_g14j6"] +[ext_resource type="Texture2D" uid="uid://d1qnbjrs54epd" path="res://assets/applePit.png" id="7_0m0f1"] [ext_resource type="PackedScene" uid="uid://bl5py87o1qbgr" path="res://prefabs/wall.tscn" id="7_vbegm"] [ext_resource type="Script" uid="uid://dib0u5gw356nv" path="res://apple_furnace_man.gd" id="8_5tkv4"] +[ext_resource type="Texture2D" uid="uid://dfsa7lnulqunr" path="res://assets/furnace.png" id="9_0m0f1"] [ext_resource type="Script" uid="uid://cpav6iuq2hrns" path="res://uiman.gd" id="9_xersf"] -[ext_resource type="Texture2D" uid="uid://dyxnlko6tpmui" path="res://icon.svg" id="11_77dp3"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_b0q6j"] +atlas = ExtResource("7_0m0f1") +region = Rect2(0, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_mhym6"] +atlas = ExtResource("7_0m0f1") +region = Rect2(128, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_a3se8"] +atlas = ExtResource("7_0m0f1") +region = Rect2(256, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_uty7l"] +atlas = ExtResource("7_0m0f1") +region = Rect2(384, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_45l4g"] +atlas = ExtResource("7_0m0f1") +region = Rect2(512, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_4uo0j"] +atlas = ExtResource("7_0m0f1") +region = Rect2(0, 128, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_vxl6d"] +atlas = ExtResource("7_0m0f1") +region = Rect2(128, 128, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_eski5"] +atlas = ExtResource("7_0m0f1") +region = Rect2(256, 128, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_pdf00"] +atlas = ExtResource("7_0m0f1") +region = Rect2(384, 128, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_a6gra"] +atlas = ExtResource("7_0m0f1") +region = Rect2(512, 128, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_dwqlq"] +atlas = ExtResource("7_0m0f1") +region = Rect2(0, 256, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_15c7i"] +atlas = ExtResource("7_0m0f1") +region = Rect2(128, 256, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_xpeyw"] +atlas = ExtResource("7_0m0f1") +region = Rect2(256, 256, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_dpmuy"] +atlas = ExtResource("7_0m0f1") +region = Rect2(384, 256, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_yww54"] +atlas = ExtResource("7_0m0f1") +region = Rect2(512, 256, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_j75vh"] +atlas = ExtResource("7_0m0f1") +region = Rect2(0, 384, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_rrpoi"] +atlas = ExtResource("7_0m0f1") +region = Rect2(128, 384, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_34fux"] +atlas = ExtResource("7_0m0f1") +region = Rect2(256, 384, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ppv7d"] +atlas = ExtResource("7_0m0f1") +region = Rect2(384, 384, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_naet1"] +atlas = ExtResource("7_0m0f1") +region = Rect2(512, 384, 128, 128) + +[sub_resource type="SpriteFrames" id="SpriteFrames_6qlrc"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_b0q6j") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_mhym6") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_a3se8") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_uty7l") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_45l4g") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_4uo0j") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_vxl6d") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_eski5") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_pdf00") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_a6gra") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_dwqlq") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_15c7i") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_xpeyw") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_dpmuy") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_yww54") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_j75vh") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_rrpoi") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_34fux") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ppv7d") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_naet1") +}], +"loop": false, +"name": &"default", +"speed": 5.0 +}] [sub_resource type="LabelSettings" id="LabelSettings_00tp4"] font_size = 36 @@ -22,6 +171,61 @@ outline_color = Color(1, 0.478431, 1, 1) [sub_resource type="CircleShape2D" id="CircleShape2D_00tp4"] radius = 64.0 +[sub_resource type="AtlasTexture" id="AtlasTexture_6qlrc"] +atlas = ExtResource("9_0m0f1") +region = Rect2(0, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_shobf"] +atlas = ExtResource("9_0m0f1") +region = Rect2(128, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_lb1cv"] +atlas = ExtResource("9_0m0f1") +region = Rect2(256, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_2h37t"] +atlas = ExtResource("9_0m0f1") +region = Rect2(384, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_adp8l"] +atlas = ExtResource("9_0m0f1") +region = Rect2(512, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_dvnpp"] +atlas = ExtResource("9_0m0f1") +region = Rect2(0, 128, 128, 128) + +[sub_resource type="SpriteFrames" id="SpriteFrames_ffwl0"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_6qlrc") +}], +"loop": false, +"name": &"off", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_shobf") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_lb1cv") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_2h37t") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_adp8l") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_dvnpp") +}], +"loop": true, +"name": &"on", +"speed": 6.0 +}] + [sub_resource type="CircleShape2D" id="CircleShape2D_77dp3"] radius = 64.0 @@ -31,6 +235,9 @@ font_color = Color(1, 0.490271, 0.0740941, 1) outline_size = 8 outline_color = Color(0.87451, 0, 0, 1) +[sub_resource type="Gradient" id="Gradient_0m0f1"] +colors = PackedColorArray(0, 0.662745, 0, 1, 0, 0.428325, 0.224898, 1) + [sub_resource type="CircleShape2D" id="CircleShape2D_ehkex"] radius = 50.0 @@ -66,15 +273,16 @@ is_head = true [node name="Braincell" parent="Snake/SegementHolder/SnakeSegment" instance=ExtResource("2_6uqi0")] -[node name="ApplePit" type="Node2D" parent="Snake/SegementHolder/SnakeSegment" node_paths=PackedStringArray("snake_man", "count", "my_area", "brain")] +[node name="ApplePit" type="Node2D" parent="Snake/SegementHolder/SnakeSegment" node_paths=PackedStringArray("snake_man", "count", "my_area", "brain", "pit_sprite")] script = ExtResource("6_77dp3") snake_man = NodePath("../../..") count = NodePath("Label") my_area = NodePath("Area2D") brain = NodePath("../Braincell") +pit_sprite = NodePath("Sprite2D") -[node name="Sprite2D" type="Sprite2D" parent="Snake/SegementHolder/SnakeSegment/ApplePit"] -texture = ExtResource("11_77dp3") +[node name="Sprite2D" type="AnimatedSprite2D" parent="Snake/SegementHolder/SnakeSegment/ApplePit"] +sprite_frames = SubResource("SpriteFrames_6qlrc") [node name="Label" type="Label" parent="Snake/SegementHolder/SnakeSegment/ApplePit"] offset_left = -80.0 @@ -96,15 +304,19 @@ position = Vector2(-320, 0) next_segment = NodePath("../SnakeSegment") door_disabled = true -[node name="AppleFurnace" type="Node2D" parent="Snake/SegementHolder/SnakeSegment2" node_paths=PackedStringArray("snake_man", "count", "my_area", "brain")] +[node name="AppleFurnace" type="Node2D" parent="Snake/SegementHolder/SnakeSegment2" node_paths=PackedStringArray("snake_man", "count", "my_area", "brain", "furnace_sprite")] script = ExtResource("8_5tkv4") snake_man = NodePath("../../..") count = NodePath("Label2") my_area = NodePath("Area2D") brain = NodePath("../../SnakeSegment/Braincell") +furnace_sprite = NodePath("Sprite2D") -[node name="Sprite2D" type="Sprite2D" parent="Snake/SegementHolder/SnakeSegment2/AppleFurnace"] -texture = ExtResource("11_77dp3") +[node name="Sprite2D" type="AnimatedSprite2D" parent="Snake/SegementHolder/SnakeSegment2/AppleFurnace"] +sprite_frames = SubResource("SpriteFrames_ffwl0") +animation = &"off" +autoplay = "off" +frame_progress = 1.0 [node name="Area2D" type="Area2D" parent="Snake/SegementHolder/SnakeSegment2/AppleFurnace"] @@ -127,8 +339,9 @@ next_segment = NodePath("../SnakeSegment2") door_disabled = true [node name="Line2D" type="Line2D" parent="Snake"] -width = 320.0 +width = 330.0 default_color = Color(0, 0.662728, 1.54018e-06, 1) +gradient = SubResource("Gradient_0m0f1") joint_mode = 2 begin_cap_mode = 2 end_cap_mode = 2 diff --git a/uiman.gd b/uiman.gd index e6eccd4..e3ee454 100644 --- a/uiman.gd +++ b/uiman.gd @@ -25,6 +25,12 @@ func _process(delta: float) -> void: else: speed_label.text = str(round(snake_manager.max_snake_speed*100)/100) + " MAX" speed_label.label_settings.font_color = Color.RED + if snake_manager.burn_apples > 0: + food_bar.modulate = Color.GREEN + elif food_bar.value < food_bar.max_value*0.3: + food_bar.modulate = Color.RED + else: + food_bar.modulate = Color.WHITE func show_gameover(): gameover_screen.show() @@ -32,9 +38,11 @@ func show_gameover(): func _on_again_button_pressed() -> void: get_tree().get_root().process_mode = Node.PROCESS_MODE_ALWAYS + Router.player_mode = false get_tree().change_scene_to_file("res://test.tscn") func _on_menu_button_pressed() -> void: get_tree().get_root().process_mode = Node.PROCESS_MODE_ALWAYS + Router.player_mode = false get_tree().change_scene_to_file("res://scenes/menu.tscn")