Anri/AdBlockNot
Archived
1
0
Fork 0

pause menu

This commit is contained in:
Mylloon 2024-01-28 22:30:48 +01:00
parent 900e5611b5
commit e866ff43cc
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
10 changed files with 49 additions and 60 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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"]

View file

@ -6,8 +6,6 @@ var condition = false
func _ready():
pass
func exit_condition():
return condition

View file

@ -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_offset (Vector2($Sprite2D.texture.get_width()/2, ($Sprite2D.texture.get_height()/2)+30))
pass
$Sprite2D.set_texture(images[val])
$Sprite2D.set_offset(Vector2($Sprite2D.texture.get_width() / 2, ($Sprite2D.texture.get_height() / 2) + 30))
func _on_button_pressed():
condition = true

View file

@ -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():

View file

@ -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()

View file

@ -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,10 +58,8 @@ func _ready():
pass
newLevel()
var seconds=0
var Dsecond=45
var seconds := 0
var Dsecond := 45
func win():
for ad in ads: