diff --git a/scenes/game/ButtonMenu.gd b/scenes/game/ButtonMenu.gd index deeb16b..a2a2cbb 100644 --- a/scenes/game/ButtonMenu.gd +++ b/scenes/game/ButtonMenu.gd @@ -7,7 +7,7 @@ func _ready(): # Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): +func _process(_delta): pass diff --git a/scenes/game/ads/ads_normal.tscn b/scenes/game/ads/ads_normal.tscn index b79bc03..bb7eb65 100644 --- a/scenes/game/ads/ads_normal.tscn +++ b/scenes/game/ads/ads_normal.tscn @@ -12,6 +12,7 @@ position = Vector2(10, 53) scale = Vector2(0.4, 0.34) [node name="Label" type="Label" parent="." index="3"] +layout_mode = 0 offset_left = 17.0 offset_top = 12.0 offset_right = 407.0 diff --git a/scenes/game/ads/ads_operation.tscn b/scenes/game/ads/ads_operation.tscn index 30f21b2..51c6b8a 100644 --- a/scenes/game/ads/ads_operation.tscn +++ b/scenes/game/ads/ads_operation.tscn @@ -41,6 +41,7 @@ offset_bottom = 326.0 theme_override_font_sizes/font_size = 31 [node name="Label" type="Label" parent="." index="6"] +layout_mode = 0 offset_left = 17.0 offset_top = 12.0 offset_right = 407.0 diff --git a/scenes/game/ads/ads_roll.tscn b/scenes/game/ads/ads_roll.tscn index 0a48b96..a631d3b 100644 --- a/scenes/game/ads/ads_roll.tscn +++ b/scenes/game/ads/ads_roll.tscn @@ -46,6 +46,7 @@ focus_mode = 0 flat = true [node name="Label" type="Label" parent="." index="4"] +layout_mode = 0 offset_left = 17.0 offset_top = 12.0 offset_right = 407.0 diff --git a/scenes/game/screen.tscn b/scenes/game/screen.tscn index 87623df..c85aa14 100644 --- a/scenes/game/screen.tscn +++ b/scenes/game/screen.tscn @@ -119,16 +119,14 @@ offset_top = 89.0 offset_right = -459.0 offset_bottom = -265.0 -[node name="Rules" parent="." instance=ExtResource("8_fvukt")] -visible = false -z_index = 4096 - [node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] stream = ExtResource("9_j4hp8") volume_db = -14.102 autoplay = true bus = &"Music" +[node name="GamesAreUnderThisNode" type="Node2D" parent="."] + [node name="Timer" type="Timer" parent="."] process_callback = 0 @@ -140,4 +138,8 @@ offset_bottom = 64.0 theme_override_fonts/font = ExtResource("1_7ecbr") theme_override_font_sizes/font_size = 46 +[node name="Rules" parent="." instance=ExtResource("8_fvukt")] +visible = false +z_index = 4096 + [connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"] diff --git a/scripts/ads.gd b/scripts/ads.gd index ed51c5e..792fdfd 100644 --- a/scripts/ads.gd +++ b/scripts/ads.gd @@ -5,12 +5,10 @@ var condition = false # Called when the node enters the scene tree for the first time. func _ready(): pass - - func exit_condition(): return condition - + func close(): if exit_condition(): self.visible = false diff --git a/scripts/ads/Ads_normal.gd b/scripts/ads/Ads_normal.gd index 07961c6..77933b3 100644 --- a/scripts/ads/Ads_normal.gd +++ b/scripts/ads/Ads_normal.gd @@ -4,17 +4,14 @@ var rng = RandomNumberGenerator.new() # Called when the node enters the scene tree for the first time. func _ready(): $Panel2/Button.disabled = false - var images = [ load("res://ressources/assets/NormalAds/PosterCrab2.png") - ,load("res://ressources/assets/NormalAds/PosterCrab.png") - ,load("res://ressources/assets/NormalAds/PosterMeow2.png") - ,load("res://ressources/assets/NormalAds/PosterMeow.png") - ] + var images = [ load("res://ressources/assets/NormalAds/PosterCrab2.png") + , load("res://ressources/assets/NormalAds/PosterCrab.png") + , load("res://ressources/assets/NormalAds/PosterMeow2.png") + , load("res://ressources/assets/NormalAds/PosterMeow.png") ] var val = rng.randf_range(0, 4) - $Sprite2D.set_texture (images[val]) + $Sprite2D.set_texture(images[val]) - $Sprite2D.set_offset (Vector2($Sprite2D.texture.get_width()/2, ($Sprite2D.texture.get_height()/2)+30)) - pass - + $Sprite2D.set_offset(Vector2($Sprite2D.texture.get_width() / 2, ($Sprite2D.texture.get_height() / 2) + 30)) func _on_button_pressed(): condition = true diff --git a/scripts/ads/ads_default.gd b/scripts/ads/ads_default.gd index deca7ca..f8fc1e7 100644 --- a/scripts/ads/ads_default.gd +++ b/scripts/ads/ads_default.gd @@ -11,7 +11,7 @@ func exit_condition(): return condition # Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): +func _process(_delta): close() func _on_button_pressed(): diff --git a/scripts/ads/ads_operation.gd b/scripts/ads/ads_operation.gd index b482ae0..8af9920 100644 --- a/scripts/ads/ads_operation.gd +++ b/scripts/ads/ads_operation.gd @@ -13,6 +13,9 @@ enum OP { var reponse func _ready(): + new_game() + +func new_game(): var a := randi_range(0, 9) var b := randi_range(0, 9) @@ -28,7 +31,7 @@ func _ready(): operator = "-" OP.MUL: reponse = a * b - operator = "*" + operator = "x" question.text = str(str(a), " ", operator, " " , str(b)) @@ -41,7 +44,13 @@ func exit_condition(): return condition func _on_button_1_pressed(): - condition = int(responseA.text) == reponse + check(int(responseA.text)) func _on_button_2_pressed(): - condition = int(responseB.text) == reponse + check(int(responseB.text)) + +func check(data): + if data == reponse: + condition = true + else: + new_game() diff --git a/scripts/game.gd b/scripts/game.gd index 7520aaf..64085e1 100644 --- a/scripts/game.gd +++ b/scripts/game.gd @@ -4,60 +4,42 @@ var ads = [] var level = [10, 15, 25] var nlevel = 0 var nb = 10 -""" -var ads_scene = [preload("res://scenes/game/ads/Ads_password.tscn"), -preload("res://scenes/game/ads/Ads_sudoku.tscn")] -""" - -func getFilePathsByExtension(directoryPath: String, extension: String) -> Array: - var dir = DirAccess.open(directoryPath) - if !dir : - printerr("Warning: could not open directory: ", directoryPath) - return [] - - var filePaths := [] - if dir: - dir.list_dir_begin() - var fileName = dir.get_next() - while fileName != "": - if dir.current_is_dir(): - print("Found directory: " + fileName) - else: - print("Found file: " + fileName) - if fileName.get_extension() == extension: - var filePath = dir.get_current_dir() + "/" + fileName - filePaths.append(filePath) - fileName = dir.get_next() - else: - print("An error occurred when trying to access the path.") - return filePaths func new_ads(): print("her") randomize() - var _range = randi_range(0, ads_scene.size()-1) + var _range = randi_range(0, ads_scene.size() - 1) print(_range) var instance = ads_scene[_range].instantiate() - add_child(instance) # Replace with function body. - var _scale = Vector2(0.5,0.5) + $GamesAreUnderThisNode.add_sibling(instance) + var _scale = Vector2(0.5, 0.5) instance.scale = _scale var _size = instance.get_size() * _scale print(_size) instance.position.x = randf_range(1, get_viewport_rect().size.x - (_size.x)) - instance.position.y = randf_range(1, get_viewport_rect().size.y - (_size.y*1.5)) + instance.position.y = randf_range(1, get_viewport_rect().size.y - (_size.y * 1.5)) ads.push_back(instance) print(instance.position) # Called when the node enters the scene tree for the first time. func load_scene(): - var _ads_scene = getFilePathsByExtension("res://scenes/game/ads", "tscn") - for scene in _ads_scene: + for scene in [ "res://scenes/game/ads/ads_music.tscn" + , "res://scenes/game/ads/ads_normal.tscn" + , "res://scenes/game/ads/ads_operation.tscn" + , "res://scenes/game/ads/ads_pair.tscn" + , "res://scenes/game/ads/ads_roll.tscn" + , "res://scenes/game/ads/ads_sexy_robot.tscn" + , "res://scenes/game/ads/ads_weather.tscn" ]: ads_scene.push_back(load(scene)) func _input(event): if event.is_action_pressed("ui_cancel"): - pass # todo one day ahah ^^ - # $Rules.set_visible(true) + if ($Rules.visible): + $Rules.set_visible(false) + $Timer.start() + else: + $Rules.set_visible(true) + $Timer.stop() func newLevel(): for n in nb: @@ -76,11 +58,9 @@ func _ready(): pass newLevel() -var seconds=0 -var Dsecond=45 +var seconds := 0 +var Dsecond := 45 - - func win(): for ad in ads: if ad.visible == true :