diff --git a/Assets/oeil/0.png b/Assets/oeil/0.png new file mode 100755 index 0000000..69e474d --- /dev/null +++ b/Assets/oeil/0.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5844ebae04aca81653560a1ad3842e7e661ed52b154d37317bb5fd944e023fa4 +size 97959 diff --git a/Assets/tmp3.png.import b/Assets/oeil/0.png.import old mode 100644 new mode 100755 similarity index 73% rename from Assets/tmp3.png.import rename to Assets/oeil/0.png.import index a464c81..7312b2d --- a/Assets/tmp3.png.import +++ b/Assets/oeil/0.png.import @@ -2,15 +2,15 @@ importer="texture" type="StreamTexture" -path="res://.import/tmp3.png-0afe8b1e9c47be51c701b0d537c4b45a.stex" +path="res://.import/0.png-aab8ea6436f77d0de8234ee1e907b33c.stex" metadata={ "vram_texture": false } [deps] -source_file="res://Assets/tmp3.png" -dest_files=[ "res://.import/tmp3.png-0afe8b1e9c47be51c701b0d537c4b45a.stex" ] +source_file="res://Assets/oeil/0.png" +dest_files=[ "res://.import/0.png-aab8ea6436f77d0de8234ee1e907b33c.stex" ] [params] diff --git a/Assets/oeil/1.png b/Assets/oeil/1.png new file mode 100755 index 0000000..7ec9c58 --- /dev/null +++ b/Assets/oeil/1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:99503df9e53b6e6ee0b8323ab308bed1478075477fcf61ea96ada3c57aee1807 +size 96121 diff --git a/Assets/tmp1.png.import b/Assets/oeil/1.png.import old mode 100644 new mode 100755 similarity index 73% rename from Assets/tmp1.png.import rename to Assets/oeil/1.png.import index 8a1639a..0d285da --- a/Assets/tmp1.png.import +++ b/Assets/oeil/1.png.import @@ -2,15 +2,15 @@ importer="texture" type="StreamTexture" -path="res://.import/tmp1.png-0c1a3d9d3390acb57bea785b3f9e30f7.stex" +path="res://.import/1.png-988e44760c0ae733dcaea4b5bcfb6fb8.stex" metadata={ "vram_texture": false } [deps] -source_file="res://Assets/tmp1.png" -dest_files=[ "res://.import/tmp1.png-0c1a3d9d3390acb57bea785b3f9e30f7.stex" ] +source_file="res://Assets/oeil/1.png" +dest_files=[ "res://.import/1.png-988e44760c0ae733dcaea4b5bcfb6fb8.stex" ] [params] diff --git a/Assets/oeil/2.png b/Assets/oeil/2.png new file mode 100755 index 0000000..fd6904b --- /dev/null +++ b/Assets/oeil/2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:981cc069ee78f2192113f3397b798c277a1058ee4e8eb27d9e1ee7caec61282b +size 96615 diff --git a/Assets/tmp2.png.import b/Assets/oeil/2.png.import old mode 100644 new mode 100755 similarity index 73% rename from Assets/tmp2.png.import rename to Assets/oeil/2.png.import index 0c6c2a2..4e6972f --- a/Assets/tmp2.png.import +++ b/Assets/oeil/2.png.import @@ -2,15 +2,15 @@ importer="texture" type="StreamTexture" -path="res://.import/tmp2.png-ed8b7dcf1a8f661b4546e218d233b408.stex" +path="res://.import/2.png-1ff9afeca4806bc3c21ecbd49bd6edca.stex" metadata={ "vram_texture": false } [deps] -source_file="res://Assets/tmp2.png" -dest_files=[ "res://.import/tmp2.png-ed8b7dcf1a8f661b4546e218d233b408.stex" ] +source_file="res://Assets/oeil/2.png" +dest_files=[ "res://.import/2.png-1ff9afeca4806bc3c21ecbd49bd6edca.stex" ] [params] diff --git a/Assets/oeil/3.png b/Assets/oeil/3.png new file mode 100755 index 0000000..74fa68e --- /dev/null +++ b/Assets/oeil/3.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:167c2690ce736aea492e0b7942e9fd2f09fe0c5ce04228714d1df42471e62b7b +size 95412 diff --git a/Assets/oeil/3.png.import b/Assets/oeil/3.png.import new file mode 100755 index 0000000..a9260f6 --- /dev/null +++ b/Assets/oeil/3.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/3.png-fb4c2c875bedb0a5b9a15aaceb5db7a6.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/oeil/3.png" +dest_files=[ "res://.import/3.png-fb4c2c875bedb0a5b9a15aaceb5db7a6.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/oeil/4.png b/Assets/oeil/4.png new file mode 100755 index 0000000..9c74225 --- /dev/null +++ b/Assets/oeil/4.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:59edb12b971b8fce77cef07b6a5995e68c9e7b6ea3bae43c353f71d75fc027a7 +size 96020 diff --git a/Assets/oeil/4.png.import b/Assets/oeil/4.png.import new file mode 100755 index 0000000..feac369 --- /dev/null +++ b/Assets/oeil/4.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/4.png-7fe1e66a304beb8b8f288b2e20552fb7.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/oeil/4.png" +dest_files=[ "res://.import/4.png-7fe1e66a304beb8b8f288b2e20552fb7.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/oeil/5.png b/Assets/oeil/5.png new file mode 100755 index 0000000..a11df8d --- /dev/null +++ b/Assets/oeil/5.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:129932fb7adc00db285a8f1ab3a4e26a156244ac2a33e9c3d7232a607e0530ce +size 96972 diff --git a/Assets/oeil/5.png.import b/Assets/oeil/5.png.import new file mode 100755 index 0000000..266b921 --- /dev/null +++ b/Assets/oeil/5.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/5.png-bfc4574c3b23de470ee5e4b441d75685.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/oeil/5.png" +dest_files=[ "res://.import/5.png-bfc4574c3b23de470ee5e4b441d75685.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/oeil/6.png b/Assets/oeil/6.png new file mode 100755 index 0000000..4d52b92 --- /dev/null +++ b/Assets/oeil/6.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:22f9a642b78039d8ad6f57c6be064707007199de8f9c98ca554d66faff42f119 +size 97046 diff --git a/Assets/oeil/6.png.import b/Assets/oeil/6.png.import new file mode 100755 index 0000000..7294ccd --- /dev/null +++ b/Assets/oeil/6.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/6.png-0d212346d3154516cc8685f08785d0ab.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/oeil/6.png" +dest_files=[ "res://.import/6.png-0d212346d3154516cc8685f08785d0ab.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/tmp1.png b/Assets/tmp1.png deleted file mode 100755 index 708b537..0000000 --- a/Assets/tmp1.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8d56697442f1a48f9fd0423e05937add3e6d21cc9c254665b685dbe47b888654 -size 162 diff --git a/Assets/tmp2.png b/Assets/tmp2.png deleted file mode 100755 index 73da3fd..0000000 --- a/Assets/tmp2.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:12a59ab2d5b0d56f2ea760d644e4f3ef3c4b3e5685edc5a6c4d3b3facbb4a688 -size 160 diff --git a/Assets/tmp3.png b/Assets/tmp3.png deleted file mode 100755 index 82e0f18..0000000 --- a/Assets/tmp3.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e74d9171f175d34a6ee53a596be336fe3e33f7e06e543331d86c5463ef7a563a -size 161 diff --git a/Assets/warning/0.png b/Assets/warning/0.png new file mode 100755 index 0000000..a39d9c7 --- /dev/null +++ b/Assets/warning/0.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:345ebbf898767b97bd8e1169e3602780cb57a647b4118ddb35b249e989125189 +size 58833 diff --git a/Assets/warning/0.png.import b/Assets/warning/0.png.import new file mode 100755 index 0000000..6ecc520 --- /dev/null +++ b/Assets/warning/0.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/0.png-27f9a855fab4c2014c67992f0f29df5c.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/warning/0.png" +dest_files=[ "res://.import/0.png-27f9a855fab4c2014c67992f0f29df5c.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/warning/1.png b/Assets/warning/1.png new file mode 100755 index 0000000..01dd3b7 --- /dev/null +++ b/Assets/warning/1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cba83651eee34c3af1a15a4b0b4a185ee674fec37cba54b60ae139602172dd3c +size 61815 diff --git a/Assets/warning/1.png.import b/Assets/warning/1.png.import new file mode 100755 index 0000000..2dd76f9 --- /dev/null +++ b/Assets/warning/1.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/1.png-b3d440a789e97edae5d3bf6ecc56ccd9.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/warning/1.png" +dest_files=[ "res://.import/1.png-b3d440a789e97edae5d3bf6ecc56ccd9.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/warning/2.png b/Assets/warning/2.png new file mode 100755 index 0000000..f00e71b --- /dev/null +++ b/Assets/warning/2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:591670b1f48785e387196aff9e9e8cda175b7ef4b7a8e8ff496c840867d9440c +size 65523 diff --git a/Assets/warning/2.png.import b/Assets/warning/2.png.import new file mode 100755 index 0000000..91f367f --- /dev/null +++ b/Assets/warning/2.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/2.png-cf34b6dbfc69e919cd206f0f696a58b8.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/warning/2.png" +dest_files=[ "res://.import/2.png-cf34b6dbfc69e919cd206f0f696a58b8.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/warning/3.png b/Assets/warning/3.png new file mode 100755 index 0000000..fe579f5 --- /dev/null +++ b/Assets/warning/3.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f0ba857a2d4b427ef056fd92c77613293fa3efaaf18e664ca92865a1dca394bd +size 65317 diff --git a/Assets/warning/3.png.import b/Assets/warning/3.png.import new file mode 100755 index 0000000..1f54044 --- /dev/null +++ b/Assets/warning/3.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/3.png-84accc014138671d10224939234f4b7b.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/warning/3.png" +dest_files=[ "res://.import/3.png-84accc014138671d10224939234f4b7b.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/Villain.gd b/Characters/Villain.gd index 35a4022..7becb84 100755 --- a/Characters/Villain.gd +++ b/Characters/Villain.gd @@ -7,33 +7,38 @@ var limit_random var rng = RandomNumberGenerator.new() onready var button = $"../Button/" +# True if animation should change +var next = false + # 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) + me.play("orange") # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): timer += delta - match me.get_frame(): - 0: - # Vert - if timer >= limit_random: - timer = 0 - limit_random = rng.randi_range(2, 10) - me.set_frame(1) - 1: - # Orange - if timer >= .5: - timer = 0 - me.set_frame(2) - 2: - # Rouge - if timer >= 2: - timer = 0 - me.set_frame(0) - _: - print("Not handled frame") + + var animations = ["orange", "red"] + + var max_frame = me.frames.get_frame_count(me.animation) - 1 + var current_anim_idx = animations.find(me.animation) + if current_anim_idx >= animations.size() - 1: + # Last animation reached + check_next_animframe(me, max_frame, animations[0]) + else: + check_next_animframe(me, max_frame, animations[current_anim_idx + 1]) + + +# Jump to next animation at the end of the current one +func check_next_animframe(me, max_frame, next_animation): + if me.frame == 0 and next: + me.play(next_animation) + next = false + if max_frame == me.frame: + # Last frame of animation reached + next = true diff --git a/Characters/Villain.tscn b/Characters/Villain.tscn index a5a6c82..b9d3c6b 100755 --- a/Characters/Villain.tscn +++ b/Characters/Villain.tscn @@ -1,21 +1,33 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=13 format=2] -[ext_resource path="res://Assets/tmp1.png" type="Texture" id=1] -[ext_resource path="res://Assets/tmp3.png" type="Texture" id=2] -[ext_resource path="res://Assets/tmp2.png" type="Texture" id=3] +[ext_resource path="res://Assets/oeil/0.png" type="Texture" id=1] +[ext_resource path="res://Assets/oeil/1.png" type="Texture" id=2] +[ext_resource path="res://Assets/oeil/3.png" type="Texture" id=3] [ext_resource path="res://Characters/Villain.gd" type="Script" id=4] +[ext_resource path="res://Assets/oeil/4.png" type="Texture" id=5] +[ext_resource path="res://Assets/oeil/5.png" type="Texture" id=6] +[ext_resource path="res://Assets/oeil/6.png" type="Texture" id=7] +[ext_resource path="res://Assets/oeil/2.png" type="Texture" id=8] +[ext_resource path="res://Assets/warning/2.png" type="Texture" id=9] +[ext_resource path="res://Assets/warning/1.png" type="Texture" id=10] +[ext_resource path="res://Assets/warning/3.png" type="Texture" id=11] [sub_resource type="SpriteFrames" id=1] animations = [ { -"frames": [ ExtResource( 2 ), ExtResource( 3 ), ExtResource( 1 ) ], +"frames": [ ExtResource( 10 ), ExtResource( 9 ), ExtResource( 11 ) ], "loop": true, -"name": "default", -"speed": 5.0 +"name": "orange", +"speed": 1.5 +}, { +"frames": [ ExtResource( 1 ), ExtResource( 2 ), ExtResource( 8 ), ExtResource( 3 ), ExtResource( 5 ), ExtResource( 6 ), ExtResource( 7 ) ], +"loop": true, +"name": "red", +"speed": 2.0 } ] [node name="Villain" type="Node2D"] script = ExtResource( 4 ) [node name="AnimatedSprite" type="AnimatedSprite" parent="."] -scale = Vector2( 5, 5 ) frames = SubResource( 1 ) +animation = "orange" diff --git a/Scenes/Button_Node2D.gd b/Scenes/Button_Node2D.gd index 6a06021..9b15238 100755 --- a/Scenes/Button_Node2D.gd +++ b/Scenes/Button_Node2D.gd @@ -3,8 +3,8 @@ extends Button onready var villain = $"../Villain/AnimatedSprite" var etat -var texture_pressed = preload("res://Assets/skin_assets/button_normal.png") -var texture_released = preload("res://Assets/skin_assets/button_pressed.png") +const texture_pressed = preload("res://Assets/skin_assets/button_normal.png") +const texture_released = preload("res://Assets/skin_assets/button_pressed.png") # Called when the node enters the scene tree for the first time. @@ -15,11 +15,14 @@ func _ready(): # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(_delta): - match villain.get_frame(): - 2: - print("non") if etat else print("caché") - _: - print("oui") if etat else print("caché") + if etat: + match villain.get_frame(): + 2: + print("non") + _: + print("oui") + else: + print("caché") func _on_Button_pressed(): diff --git a/Scenes/Node2D.tscn b/Scenes/Node2D.tscn index 6215424..ccb0381 100755 --- a/Scenes/Node2D.tscn +++ b/Scenes/Node2D.tscn @@ -31,7 +31,8 @@ text = "CLIQUE MOI" script = ExtResource( 3 ) [node name="Villain" parent="." instance=ExtResource( 2 )] -position = Vector2( 943, 639 ) +position = Vector2( 871, 589 ) +scale = Vector2( 0.2, 0.2 ) [node name="Windows" type="Sprite" parent="."] visible = false