From bbf3c5e5933cd5508ddc77e1404bf7493910c6e7 Mon Sep 17 00:00:00 2001 From: dukantic Date: Sat, 19 Oct 2024 19:19:46 +0200 Subject: [PATCH] plein --- .../DiabeteMeter1.png.import | 8 +- model/DiabeteMeter2.png.import | 34 ++++++++ model/Trick or treatBG.png.import | 34 ++++++++ scene/control/door_view.tscn | 15 ++-- scene/player.tscn | 25 +++++- scene/principal.tscn | 75 ++++++++++++++++++ script/DoorView.cs | 23 ++++++ script/Player.cs | 18 ++++- script/Principal.cs | 24 ++++++ sound/back_menu2.png | Bin 2796 -> 0 bytes sound/{IMG_8891.mp3 => toc.mp3} | Bin sound/toc.mp3.import | 19 +++++ 12 files changed, 262 insertions(+), 13 deletions(-) rename sound/back_menu2.png.import => model/DiabeteMeter1.png.import (68%) create mode 100644 model/DiabeteMeter2.png.import create mode 100644 model/Trick or treatBG.png.import create mode 100644 scene/principal.tscn create mode 100644 script/Principal.cs delete mode 100644 sound/back_menu2.png rename sound/{IMG_8891.mp3 => toc.mp3} (100%) create mode 100644 sound/toc.mp3.import diff --git a/sound/back_menu2.png.import b/model/DiabeteMeter1.png.import similarity index 68% rename from sound/back_menu2.png.import rename to model/DiabeteMeter1.png.import index 1b06e9d..554d234 100644 --- a/sound/back_menu2.png.import +++ b/model/DiabeteMeter1.png.import @@ -2,16 +2,16 @@ importer="texture" type="CompressedTexture2D" -uid="uid://c5luwi0ekq5he" -path="res://.godot/imported/back_menu2.png-ce7974e2e9793729e43fcf095529a482.ctex" +uid="uid://dxepey1fkkhhv" +path="res://.godot/imported/DiabeteMeter1.png-d0b47e401aa5e0df595b747218e9ba7f.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://sound/back_menu2.png" -dest_files=["res://.godot/imported/back_menu2.png-ce7974e2e9793729e43fcf095529a482.ctex"] +source_file="res://model/DiabeteMeter1.png" +dest_files=["res://.godot/imported/DiabeteMeter1.png-d0b47e401aa5e0df595b747218e9ba7f.ctex"] [params] diff --git a/model/DiabeteMeter2.png.import b/model/DiabeteMeter2.png.import new file mode 100644 index 0000000..9f77e83 --- /dev/null +++ b/model/DiabeteMeter2.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dqqegt7a6ng06" +path="res://.godot/imported/DiabeteMeter2.png-86d1f7a94d1ff2f1fe83ab0f70468d1b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://model/DiabeteMeter2.png" +dest_files=["res://.godot/imported/DiabeteMeter2.png-86d1f7a94d1ff2f1fe83ab0f70468d1b.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=0 diff --git a/model/Trick or treatBG.png.import b/model/Trick or treatBG.png.import new file mode 100644 index 0000000..36588be --- /dev/null +++ b/model/Trick or treatBG.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://mr6hi8icwyle" +path="res://.godot/imported/Trick or treatBG.png-76b8ac899f979f8367c2279bdce07535.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://model/Trick or treatBG.png" +dest_files=["res://.godot/imported/Trick or treatBG.png-76b8ac899f979f8367c2279bdce07535.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/scene/control/door_view.tscn b/scene/control/door_view.tscn index edb5f18..8333efe 100644 --- a/scene/control/door_view.tscn +++ b/scene/control/door_view.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=33 format=3 uid="uid://bq2yxcm55h7n8"] +[gd_scene load_steps=34 format=3 uid="uid://bq2yxcm55h7n8"] [ext_resource type="Script" path="res://script/DoorView.cs" id="1_nmul8"] [ext_resource type="Texture2D" uid="uid://dpqc1xv3cechw" path="res://model/House1Closed.jpg" id="1_suqi6"] @@ -26,6 +26,7 @@ [ext_resource type="Texture2D" uid="uid://drvspvx3dpe8u" path="res://model/frame_18_delay-0.1s.png" id="22_atju4"] [ext_resource type="Texture2D" uid="uid://cggbun65n8uo6" path="res://model/frame_19_delay-0.1s.png" id="23_l4jpt"] [ext_resource type="Texture2D" uid="uid://ob3tlldg8ta" path="res://model/frame_20_delay-0.1s.png" id="24_tjfip"] +[ext_resource type="AudioStream" uid="uid://blgk5pv3ydewn" path="res://sound/toc.mp3" id="26_7kpao"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_jooqt"] @@ -310,8 +311,8 @@ script = ExtResource("1_nmul8") mob = NodePath("Panel/mob") anim = NodePath("AnimationPlayer") text_mob = NodePath("Question/Label") -butA = NodePath("Question/Button") -butB = NodePath("Question/Button2") +butA = NodePath("Question/a") +butB = NodePath("Question/b") [node name="Panel" type="Panel" parent="."] layout_mode = 1 @@ -343,6 +344,7 @@ libraries = { } [node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] +stream = ExtResource("26_7kpao") [node name="Trick" type="VBoxContainer" parent="."] visible = false @@ -398,14 +400,14 @@ theme_override_font_sizes/font_size = 18 text = "Trick or treat salut a tous les amis moi c'est davide la farge pokemon" autowrap_mode = 2 -[node name="Button" type="Button" parent="Question"] +[node name="a" type="Button" parent="Question"] custom_minimum_size = Vector2(128.58, 0) layout_mode = 2 theme = ExtResource("5_50q8s") theme_override_font_sizes/font_size = 18 text = "Trick" -[node name="Button2" type="Button" parent="Question"] +[node name="b" type="Button" parent="Question"] layout_mode = 2 theme = ExtResource("5_50q8s") theme_override_font_sizes/font_size = 18 @@ -413,4 +415,5 @@ text = "Treat " [connection signal="pressed" from="Trick/Button2" to="." method="TreatPressed"] -[connection signal="pressed" from="Question/Button2" to="." method="TreatPressed"] +[connection signal="pressed" from="Question/a" to="." method="APressed"] +[connection signal="pressed" from="Question/b" to="." method="BPressed"] diff --git a/scene/player.tscn b/scene/player.tscn index a7315db..eb56e47 100644 --- a/scene/player.tscn +++ b/scene/player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=31 format=3 uid="uid://4ubk6w44h4s2"] +[gd_scene load_steps=33 format=3 uid="uid://4ubk6w44h4s2"] [ext_resource type="Script" path="res://script/Player.cs" id="1_gmlsd"] [ext_resource type="Texture2D" uid="uid://bo4q2rvn056p3" path="res://model/PatrickIdle1.png" id="2_w2lj6"] @@ -12,7 +12,9 @@ [ext_resource type="Texture2D" uid="uid://bu5nnr2x4co38" path="res://model/PatrickLeft2.png" id="6_jii6b"] [ext_resource type="Texture2D" uid="uid://doavv8drnetm" path="res://model/PatrickRight1.png" id="7_xptin"] [ext_resource type="Texture2D" uid="uid://dbey2oeyhxsq8" path="res://model/PatrickRight2.png" id="8_m32jm"] +[ext_resource type="Texture2D" uid="uid://dxepey1fkkhhv" path="res://model/DiabeteMeter1.png" id="9_0ohl3"] [ext_resource type="Texture2D" uid="uid://c0oqqh7qgohu" path="res://model/PatrickBack1.png" id="9_y1wtp"] +[ext_resource type="Texture2D" uid="uid://dqqegt7a6ng06" path="res://model/DiabeteMeter2.png" id="10_ete3q"] [ext_resource type="Texture2D" uid="uid://dgs1topxer4a8" path="res://model/PatrickBack2.png" id="10_rvawd"] [ext_resource type="Texture2D" uid="uid://cisefnb0eej45" path="res://model/Patrickfront1.png" id="11_wpam5"] [ext_resource type="Texture2D" uid="uid://bex6put0xmadj" path="res://model/Patrickfront2.png" id="12_t0eem"] @@ -354,13 +356,15 @@ _data = { "up": SubResource("Animation_7twwg") } -[node name="CharacterBody2D" type="CharacterBody2D" node_paths=PackedStringArray("anim", "cam", "menu")] +[node name="CharacterBody2D" type="CharacterBody2D" node_paths=PackedStringArray("anim", "cam", "bar", "menu")] position = Vector2(1, 1) motion_mode = 1 script = ExtResource("1_gmlsd") Speed = 6000.0 +sugar_speed = 2.0 anim = NodePath("anim") cam = NodePath("Camera2D") +bar = NodePath("diabetmeter") menu = NodePath("Camera2D/menu") [node name="CollisionShape2D" type="CollisionShape2D" parent="."] @@ -371,6 +375,23 @@ shape = SubResource("RectangleShape2D_2homw") position = Vector2(2, 1) texture = ExtResource("2_w2lj6") +[node name="diabetmeter" type="TextureProgressBar" parent="."] +texture_filter = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = 162.0 +offset_top = -121.0 +offset_right = 192.0 +offset_bottom = 129.0 +grow_horizontal = 2 +grow_vertical = 2 +step = 0.01 +value = 50.0 +fill_mode = 3 +texture_under = ExtResource("9_0ohl3") +texture_progress = ExtResource("10_ete3q") + [node name="Camera2D" type="Camera2D" parent="."] process_mode = 3 limit_smoothed = true diff --git a/scene/principal.tscn b/scene/principal.tscn new file mode 100644 index 0000000..41020f0 --- /dev/null +++ b/scene/principal.tscn @@ -0,0 +1,75 @@ +[gd_scene load_steps=6 format=3 uid="uid://cru3yl7laeiem"] + +[ext_resource type="Texture2D" uid="uid://mr6hi8icwyle" path="res://model/Trick or treatBG.png" id="1_4oira"] +[ext_resource type="Script" path="res://script/Principal.cs" id="1_5hpqm"] +[ext_resource type="Theme" uid="uid://depo4fa5p8k8m" path="res://themes/button.tres" id="2_ab0tu"] +[ext_resource type="PackedScene" uid="uid://1tfopbwug3ht" path="res://scene/city.tscn" id="2_qp7s0"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_qdt6c"] +bg_color = Color(0, 0, 0, 0.792157) + +[node name="Principal" type="Control" node_paths=PackedStringArray("sub")] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_5hpqm") +sub = NodePath("sub") +play = ExtResource("2_qp7s0") + +[node name="TrickOrTreatBg" type="Sprite2D" parent="."] +texture = ExtResource("1_4oira") +centered = false + +[node name="Enter" type="Button" parent="."] +layout_mode = 0 +offset_left = 24.0 +offset_top = 238.0 +offset_right = 121.0 +offset_bottom = 290.0 +theme = ExtResource("2_ab0tu") +theme_override_font_sizes/font_size = 42 +text = "Enter" + +[node name="sub" type="Panel" parent="."] +visible = false +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_qdt6c") + +[node name="Play" type="Button" parent="sub"] +layout_mode = 0 +offset_left = 284.0 +offset_top = 53.0 +offset_right = 343.0 +offset_bottom = 91.0 +theme = ExtResource("2_ab0tu") +text = "Play +" + +[node name="Credits" type="Button" parent="sub"] +layout_mode = 0 +offset_left = 247.0 +offset_top = 149.0 +offset_right = 338.0 +offset_bottom = 187.0 +theme = ExtResource("2_ab0tu") +text = "Credits" + +[node name="Exit" type="Button" parent="sub"] +layout_mode = 0 +offset_left = 181.0 +offset_top = 230.0 +offset_right = 233.0 +offset_bottom = 268.0 +theme = ExtResource("2_ab0tu") +text = "Exit +" + +[connection signal="pressed" from="Enter" to="." method="EnterPressed"] diff --git a/script/DoorView.cs b/script/DoorView.cs index 8388548..4bc1784 100644 --- a/script/DoorView.cs +++ b/script/DoorView.cs @@ -13,11 +13,17 @@ public partial class DoorView : Control string answerA{get; set;} string answerB{get; set;} bool answerA_good {get; set;} + CharacterBody2D player; [Export] Label text_mob; [Export] Button butA; [Export] Button butB; // Called when the node enters the scene tree for the first time. + + public override void _Ready() + { + player = (CharacterBody2D)GetParent().GetParent(); + } public void start() { GetParent().PositionSmoothingEnabled = false; @@ -43,4 +49,21 @@ public partial class DoorView : Control butB.Text = answerB; } + public void APressed() + { + if(answerA_good) + { + player.Set("sugar", (int)player.Get("sugar") + GD.RandRange(20, 40)); + } + stop(); + } + + public void BPressed() + { + if(!answerA_good) + { + player.Set("sugar", (int)player.Get("sugar") + GD.RandRange(20, 40)); + } + stop(); + } } diff --git a/script/Player.cs b/script/Player.cs index 0ff8920..bca57f1 100644 --- a/script/Player.cs +++ b/script/Player.cs @@ -4,19 +4,35 @@ using System; public partial class Player : CharacterBody2D { [Export] float Speed; + [Export] float sugar_speed; [Export] AnimationPlayer anim; [Export] Camera2D cam; - + [Export] TextureProgressBar bar; [ExportGroup("controls")] [Export] Control menu; + public float PixelSize = 1.0f; + float sugar { get; set;}= 50; + const float MAX_SUGAR = 100; + public override void _PhysicsProcess(double delta) { Vector2 velocity = Velocity; + sugar -= (float)delta / sugar_speed; + bar.Value = sugar; + + if(sugar <= 0) + { + + } + else if (sugar >= 100) + { + + } Vector2 direction = Input.GetVector("left", "right", "up", "down"); diff --git a/script/Principal.cs b/script/Principal.cs new file mode 100644 index 0000000..9e29199 --- /dev/null +++ b/script/Principal.cs @@ -0,0 +1,24 @@ +using Godot; +using System; + +public partial class Principal : Control +{ + [Export] Panel sub; + [Export] PackedScene play; + [Export] PackedScene credit; + // Called when the node enters the scene tree for the first time. + public override void _Ready() + { + + } + + // Called every frame. 'delta' is the elapsed time since the previous frame. + public override void _Process(double delta) + { + } + + public void EnterPressed() + { + sub.Visible = true; + } +} diff --git a/sound/back_menu2.png b/sound/back_menu2.png deleted file mode 100644 index 82b1ecfbef193d496c318d4069e53a2d68d1dcd6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2796 zcmeAS@N?(olHy`uVBq!ia0y~yV4MKNIvi|3k+<8Q9s*LF1s;*b3=De8Ak0{?)V_>? zfoqo`vNI8wXHGfs?}{sn`W% z1XB_-3s7hR3yaD|OC^x0j2l6E1w5FTCf$$`1nO^SxB=43p~A@MnbQZ-@8FOF(#tZb zp+UvW9i(4D!3^voPX`B~*~%dO0s_*b&KV7z(X=y~vqsCE(NcM|k{GQ*M;jQ!p!s!x Z-*y%Y(^iT2=fLJGgQu&X%Q~loCIBCvL3IEC diff --git a/sound/IMG_8891.mp3 b/sound/toc.mp3 similarity index 100% rename from sound/IMG_8891.mp3 rename to sound/toc.mp3 diff --git a/sound/toc.mp3.import b/sound/toc.mp3.import new file mode 100644 index 0000000..64b897d --- /dev/null +++ b/sound/toc.mp3.import @@ -0,0 +1,19 @@ +[remap] + +importer="mp3" +type="AudioStreamMP3" +uid="uid://blgk5pv3ydewn" +path="res://.godot/imported/toc.mp3-2735aa5520ec9e4f3f689c5400a40c21.mp3str" + +[deps] + +source_file="res://sound/toc.mp3" +dest_files=["res://.godot/imported/toc.mp3-2735aa5520ec9e4f3f689c5400a40c21.mp3str"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4