pause menu
This commit is contained in:
parent
900e5611b5
commit
e866ff43cc
10 changed files with 49 additions and 60 deletions
|
@ -7,7 +7,7 @@ func _ready():
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta):
|
func _process(_delta):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ position = Vector2(10, 53)
|
||||||
scale = Vector2(0.4, 0.34)
|
scale = Vector2(0.4, 0.34)
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="." index="3"]
|
[node name="Label" type="Label" parent="." index="3"]
|
||||||
|
layout_mode = 0
|
||||||
offset_left = 17.0
|
offset_left = 17.0
|
||||||
offset_top = 12.0
|
offset_top = 12.0
|
||||||
offset_right = 407.0
|
offset_right = 407.0
|
||||||
|
|
|
@ -41,6 +41,7 @@ offset_bottom = 326.0
|
||||||
theme_override_font_sizes/font_size = 31
|
theme_override_font_sizes/font_size = 31
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="." index="6"]
|
[node name="Label" type="Label" parent="." index="6"]
|
||||||
|
layout_mode = 0
|
||||||
offset_left = 17.0
|
offset_left = 17.0
|
||||||
offset_top = 12.0
|
offset_top = 12.0
|
||||||
offset_right = 407.0
|
offset_right = 407.0
|
||||||
|
|
|
@ -46,6 +46,7 @@ focus_mode = 0
|
||||||
flat = true
|
flat = true
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="." index="4"]
|
[node name="Label" type="Label" parent="." index="4"]
|
||||||
|
layout_mode = 0
|
||||||
offset_left = 17.0
|
offset_left = 17.0
|
||||||
offset_top = 12.0
|
offset_top = 12.0
|
||||||
offset_right = 407.0
|
offset_right = 407.0
|
||||||
|
|
|
@ -119,16 +119,14 @@ offset_top = 89.0
|
||||||
offset_right = -459.0
|
offset_right = -459.0
|
||||||
offset_bottom = -265.0
|
offset_bottom = -265.0
|
||||||
|
|
||||||
[node name="Rules" parent="." instance=ExtResource("8_fvukt")]
|
|
||||||
visible = false
|
|
||||||
z_index = 4096
|
|
||||||
|
|
||||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
||||||
stream = ExtResource("9_j4hp8")
|
stream = ExtResource("9_j4hp8")
|
||||||
volume_db = -14.102
|
volume_db = -14.102
|
||||||
autoplay = true
|
autoplay = true
|
||||||
bus = &"Music"
|
bus = &"Music"
|
||||||
|
|
||||||
|
[node name="GamesAreUnderThisNode" type="Node2D" parent="."]
|
||||||
|
|
||||||
[node name="Timer" type="Timer" parent="."]
|
[node name="Timer" type="Timer" parent="."]
|
||||||
process_callback = 0
|
process_callback = 0
|
||||||
|
|
||||||
|
@ -140,4 +138,8 @@ offset_bottom = 64.0
|
||||||
theme_override_fonts/font = ExtResource("1_7ecbr")
|
theme_override_fonts/font = ExtResource("1_7ecbr")
|
||||||
theme_override_font_sizes/font_size = 46
|
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"]
|
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||||
|
|
|
@ -6,8 +6,6 @@ var condition = false
|
||||||
func _ready():
|
func _ready():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func exit_condition():
|
func exit_condition():
|
||||||
return condition
|
return condition
|
||||||
|
|
||||||
|
|
|
@ -7,14 +7,11 @@ func _ready():
|
||||||
var images = [ load("res://ressources/assets/NormalAds/PosterCrab2.png")
|
var images = [ load("res://ressources/assets/NormalAds/PosterCrab2.png")
|
||||||
, load("res://ressources/assets/NormalAds/PosterCrab.png")
|
, load("res://ressources/assets/NormalAds/PosterCrab.png")
|
||||||
, load("res://ressources/assets/NormalAds/PosterMeow2.png")
|
, load("res://ressources/assets/NormalAds/PosterMeow2.png")
|
||||||
,load("res://ressources/assets/NormalAds/PosterMeow.png")
|
, load("res://ressources/assets/NormalAds/PosterMeow.png") ]
|
||||||
]
|
|
||||||
var val = rng.randf_range(0, 4)
|
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))
|
$Sprite2D.set_offset(Vector2($Sprite2D.texture.get_width() / 2, ($Sprite2D.texture.get_height() / 2) + 30))
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
func _on_button_pressed():
|
func _on_button_pressed():
|
||||||
condition = true
|
condition = true
|
||||||
|
|
|
@ -11,7 +11,7 @@ func exit_condition():
|
||||||
return condition
|
return condition
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta):
|
func _process(_delta):
|
||||||
close()
|
close()
|
||||||
|
|
||||||
func _on_button_pressed():
|
func _on_button_pressed():
|
||||||
|
|
|
@ -13,6 +13,9 @@ enum OP {
|
||||||
var reponse
|
var reponse
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
new_game()
|
||||||
|
|
||||||
|
func new_game():
|
||||||
var a := randi_range(0, 9)
|
var a := randi_range(0, 9)
|
||||||
var b := randi_range(0, 9)
|
var b := randi_range(0, 9)
|
||||||
|
|
||||||
|
@ -28,7 +31,7 @@ func _ready():
|
||||||
operator = "-"
|
operator = "-"
|
||||||
OP.MUL:
|
OP.MUL:
|
||||||
reponse = a * b
|
reponse = a * b
|
||||||
operator = "*"
|
operator = "x"
|
||||||
|
|
||||||
question.text = str(str(a), " ", operator, " " , str(b))
|
question.text = str(str(a), " ", operator, " " , str(b))
|
||||||
|
|
||||||
|
@ -41,7 +44,13 @@ func exit_condition():
|
||||||
return condition
|
return condition
|
||||||
|
|
||||||
func _on_button_1_pressed():
|
func _on_button_1_pressed():
|
||||||
condition = int(responseA.text) == reponse
|
check(int(responseA.text))
|
||||||
|
|
||||||
func _on_button_2_pressed():
|
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()
|
||||||
|
|
|
@ -4,33 +4,6 @@ var ads = []
|
||||||
var level = [10, 15, 25]
|
var level = [10, 15, 25]
|
||||||
var nlevel = 0
|
var nlevel = 0
|
||||||
var nb = 10
|
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():
|
func new_ads():
|
||||||
print("her")
|
print("her")
|
||||||
|
@ -38,7 +11,7 @@ func new_ads():
|
||||||
var _range = randi_range(0, ads_scene.size() - 1)
|
var _range = randi_range(0, ads_scene.size() - 1)
|
||||||
print(_range)
|
print(_range)
|
||||||
var instance = ads_scene[_range].instantiate()
|
var instance = ads_scene[_range].instantiate()
|
||||||
add_child(instance) # Replace with function body.
|
$GamesAreUnderThisNode.add_sibling(instance)
|
||||||
var _scale = Vector2(0.5, 0.5)
|
var _scale = Vector2(0.5, 0.5)
|
||||||
instance.scale = _scale
|
instance.scale = _scale
|
||||||
var _size = instance.get_size() * _scale
|
var _size = instance.get_size() * _scale
|
||||||
|
@ -50,14 +23,23 @@ func new_ads():
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func load_scene():
|
func load_scene():
|
||||||
var _ads_scene = getFilePathsByExtension("res://scenes/game/ads", "tscn")
|
for scene in [ "res://scenes/game/ads/ads_music.tscn"
|
||||||
for scene in _ads_scene:
|
, "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))
|
ads_scene.push_back(load(scene))
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
if event.is_action_pressed("ui_cancel"):
|
if event.is_action_pressed("ui_cancel"):
|
||||||
pass # todo one day ahah ^^
|
if ($Rules.visible):
|
||||||
# $Rules.set_visible(true)
|
$Rules.set_visible(false)
|
||||||
|
$Timer.start()
|
||||||
|
else:
|
||||||
|
$Rules.set_visible(true)
|
||||||
|
$Timer.stop()
|
||||||
|
|
||||||
func newLevel():
|
func newLevel():
|
||||||
for n in nb:
|
for n in nb:
|
||||||
|
@ -76,10 +58,8 @@ func _ready():
|
||||||
pass
|
pass
|
||||||
newLevel()
|
newLevel()
|
||||||
|
|
||||||
var seconds=0
|
var seconds := 0
|
||||||
var Dsecond=45
|
var Dsecond := 45
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func win():
|
func win():
|
||||||
for ad in ads:
|
for ad in ads:
|
||||||
|
|
Reference in a new issue