From 02c2d9bc4283926ada0bf6251c7f74e94a762891 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sat, 25 Feb 2023 01:04:08 +0100 Subject: [PATCH] Add prototype --- Assets/tmp.png | 3 +++ Assets/tmp.png.import | 35 +++++++++++++++++++++++++++++++++++ Assets/tmp1.png | 3 +++ Assets/tmp1.png.import | 35 +++++++++++++++++++++++++++++++++++ Assets/tmp2.png | 3 +++ Assets/tmp2.png.import | 35 +++++++++++++++++++++++++++++++++++ Assets/tmp3.png | 3 +++ Assets/tmp3.png.import | 35 +++++++++++++++++++++++++++++++++++ Characters/Player.tscn | 10 ++++++++++ Characters/Villain.gd | 33 +++++++++++++++++++++++++++++++++ Characters/Villain.tscn | 21 +++++++++++++++++++++ Scenes/Button_Node2D.gd | 21 +++++++++++++++++++++ Scenes/Node2D.tscn | 27 +++++++++++++++++++++++++++ project.godot | 1 + 14 files changed, 265 insertions(+) create mode 100755 Assets/tmp.png create mode 100755 Assets/tmp.png.import create mode 100755 Assets/tmp1.png create mode 100755 Assets/tmp1.png.import create mode 100755 Assets/tmp2.png create mode 100755 Assets/tmp2.png.import create mode 100755 Assets/tmp3.png create mode 100755 Assets/tmp3.png.import create mode 100755 Characters/Player.tscn create mode 100755 Characters/Villain.gd create mode 100755 Characters/Villain.tscn create mode 100755 Scenes/Button_Node2D.gd create mode 100755 Scenes/Node2D.tscn diff --git a/Assets/tmp.png b/Assets/tmp.png new file mode 100755 index 0000000..626a76b --- /dev/null +++ b/Assets/tmp.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1d59d5d88005399653a3066d562184dc505761dcdea809f7e6a9d6faa2b90a63 +size 439 diff --git a/Assets/tmp.png.import b/Assets/tmp.png.import new file mode 100755 index 0000000..e815ee7 --- /dev/null +++ b/Assets/tmp.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/tmp.png-82d4b422f3667f5c47d6988a92ccd2a3.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/tmp.png" +dest_files=[ "res://.import/tmp.png-82d4b422f3667f5c47d6988a92ccd2a3.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 new file mode 100755 index 0000000..708b537 --- /dev/null +++ b/Assets/tmp1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8d56697442f1a48f9fd0423e05937add3e6d21cc9c254665b685dbe47b888654 +size 162 diff --git a/Assets/tmp1.png.import b/Assets/tmp1.png.import new file mode 100755 index 0000000..8a1639a --- /dev/null +++ b/Assets/tmp1.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/tmp1.png-0c1a3d9d3390acb57bea785b3f9e30f7.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/tmp1.png" +dest_files=[ "res://.import/tmp1.png-0c1a3d9d3390acb57bea785b3f9e30f7.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/tmp2.png b/Assets/tmp2.png new file mode 100755 index 0000000..73da3fd --- /dev/null +++ b/Assets/tmp2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:12a59ab2d5b0d56f2ea760d644e4f3ef3c4b3e5685edc5a6c4d3b3facbb4a688 +size 160 diff --git a/Assets/tmp2.png.import b/Assets/tmp2.png.import new file mode 100755 index 0000000..0c6c2a2 --- /dev/null +++ b/Assets/tmp2.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/tmp2.png-ed8b7dcf1a8f661b4546e218d233b408.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/tmp2.png" +dest_files=[ "res://.import/tmp2.png-ed8b7dcf1a8f661b4546e218d233b408.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/tmp3.png b/Assets/tmp3.png new file mode 100755 index 0000000..82e0f18 --- /dev/null +++ b/Assets/tmp3.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e74d9171f175d34a6ee53a596be336fe3e33f7e06e543331d86c5463ef7a563a +size 161 diff --git a/Assets/tmp3.png.import b/Assets/tmp3.png.import new file mode 100755 index 0000000..a464c81 --- /dev/null +++ b/Assets/tmp3.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/tmp3.png-0afe8b1e9c47be51c701b0d537c4b45a.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/tmp3.png" +dest_files=[ "res://.import/tmp3.png-0afe8b1e9c47be51c701b0d537c4b45a.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 new file mode 100755 index 0000000..39464a0 --- /dev/null +++ b/Characters/Player.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://Assets/tmp.png" type="Texture" id=1] + +[node name="Player" type="Node2D"] +script = ExtResource( 1 ) + +[node name="Sprite" type="Sprite" parent="."] +scale = Vector2( 3.34375, 3.03125 ) +texture = ExtResource( 1 ) diff --git a/Characters/Villain.gd b/Characters/Villain.gd new file mode 100755 index 0000000..a3aba37 --- /dev/null +++ b/Characters/Villain.gd @@ -0,0 +1,33 @@ +extends Node2D + +onready var me = $AnimatedSprite + +onready var timer + + +# Called when the node enters the scene tree for the first time. +func _ready(): + timer = 0 + + +# 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 >= 5: + timer = 0 + 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") diff --git a/Characters/Villain.tscn b/Characters/Villain.tscn new file mode 100755 index 0000000..a5a6c82 --- /dev/null +++ b/Characters/Villain.tscn @@ -0,0 +1,21 @@ +[gd_scene load_steps=6 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://Characters/Villain.gd" type="Script" id=4] + +[sub_resource type="SpriteFrames" id=1] +animations = [ { +"frames": [ ExtResource( 2 ), ExtResource( 3 ), ExtResource( 1 ) ], +"loop": true, +"name": "default", +"speed": 5.0 +} ] + +[node name="Villain" type="Node2D"] +script = ExtResource( 4 ) + +[node name="AnimatedSprite" type="AnimatedSprite" parent="."] +scale = Vector2( 5, 5 ) +frames = SubResource( 1 ) diff --git a/Scenes/Button_Node2D.gd b/Scenes/Button_Node2D.gd new file mode 100755 index 0000000..39befa1 --- /dev/null +++ b/Scenes/Button_Node2D.gd @@ -0,0 +1,21 @@ +extends Button + +onready var villain = $"../Villain/AnimatedSprite" + + +# 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_Button_pressed(): + match villain.get_frame(): + 2: + print("non") + _: + print("oui") diff --git a/Scenes/Node2D.tscn b/Scenes/Node2D.tscn new file mode 100755 index 0000000..3e6061a --- /dev/null +++ b/Scenes/Node2D.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=5 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] + +[sub_resource type="Theme" id=1] + +[node name="Node2D" type="Node2D"] + +[node name="Player" parent="." instance=ExtResource( 1 )] +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 +theme = SubResource( 1 ) +text = "CLIQUE MOI" +script = ExtResource( 3 ) + +[node name="Villain" parent="." instance=ExtResource( 2 )] +position = Vector2( 276, 189 ) + +[connection signal="pressed" from="Button" to="Button" method="_on_Button_pressed"] diff --git a/project.godot b/project.godot index 544cbeb..3416020 100755 --- a/project.godot +++ b/project.godot @@ -11,6 +11,7 @@ config_version=4 [application] config/name="Gja" +run/main_scene="res://Scenes/Node2D.tscn" config/icon="res://icon.png" [gui]