Refactoring, add types and WIP directories

This commit is contained in:
Mylloon 2023-02-25 19:31:26 +01:00
parent f5db6bcbc0
commit 2ed6ec6ee3
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
13 changed files with 87 additions and 49 deletions

View file

@ -1,10 +0,0 @@
[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 )

View file

@ -13,20 +13,20 @@ var next = false
# Called when the node enters the scene tree for the first time.
func _ready():
func _ready() -> void:
rng.randomize()
reset_timer()
me.play(animations[0])
func reset_timer():
func reset_timer() -> void:
timer = 0
limit_random = rng.randi_range(2, 10)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
func _process(delta) -> void:
timer += delta
var max_frame = me.frames.get_frame_count(me.animation) - 1
@ -39,7 +39,7 @@ func _process(delta):
# Jump to next animation at the end of the current one
func check_next_animframe(max_frame, next_animation):
func check_next_animframe(max_frame, next_animation) -> void:
if me.frame == 0 and next:
me.play(next_animation)
next = false

View file

@ -3,7 +3,7 @@
[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://Characters/Scripts/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]

21
Elements/Directory.tscn Executable file
View file

@ -0,0 +1,21 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Assets/tmp.png" type="Texture" id=1]
[ext_resource path="res://Elements/Scripts/Directory.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 16, 16 )
[node name="Node2D" type="Node2D"]
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
[node name="Area2D" type="Area2D" parent="."]
script = ExtResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource( 1 )
[connection signal="mouse_entered" from="Area2D" to="Area2D" method="_on_Area2D_mouse_entered"]
[connection signal="mouse_exited" from="Area2D" to="Area2D" method="_on_Area2D_mouse_exited"]

11
Elements/Scripts/Directory.gd Executable file
View file

@ -0,0 +1,11 @@
extends Area2D
func _on_Area2D_mouse_entered() -> void:
print("coucou")
Input.set_default_cursor_shape(Input.CURSOR_POINTING_HAND)
func _on_Area2D_mouse_exited() -> void:
print("bye")
Input.set_default_cursor_shape(Input.CURSOR_ARROW)

View file

@ -1,8 +1,8 @@
[gd_scene load_steps=10 format=2]
[ext_resource path="res://Characters/Villain.tscn" type="PackedScene" id=1]
[ext_resource path="res://Characters/Player.tscn" type="PackedScene" id=2]
[ext_resource path="res://Scenes/Button_Node2D.gd" type="Script" id=3]
[ext_resource path="res://Elements/Directory.tscn" type="PackedScene" id=2]
[ext_resource path="res://Scenes/Scripts/Button_Node2D.gd" type="Script" 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://Assets/tres_button/hover.tres" type="StyleBox" id=6]
@ -13,10 +13,11 @@
[node name="Node2D" type="Node2D"]
[node name="Player" parent="." instance=ExtResource( 2 )]
[node name="Windows" type="Sprite" parent="."]
visible = false
position = Vector2( 719, 386 )
script = null
position = Vector2( 512, 358 )
z_index = -3
texture = ExtResource( 7 )
[node name="Button" type="Button" parent="."]
margin_left = 431.0
@ -24,7 +25,8 @@ margin_top = 349.0
margin_right = 651.0
margin_bottom = 386.0
theme = SubResource( 1 )
custom_colors/font_color = Color( 0.27451, 0.207843, 0.207843, 1 )
custom_colors/font_color_disabled = Color( 0, 0, 0, 1 )
custom_colors/font_color = Color( 0.34902, 0.313726, 0.313726, 1 )
custom_fonts/font = ExtResource( 8 )
custom_styles/hover = ExtResource( 6 )
custom_styles/pressed = ExtResource( 5 )
@ -36,10 +38,24 @@ script = ExtResource( 3 )
position = Vector2( 871, 589 )
scale = Vector2( 0.2, 0.2 )
[node name="Windows" type="Sprite" parent="."]
visible = false
position = Vector2( 512, 358 )
z_index = -3
texture = ExtResource( 7 )
[node name="Directories" type="Node2D" parent="."]
[node name="Directory1" parent="Directories" instance=ExtResource( 2 )]
position = Vector2( 40, 130 )
[node name="Directory2" parent="Directories" instance=ExtResource( 2 )]
position = Vector2( 40, 180 )
[node name="Directory3" parent="Directories" instance=ExtResource( 2 )]
position = Vector2( 40, 230 )
[node name="Directory4" parent="Directories" instance=ExtResource( 2 )]
position = Vector2( 40, 280 )
[node name="Directory5" parent="Directories" instance=ExtResource( 2 )]
position = Vector2( 40, 330 )
[node name="Directory6" parent="Directories" instance=ExtResource( 2 )]
position = Vector2( 40, 380 )
[connection signal="pressed" from="Button" to="Button" method="_on_Button_pressed"]

View file

@ -1,5 +0,0 @@
extends Node2D
func _on_RestartButton_pressed():
get_tree().change_scene("res://Scenes/Menu.tscn")

View file

@ -1,13 +0,0 @@
extends Control
func _on_PlayButton_pressed():
get_tree().change_scene("res://Scenes/DesktopScreen.tscn")
func _on_Help_Button_pressed():
print("help me")
func _on_Quit_Button_pressed():
get_tree().quit()

View file

@ -9,13 +9,13 @@ const texture_released = preload("res://Assets/skin_assets/button_pressed.png")
# Called every frame. '_delta' is the elapsed time since the previous frame.
func _process(_delta):
func _process(_delta) -> void:
if etat:
if villain.animation == villain_animations[-1]:
get_tree().change_scene("res://Scenes/GameOver.tscn")
assert(get_tree().change_scene("res://Scenes/GameOver.tscn") == OK)
func _on_Button_pressed():
func _on_Button_pressed() -> void:
etat = !etat
var new_stylebox_normal = self.get_stylebox("normal").duplicate()
if etat:

5
Scenes/Scripts/GameOver.gd Executable file
View file

@ -0,0 +1,5 @@
extends Node2D
func _on_RestartButton_pressed() -> void:
assert(get_tree().change_scene("res://Scenes/Menu.tscn") == OK)

13
Scenes/Scripts/Screen_Menu.gd Executable file
View file

@ -0,0 +1,13 @@
extends Control
func _on_PlayButton_pressed() -> void:
assert(get_tree().change_scene("res://Scenes/DesktopScreen.tscn") == OK)
func _on_Help_Button_pressed() -> void:
print("help me")
func _on_Quit_Button_pressed() -> void:
get_tree().quit()

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=7 format=2]
[ext_resource path="res://Scenes/GameOver.gd" type="Script" id=1]
[ext_resource path="res://Scenes/Scripts/GameOver.gd" type="Script" id=1]
[ext_resource path="res://Assets/skin_assets/menu_font.tres" type="DynamicFont" id=2]
[ext_resource path="res://Assets/tres_button/normal.tres" type="StyleBox" id=3]
[ext_resource path="res://Assets/tres_button/pressed.tres" type="StyleBox" id=4]

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=7 format=2]
[ext_resource path="res://Scenes/Screen_Menu.gd" type="Script" id=1]
[ext_resource path="res://Scenes/Scripts/Screen_Menu.gd" type="Script" id=1]
[ext_resource path="res://Assets/skin_assets/menu_font.tres" type="DynamicFont" id=2]
[ext_resource path="res://Assets/tres_button/normal.tres" type="StyleBox" id=3]
[ext_resource path="res://Assets/tres_button/pressed.tres" type="StyleBox" id=4]