From 225c912f2b31c2e5931fe5666b65fe33ca9be2c8 Mon Sep 17 00:00:00 2001 From: 2-1-1-2 Date: Sat, 25 Feb 2023 14:02:57 +0100 Subject: [PATCH] WIP: texture changement button --- Assets/skin_assets/VCR_OSD_MONO_1.001.ttf | 3 + Assets/skin_assets/button_focus.png | 3 + Assets/skin_assets/button_focus.png.import | 35 ++++++++++ Assets/skin_assets/button_normal.png | 3 + Assets/skin_assets/button_normal.png.import | 35 ++++++++++ Assets/skin_assets/button_pressed.png | 3 + Assets/skin_assets/button_pressed.png.import | 35 ++++++++++ Assets/tmp.png.import | 0 Assets/tmp1.png.import | 0 Assets/tmp2.png.import | 0 Assets/tmp3.png.import | 0 Assets/tres_button/hover.tres | 11 +++ Assets/tres_button/normal.tres | 11 +++ Assets/tres_button/pressed.tres | 11 +++ Assets/windows.png | 3 + Assets/windows.png.import | 35 ++++++++++ Characters/Player.tscn | 0 Characters/Villain.gd | 8 ++- Characters/Villain.tscn | 0 Scenes/Button_Node2D.gd | 28 ++++++-- Scenes/Node2D.tscn | 27 ++++++-- Scenes/Screen_Menu.gd | 23 +++++++ Scenes/menu.tscn | 71 ++++++++++++++++++++ default_env.tres | 0 icon.png.import | 0 project.godot | 4 +- 26 files changed, 334 insertions(+), 15 deletions(-) create mode 100644 Assets/skin_assets/VCR_OSD_MONO_1.001.ttf create mode 100644 Assets/skin_assets/button_focus.png create mode 100644 Assets/skin_assets/button_focus.png.import create mode 100644 Assets/skin_assets/button_normal.png create mode 100644 Assets/skin_assets/button_normal.png.import create mode 100644 Assets/skin_assets/button_pressed.png create mode 100644 Assets/skin_assets/button_pressed.png.import mode change 100755 => 100644 Assets/tmp.png.import mode change 100755 => 100644 Assets/tmp1.png.import mode change 100755 => 100644 Assets/tmp2.png.import mode change 100755 => 100644 Assets/tmp3.png.import create mode 100644 Assets/tres_button/hover.tres create mode 100644 Assets/tres_button/normal.tres create mode 100644 Assets/tres_button/pressed.tres create mode 100644 Assets/windows.png create mode 100644 Assets/windows.png.import mode change 100755 => 100644 Characters/Player.tscn mode change 100755 => 100644 Characters/Villain.gd mode change 100755 => 100644 Characters/Villain.tscn mode change 100755 => 100644 Scenes/Button_Node2D.gd mode change 100755 => 100644 Scenes/Node2D.tscn create mode 100644 Scenes/Screen_Menu.gd create mode 100644 Scenes/menu.tscn mode change 100755 => 100644 default_env.tres mode change 100755 => 100644 icon.png.import mode change 100755 => 100644 project.godot diff --git a/Assets/skin_assets/VCR_OSD_MONO_1.001.ttf b/Assets/skin_assets/VCR_OSD_MONO_1.001.ttf new file mode 100644 index 0000000..227241f --- /dev/null +++ b/Assets/skin_assets/VCR_OSD_MONO_1.001.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01918d86cb163a715dcb97165b997256734dfcc9f550beeb7c142fa4a064cf1c +size 75864 diff --git a/Assets/skin_assets/button_focus.png b/Assets/skin_assets/button_focus.png new file mode 100644 index 0000000..d213974 --- /dev/null +++ b/Assets/skin_assets/button_focus.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fe98dd8356385014857fa7b0f3f75792fd63bdf6a5e2f8d1942444775aa99b00 +size 219 diff --git a/Assets/skin_assets/button_focus.png.import b/Assets/skin_assets/button_focus.png.import new file mode 100644 index 0000000..e4407cc --- /dev/null +++ b/Assets/skin_assets/button_focus.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/button_focus.png-e1981e994155ca422d4d953f4af77164.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/skin_assets/button_focus.png" +dest_files=[ "res://.import/button_focus.png-e1981e994155ca422d4d953f4af77164.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Assets/skin_assets/button_normal.png b/Assets/skin_assets/button_normal.png new file mode 100644 index 0000000..82123c3 --- /dev/null +++ b/Assets/skin_assets/button_normal.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e29606a5584bcfa57c9546348197ac17867a5022a2afcd0121f4808494bca56c +size 209 diff --git a/Assets/skin_assets/button_normal.png.import b/Assets/skin_assets/button_normal.png.import new file mode 100644 index 0000000..cbb6a2f --- /dev/null +++ b/Assets/skin_assets/button_normal.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/button_normal.png-7ceacf3d6625a4e76f581d0ae1258671.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/skin_assets/button_normal.png" +dest_files=[ "res://.import/button_normal.png-7ceacf3d6625a4e76f581d0ae1258671.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Assets/skin_assets/button_pressed.png b/Assets/skin_assets/button_pressed.png new file mode 100644 index 0000000..63f06f5 --- /dev/null +++ b/Assets/skin_assets/button_pressed.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b8d5641895fa3c2ef6bf7260f845566a151f16561e3c9e17c557480d3fce499 +size 216 diff --git a/Assets/skin_assets/button_pressed.png.import b/Assets/skin_assets/button_pressed.png.import new file mode 100644 index 0000000..845fb8c --- /dev/null +++ b/Assets/skin_assets/button_pressed.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/button_pressed.png-501e49eae0845aa00c0264094791a5b9.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/skin_assets/button_pressed.png" +dest_files=[ "res://.import/button_pressed.png-501e49eae0845aa00c0264094791a5b9.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Assets/tmp.png.import b/Assets/tmp.png.import old mode 100755 new mode 100644 diff --git a/Assets/tmp1.png.import b/Assets/tmp1.png.import old mode 100755 new mode 100644 diff --git a/Assets/tmp2.png.import b/Assets/tmp2.png.import old mode 100755 new mode 100644 diff --git a/Assets/tmp3.png.import b/Assets/tmp3.png.import old mode 100755 new mode 100644 diff --git a/Assets/tres_button/hover.tres b/Assets/tres_button/hover.tres new file mode 100644 index 0000000..92c434d --- /dev/null +++ b/Assets/tres_button/hover.tres @@ -0,0 +1,11 @@ +[gd_resource type="StyleBoxTexture" load_steps=2 format=2] + +[ext_resource path="res://Assets/skin_assets/button_focus.png" type="Texture" id=1] + +[resource] +texture = ExtResource( 1 ) +region_rect = Rect2( 0, 0, 16, 16 ) +margin_left = 10.0 +margin_right = 10.0 +margin_top = 2.0 +margin_bottom = 5.0 diff --git a/Assets/tres_button/normal.tres b/Assets/tres_button/normal.tres new file mode 100644 index 0000000..988d7fc --- /dev/null +++ b/Assets/tres_button/normal.tres @@ -0,0 +1,11 @@ +[gd_resource type="StyleBoxTexture" load_steps=2 format=2] + +[ext_resource path="res://Assets/skin_assets/button_normal.png" type="Texture" id=1] + +[resource] +texture = ExtResource( 1 ) +region_rect = Rect2( 0, 0, 16, 16 ) +margin_left = 10.0 +margin_right = 10.0 +margin_top = 2.0 +margin_bottom = 5.0 diff --git a/Assets/tres_button/pressed.tres b/Assets/tres_button/pressed.tres new file mode 100644 index 0000000..5060202 --- /dev/null +++ b/Assets/tres_button/pressed.tres @@ -0,0 +1,11 @@ +[gd_resource type="StyleBoxTexture" load_steps=2 format=2] + +[ext_resource path="res://Assets/skin_assets/button_pressed.png" type="Texture" id=1] + +[resource] +texture = ExtResource( 1 ) +region_rect = Rect2( 0, 0, 16, 16 ) +margin_left = 10.0 +margin_right = 10.0 +margin_top = 2.0 +margin_bottom = 5.0 diff --git a/Assets/windows.png b/Assets/windows.png new file mode 100644 index 0000000..979e066 --- /dev/null +++ b/Assets/windows.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4b0fedd299f828484743899316a68b4edf9dfb88815fefaff5818f7209b85b26 +size 3966 diff --git a/Assets/windows.png.import b/Assets/windows.png.import new file mode 100644 index 0000000..ec21f03 --- /dev/null +++ b/Assets/windows.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/windows.png-57bc7ca67ed2fd90bf67137af0c36b14.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/windows.png" +dest_files=[ "res://.import/windows.png-57bc7ca67ed2fd90bf67137af0c36b14.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Characters/Player.tscn b/Characters/Player.tscn old mode 100755 new mode 100644 diff --git a/Characters/Villain.gd b/Characters/Villain.gd old mode 100755 new mode 100644 index a3aba37..35a4022 --- a/Characters/Villain.gd +++ b/Characters/Villain.gd @@ -3,11 +3,16 @@ extends Node2D onready var me = $AnimatedSprite onready var timer +var limit_random +var rng = RandomNumberGenerator.new() +onready var button = $"../Button/" # Called when the node enters the scene tree for the first time. func _ready(): timer = 0 + rng.randomize() + limit_random = rng.randi_range(2, 10) # Called every frame. 'delta' is the elapsed time since the previous frame. @@ -16,8 +21,9 @@ func _process(delta): match me.get_frame(): 0: # Vert - if timer >= 5: + if timer >= limit_random: timer = 0 + limit_random = rng.randi_range(2, 10) me.set_frame(1) 1: # Orange diff --git a/Characters/Villain.tscn b/Characters/Villain.tscn old mode 100755 new mode 100644 diff --git a/Scenes/Button_Node2D.gd b/Scenes/Button_Node2D.gd old mode 100755 new mode 100644 index 39befa1..3f5a4e1 --- a/Scenes/Button_Node2D.gd +++ b/Scenes/Button_Node2D.gd @@ -1,21 +1,37 @@ extends Button onready var villain = $"../Villain/AnimatedSprite" +var etat +var _texture1 = load("res://Assets//skin_assets/button_normal.png") +var _texture2 = load("res://Assets//skin_assets/button_pressed.png") # Called when the node enters the scene tree for the first time. func _ready(): + etat = false pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame. -#func _process(delta): +func _process(_delta): + match villain.get_frame(): + 2: + if(etat) : print("non") + else: print("caché") + _: + if(etat) : print("oui") + else: print("caché") # pass func _on_Button_pressed(): - match villain.get_frame(): - 2: - print("non") - _: - print("oui") + etat = !etat + """ + if(etat) : + self.StyleBoxTexture.set_texture(_texture1) # reste appuyé + else : + self.StyleBoxTexture.set_texture(_texture2) # pas appuyé + + """ + """ """ + diff --git a/Scenes/Node2D.tscn b/Scenes/Node2D.tscn old mode 100755 new mode 100644 index 3e6061a..6215424 --- a/Scenes/Node2D.tscn +++ b/Scenes/Node2D.tscn @@ -1,27 +1,42 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=9 format=2] [ext_resource path="res://Characters/Player.tscn" type="PackedScene" id=1] [ext_resource path="res://Characters/Villain.tscn" type="PackedScene" id=2] [ext_resource path="res://Scenes/Button_Node2D.gd" type="Script" id=3] +[ext_resource path="res://Assets/windows.png" type="Texture" id=4] +[ext_resource path="res://Assets/tres_button/hover.tres" type="StyleBox" id=5] +[ext_resource path="res://Assets/tres_button/normal.tres" type="StyleBox" id=6] +[ext_resource path="res://Assets/tres_button/pressed.tres" type="StyleBox" id=7] [sub_resource type="Theme" id=1] [node name="Node2D" type="Node2D"] [node name="Player" parent="." instance=ExtResource( 1 )] +visible = false position = Vector2( 719, 386 ) script = null [node name="Button" type="Button" parent="."] -margin_left = 654.0 -margin_top = 288.0 -margin_right = 784.0 -margin_bottom = 322.0 +margin_left = 462.0 +margin_top = 361.0 +margin_right = 592.0 +margin_bottom = 395.0 theme = SubResource( 1 ) +custom_colors/font_color = Color( 0.27451, 0.207843, 0.207843, 1 ) +custom_styles/hover = ExtResource( 5 ) +custom_styles/pressed = ExtResource( 7 ) +custom_styles/normal = ExtResource( 6 ) text = "CLIQUE MOI" script = ExtResource( 3 ) [node name="Villain" parent="." instance=ExtResource( 2 )] -position = Vector2( 276, 189 ) +position = Vector2( 943, 639 ) + +[node name="Windows" type="Sprite" parent="."] +visible = false +position = Vector2( 512, 358 ) +z_index = -3 +texture = ExtResource( 4 ) [connection signal="pressed" from="Button" to="Button" method="_on_Button_pressed"] diff --git a/Scenes/Screen_Menu.gd b/Scenes/Screen_Menu.gd new file mode 100644 index 0000000..8f0f8a7 --- /dev/null +++ b/Scenes/Screen_Menu.gd @@ -0,0 +1,23 @@ +extends Control + +# 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 _process(delta): +# pass + + +func _on_PlayButton_pressed(): + print("ici") + get_tree().change_scene("res://Scenes/Node2D.tscn") + + +func _on_Help_Button_pressed(): + print("help") + +func _on_Quit_Button_pressed(): + get_tree().quit() + # Replace with function body. diff --git a/Scenes/menu.tscn b/Scenes/menu.tscn new file mode 100644 index 0000000..6e757b4 --- /dev/null +++ b/Scenes/menu.tscn @@ -0,0 +1,71 @@ +[gd_scene load_steps=8 format=2] + +[ext_resource path="res://Assets/windows.png" type="Texture" id=1] +[ext_resource path="res://Assets/skin_assets/VCR_OSD_MONO_1.001.ttf" type="DynamicFontData" id=2] +[ext_resource path="res://Assets/tres_button/hover.tres" type="StyleBox" id=3] +[ext_resource path="res://Assets/tres_button/normal.tres" type="StyleBox" id=4] +[ext_resource path="res://Assets/tres_button/pressed.tres" type="StyleBox" id=5] +[ext_resource path="res://Scenes/Screen_Menu.gd" type="Script" id=6] + +[sub_resource type="DynamicFont" id=1] +size = 34 +outline_color = Color( 0.298039, 0.0745098, 0.0745098, 1 ) +font_data = ExtResource( 2 ) + +[node name="Node2D" type="Node2D"] + +[node name="Windows" type="Sprite" parent="."] +position = Vector2( 512, 360 ) +z_index = -2 +texture = ExtResource( 1 ) + +[node name="MenuButton" type="MenuButton" parent="."] +margin_left = 480.0 +margin_top = 232.0 +margin_right = 584.0 +margin_bottom = 392.0 +script = ExtResource( 6 ) + +[node name="VBoxContainer" type="VBoxContainer" parent="MenuButton"] +margin_left = -24.0 +margin_top = 40.0 +margin_right = 76.0 +margin_bottom = 203.0 +custom_constants/separation = 26 +alignment = 1 + +[node name="PlayButton" type="Button" parent="MenuButton/VBoxContainer"] +margin_right = 100.0 +margin_bottom = 37.0 +custom_colors/font_color = Color( 0.34902, 0.313726, 0.313726, 1 ) +custom_fonts/font = SubResource( 1 ) +custom_styles/hover = ExtResource( 3 ) +custom_styles/pressed = ExtResource( 5 ) +custom_styles/normal = ExtResource( 4 ) +text = "PLAY" + +[node name="Help_Button" type="Button" parent="MenuButton/VBoxContainer"] +margin_top = 63.0 +margin_right = 100.0 +margin_bottom = 100.0 +custom_colors/font_color = Color( 0.34902, 0.313726, 0.313726, 1 ) +custom_fonts/font = SubResource( 1 ) +custom_styles/hover = ExtResource( 3 ) +custom_styles/pressed = ExtResource( 5 ) +custom_styles/normal = ExtResource( 4 ) +text = "HELP" + +[node name="Quit_Button" type="Button" parent="MenuButton/VBoxContainer"] +margin_top = 126.0 +margin_right = 100.0 +margin_bottom = 163.0 +custom_colors/font_color = Color( 0.34902, 0.313726, 0.313726, 1 ) +custom_fonts/font = SubResource( 1 ) +custom_styles/hover = ExtResource( 3 ) +custom_styles/pressed = ExtResource( 5 ) +custom_styles/normal = ExtResource( 4 ) +text = "QUIT" + +[connection signal="pressed" from="MenuButton/VBoxContainer/PlayButton" to="MenuButton" method="_on_PlayButton_pressed"] +[connection signal="pressed" from="MenuButton/VBoxContainer/Help_Button" to="MenuButton" method="_on_Help_Button_pressed"] +[connection signal="pressed" from="MenuButton/VBoxContainer/Quit_Button" to="MenuButton" method="_on_Quit_Button_pressed"] diff --git a/default_env.tres b/default_env.tres old mode 100755 new mode 100644 diff --git a/icon.png.import b/icon.png.import old mode 100755 new mode 100644 diff --git a/project.godot b/project.godot old mode 100755 new mode 100644 index bfe0bdc..1a60482 --- a/project.godot +++ b/project.godot @@ -11,13 +11,13 @@ config_version=4 [application] config/name="Gja" -run/main_scene="res://Scenes/Node2D.tscn" +run/main_scene="res://Scenes/menu.tscn" config/icon="res://icon.png" [display] +window/size/height=720 window/size/resizable=false -window/size/fullscreen=true [gui]