refactor minigame
This commit is contained in:
parent
9dd2ae7bb5
commit
d28716d346
35 changed files with 336 additions and 629 deletions
|
@ -4,16 +4,18 @@ signal game_over
|
||||||
|
|
||||||
onready var foreground := $foreground
|
onready var foreground := $foreground
|
||||||
onready var spawner := $spawner
|
onready var spawner := $spawner
|
||||||
onready var player := $player2
|
onready var player := $player
|
||||||
onready var scoreUI := $scoreUI
|
onready var scoreUI := $scoreUI
|
||||||
onready var start_timer_UI := $start_timer_UI
|
onready var start_timer_UI := $startTimerUI
|
||||||
onready var instructionsUI := $instructionsUI
|
onready var instructionsUI := $instructionsUI
|
||||||
|
onready var timer := $Timer
|
||||||
|
|
||||||
var next_timeline_lose := ""
|
var next_timeline_lose := ""
|
||||||
var next_timeline_win := ""
|
var next_timeline_win := ""
|
||||||
|
|
||||||
var game_mode = ""
|
var game_mode = ""
|
||||||
var game_goal = 10
|
var game_goal = 10
|
||||||
|
var current_goal = 0
|
||||||
var game_difficulty = "easy"
|
var game_difficulty = "easy"
|
||||||
var game_version = 0
|
var game_version = 0
|
||||||
|
|
||||||
|
@ -21,8 +23,7 @@ var MUSIC = "res://music/mini_jeu.ogg"
|
||||||
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
Signals.connect("die", self, "on_game_over")
|
pass
|
||||||
Signals.connect("win", self, "on_win")
|
|
||||||
|
|
||||||
|
|
||||||
func setup(mode: String, goal: int, difficulty: String, next_lose: String, next_win: String, version: int):
|
func setup(mode: String, goal: int, difficulty: String, next_lose: String, next_win: String, version: int):
|
||||||
|
@ -34,7 +35,7 @@ func setup(mode: String, goal: int, difficulty: String, next_lose: String, next_
|
||||||
game_version = version
|
game_version = version
|
||||||
print("setup minigame: " + mode + " " + next_lose + " " + next_win)
|
print("setup minigame: " + mode + " " + next_lose + " " + next_win)
|
||||||
set_mode(mode)
|
set_mode(mode)
|
||||||
scoreUI.init(mode, game_goal)
|
scoreUI.init(mode)
|
||||||
next_timeline_lose = next_lose
|
next_timeline_lose = next_lose
|
||||||
next_timeline_win = next_win
|
next_timeline_win = next_win
|
||||||
|
|
||||||
|
@ -58,25 +59,30 @@ func start():
|
||||||
add_child(t)
|
add_child(t)
|
||||||
t.start()
|
t.start()
|
||||||
for n in range(3,0,-1):
|
for n in range(3,0,-1):
|
||||||
start_timer_UI.update_timer(String(n))
|
start_timer_UI.update_timer(n)
|
||||||
yield(t, "timeout")
|
yield(t, "timeout")
|
||||||
start_timer_UI.update_timer("GO !")
|
start_timer_UI.update_timer(0)
|
||||||
instructionsUI._init()
|
instructionsUI._init()
|
||||||
foreground.start()
|
foreground.start()
|
||||||
player.start(game_mode, game_goal)
|
player.start()
|
||||||
yield(t, "timeout")
|
yield(t, "timeout")
|
||||||
yield(t, "timeout")
|
yield(t, "timeout")
|
||||||
start_timer_UI.hide()
|
start_timer_UI.hide()
|
||||||
spawner.start(game_difficulty, game_version)
|
spawner.start(game_difficulty, game_version)
|
||||||
scoreUI.start(game_mode)
|
if game_mode == "score":
|
||||||
|
scoreUI.start(0)
|
||||||
|
else:
|
||||||
|
scoreUI.start(game_goal)
|
||||||
t.queue_free()
|
t.queue_free()
|
||||||
|
if game_mode == "time":
|
||||||
|
timer.start()
|
||||||
|
|
||||||
|
|
||||||
func stop():
|
func stop():
|
||||||
foreground.stop()
|
foreground.stop()
|
||||||
player.stop()
|
player.stop()
|
||||||
spawner.stop()
|
spawner.stop()
|
||||||
scoreUI.stop()
|
timer.stop()
|
||||||
|
|
||||||
|
|
||||||
func on_win():
|
func on_win():
|
||||||
|
@ -87,3 +93,27 @@ func on_win():
|
||||||
func on_game_over():
|
func on_game_over():
|
||||||
stop()
|
stop()
|
||||||
emit_signal("game_over", next_timeline_lose)
|
emit_signal("game_over", next_timeline_lose)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_player_die() -> void:
|
||||||
|
on_game_over()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_player_hit() -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func _on_player_score() -> void:
|
||||||
|
if game_mode == "score":
|
||||||
|
current_goal += 1
|
||||||
|
scoreUI.update_score(current_goal)
|
||||||
|
if current_goal >= game_goal:
|
||||||
|
on_win()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Timer_timeout() -> void:
|
||||||
|
if game_mode == "time":
|
||||||
|
current_goal += 1
|
||||||
|
scoreUI.update_score(game_goal - current_goal)
|
||||||
|
if current_goal >= game_goal:
|
||||||
|
on_win()
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
[ext_resource path="res://mini-game/scenes/decor/background.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://mini-game/scenes/decor/background.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://mini-game/scenes/decor/foreground.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://mini-game/scenes/decor/foreground.tscn" type="PackedScene" id=2]
|
||||||
[ext_resource path="res://mini-game/scenes/players/player2.tscn" type="PackedScene" id=3]
|
[ext_resource path="res://mini-game/scenes/players/player.tscn" type="PackedScene" id=3]
|
||||||
[ext_resource path="res://mini-game/MiniGame.gd" type="Script" id=4]
|
[ext_resource path="res://mini-game/MiniGame.gd" type="Script" id=4]
|
||||||
[ext_resource path="res://mini-game/scenes/decor/start_timer_UI.tscn" type="PackedScene" id=5]
|
[ext_resource path="res://mini-game/scenes/decor/startTimerUI.tscn" type="PackedScene" id=5]
|
||||||
[ext_resource path="res://mini-game/scenes/spawner/spawner.tscn" type="PackedScene" id=6]
|
[ext_resource path="res://mini-game/scenes/spawner/spawner.tscn" type="PackedScene" id=6]
|
||||||
[ext_resource path="res://mini-game/scenes/decor/scoreUI.tscn" type="PackedScene" id=7]
|
[ext_resource path="res://mini-game/scenes/decor/scoreUI.tscn" type="PackedScene" id=7]
|
||||||
[ext_resource path="res://mini-game/scenes/decor/instructionsUI.tscn" type="PackedScene" id=8]
|
[ext_resource path="res://mini-game/scenes/decor/instructionsUI.tscn" type="PackedScene" id=8]
|
||||||
|
@ -19,13 +19,18 @@ script = ExtResource( 4 )
|
||||||
[node name="spawner" parent="." instance=ExtResource( 6 )]
|
[node name="spawner" parent="." instance=ExtResource( 6 )]
|
||||||
position = Vector2( 2015.43, 970.395 )
|
position = Vector2( 2015.43, 970.395 )
|
||||||
|
|
||||||
[node name="player2" parent="." instance=ExtResource( 3 )]
|
[node name="player" parent="." instance=ExtResource( 3 )]
|
||||||
position = Vector2( 183.674, 888.367 )
|
position = Vector2( 183.674, 888.367 )
|
||||||
jump_vitesse = 1100.0
|
|
||||||
gravite = 45.0
|
|
||||||
|
|
||||||
[node name="scoreUI" parent="." instance=ExtResource( 7 )]
|
[node name="scoreUI" parent="." instance=ExtResource( 7 )]
|
||||||
|
|
||||||
[node name="start_timer_UI" parent="." instance=ExtResource( 5 )]
|
[node name="startTimerUI" parent="." instance=ExtResource( 5 )]
|
||||||
|
|
||||||
[node name="instructionsUI" parent="." instance=ExtResource( 8 )]
|
[node name="instructionsUI" parent="." instance=ExtResource( 8 )]
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="."]
|
||||||
|
|
||||||
|
[connection signal="die" from="player" to="." method="_on_player_die"]
|
||||||
|
[connection signal="hit" from="player" to="." method="_on_player_hit"]
|
||||||
|
[connection signal="score" from="player" to="." method="_on_player_score"]
|
||||||
|
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
||||||
|
|
|
@ -1,24 +1,8 @@
|
||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://mini-game/scripts/bonus1.gd" type="Script" id=1]
|
[ext_resource path="res://mini-game/scenes/spawner/pickup.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://mini-game/ressources/sprites/bonus/bone.png" type="Texture" id=2]
|
[ext_resource path="res://mini-game/ressources/sprites/bonus/bone.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://mini-game/scenes/effets/pick_bonus.tscn" type="PackedScene" id=3]
|
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[node name="bonus1" instance=ExtResource( 1 )]
|
||||||
extents = Vector2( 24.0183, 9.31512 )
|
sprite_texture = ExtResource( 2 )
|
||||||
|
type = "bonus"
|
||||||
[node name="bonus1" type="Node2D"]
|
|
||||||
script = ExtResource( 1 )
|
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="."]
|
|
||||||
scale = Vector2( 0.119644, 0.119644 )
|
|
||||||
texture = ExtResource( 2 )
|
|
||||||
|
|
||||||
[node name="pick_bonus" parent="." instance=ExtResource( 3 )]
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="pick_bonus"]
|
|
||||||
shape = SubResource( 1 )
|
|
||||||
|
|
||||||
[node name="notifier" type="VisibilityNotifier2D" parent="."]
|
|
||||||
|
|
||||||
[connection signal="body_entered" from="pick_bonus" to="." method="_on_pick_bonus_body_entered"]
|
|
||||||
|
|
|
@ -1,24 +1,8 @@
|
||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://mini-game/scripts/bonus1.gd" type="Script" id=1]
|
[ext_resource path="res://mini-game/scenes/spawner/pickup.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://mini-game/ressources/sprites/bonus/bonus_enveloppe.png" type="Texture" id=2]
|
[ext_resource path="res://mini-game/ressources/sprites/bonus/bonus_enveloppe.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://mini-game/scenes/effets/pick_bonus.tscn" type="PackedScene" id=3]
|
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[node name="bonus1" instance=ExtResource( 1 )]
|
||||||
extents = Vector2( 51.3758, 37.234 )
|
sprite_texture = ExtResource( 2 )
|
||||||
|
type = "bonus"
|
||||||
[node name="bonus2" type="Node2D"]
|
|
||||||
script = ExtResource( 1 )
|
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="."]
|
|
||||||
scale = Vector2( 0.2, 0.2 )
|
|
||||||
texture = ExtResource( 2 )
|
|
||||||
|
|
||||||
[node name="pick_bonus" parent="." instance=ExtResource( 3 )]
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="pick_bonus"]
|
|
||||||
position = Vector2( -0.625, 0 )
|
|
||||||
shape = SubResource( 1 )
|
|
||||||
|
|
||||||
[node name="notifier" type="VisibilityNotifier2D" parent="."]
|
|
||||||
[connection signal="body_entered" from="pick_bonus" to="." method="_on_pick_bonus_body_entered"]
|
|
||||||
|
|
|
@ -1,25 +1,8 @@
|
||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://mini-game/scripts/bonus1.gd" type="Script" id=1]
|
[ext_resource path="res://mini-game/scenes/spawner/pickup.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://mini-game/ressources/sprites/bonus/oreille.png" type="Texture" id=2]
|
[ext_resource path="res://mini-game/ressources/sprites/bonus/oreille.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://mini-game/scenes/effets/pick_bonus.tscn" type="PackedScene" id=3]
|
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[node name="bonus3" instance=ExtResource( 1 )]
|
||||||
extents = Vector2( 44.6127, 47.0458 )
|
sprite_texture = ExtResource( 2 )
|
||||||
|
type = "bonus"
|
||||||
[node name="bonus3" type="Node2D"]
|
|
||||||
script = ExtResource( 1 )
|
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="."]
|
|
||||||
position = Vector2( 0.627587, -14.6332 )
|
|
||||||
scale = Vector2( 0.101666, 0.101666 )
|
|
||||||
texture = ExtResource( 2 )
|
|
||||||
|
|
||||||
[node name="pick_bonus" parent="." instance=ExtResource( 3 )]
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="pick_bonus"]
|
|
||||||
position = Vector2( 1.00113, -11.3461 )
|
|
||||||
shape = SubResource( 1 )
|
|
||||||
|
|
||||||
[node name="notifier" type="VisibilityNotifier2D" parent="."]
|
|
||||||
[connection signal="body_entered" from="pick_bonus" to="." method="_on_pick_bonus_body_entered"]
|
|
||||||
|
|
|
@ -1,25 +1,8 @@
|
||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://mini-game/scripts/bonus1.gd" type="Script" id=1]
|
[ext_resource path="res://mini-game/scenes/spawner/pickup.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://mini-game/ressources/sprites/bonus/telephonebrillant.png" type="Texture" id=2]
|
[ext_resource path="res://mini-game/ressources/sprites/bonus/telephonebrillant.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://mini-game/scenes/effets/pick_bonus.tscn" type="PackedScene" id=3]
|
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[node name="bonus4" instance=ExtResource( 1 )]
|
||||||
extents = Vector2( 25.9386, 54.0271 )
|
sprite_texture = ExtResource( 2 )
|
||||||
|
type = "bonus"
|
||||||
[node name="bonus4" type="Node2D"]
|
|
||||||
script = ExtResource( 1 )
|
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="."]
|
|
||||||
position = Vector2( -0.453356, -18.8551 )
|
|
||||||
scale = Vector2( 0.0729584, 0.0729585 )
|
|
||||||
texture = ExtResource( 2 )
|
|
||||||
|
|
||||||
[node name="pick_bonus" parent="." instance=ExtResource( 3 )]
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="pick_bonus"]
|
|
||||||
position = Vector2( -0.594162, -14.2551 )
|
|
||||||
shape = SubResource( 1 )
|
|
||||||
|
|
||||||
[node name="notifier" type="VisibilityNotifier2D" parent="."]
|
|
||||||
[connection signal="body_entered" from="pick_bonus" to="." method="_on_pick_bonus_body_entered"]
|
|
||||||
|
|
|
@ -1,28 +1,8 @@
|
||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://mini-game/scripts/bonus1.gd" type="Script" id=1]
|
[ext_resource path="res://mini-game/scenes/spawner/pickup.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://mini-game/ressources/sprites/bonus/peinture.png" type="Texture" id=2]
|
[ext_resource path="res://mini-game/ressources/sprites/bonus/peinture.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://mini-game/scenes/effets/pick_bonus.tscn" type="PackedScene" id=3]
|
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[node name="bonus5" instance=ExtResource( 1 )]
|
||||||
extents = Vector2( 30.5774, 94.4143 )
|
sprite_texture = ExtResource( 2 )
|
||||||
|
type = "bonus"
|
||||||
[node name="bonus5" type="Node2D"]
|
|
||||||
script = ExtResource( 1 )
|
|
||||||
__meta__ = {
|
|
||||||
"_edit_horizontal_guides_": [ -97.9765 ]
|
|
||||||
}
|
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="."]
|
|
||||||
position = Vector2( 0.0226159, -21.252 )
|
|
||||||
scale = Vector2( 0.101622, 0.101622 )
|
|
||||||
texture = ExtResource( 2 )
|
|
||||||
|
|
||||||
[node name="pick_bonus" parent="." instance=ExtResource( 3 )]
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="pick_bonus"]
|
|
||||||
position = Vector2( -0.759476, -7.68111 )
|
|
||||||
shape = SubResource( 1 )
|
|
||||||
|
|
||||||
[node name="notifier" type="VisibilityNotifier2D" parent="."]
|
|
||||||
[connection signal="body_entered" from="pick_bonus" to="." method="_on_pick_bonus_body_entered"]
|
|
||||||
|
|
|
@ -1,55 +1,18 @@
|
||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
onready var label : Label = $MarginContainer/Label
|
onready var label := $MarginContainer/Label
|
||||||
onready var timer = $Timer
|
|
||||||
|
|
||||||
var game_mode
|
var game_mode
|
||||||
var max_time = 30
|
|
||||||
var current_time = 0
|
|
||||||
|
|
||||||
func _ready():
|
|
||||||
Signals.connect("update_score",self,"update_score")
|
|
||||||
|
|
||||||
|
|
||||||
func update_score(score: int):
|
func update_score(score: int):
|
||||||
label.text = String(score)
|
label.text = String(score)
|
||||||
|
|
||||||
|
|
||||||
func start(mode: String):
|
func start(initial_score: int):
|
||||||
match mode:
|
update_score(initial_score)
|
||||||
"score":
|
|
||||||
update_score(0)
|
|
||||||
show()
|
show()
|
||||||
"time":
|
|
||||||
update_score(max_time)
|
|
||||||
show()
|
|
||||||
current_time = 0
|
|
||||||
timer.start()
|
|
||||||
_:
|
|
||||||
print("game_mode not recognized by scoreUI")
|
|
||||||
|
|
||||||
|
|
||||||
func set_max_time(time: int):
|
func init(mode: String):
|
||||||
max_time = time
|
|
||||||
|
|
||||||
func init(mode, goal: int):
|
|
||||||
game_mode = mode
|
game_mode = mode
|
||||||
if (goal != 0):
|
|
||||||
max_time = goal
|
|
||||||
hide()
|
hide()
|
||||||
|
|
||||||
|
|
||||||
func stop():
|
|
||||||
timer.stop()
|
|
||||||
|
|
||||||
|
|
||||||
func _on_Timer_timeout() -> void:
|
|
||||||
current_time += 1
|
|
||||||
var n = max_time - current_time
|
|
||||||
if n < 0:
|
|
||||||
n = 0
|
|
||||||
update_score(n)
|
|
||||||
if n == 0:
|
|
||||||
Signals.emit_signal("win")
|
|
||||||
timer.stop()
|
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,3 @@ align = 1
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="Timer" type="Timer" parent="."]
|
|
||||||
|
|
||||||
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
|
||||||
|
|
20
mini-game/scenes/decor/startTimerUI.gd
Normal file
20
mini-game/scenes/decor/startTimerUI.gd
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
extends Control
|
||||||
|
|
||||||
|
|
||||||
|
onready var label : Label = $MarginContainer/Label
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
hide()
|
||||||
|
|
||||||
|
|
||||||
|
func update_timer(score: int):
|
||||||
|
if score > 0:
|
||||||
|
label.text = String(score)
|
||||||
|
else:
|
||||||
|
label.text = "GO !"
|
||||||
|
|
||||||
|
|
||||||
|
func init():
|
||||||
|
update_timer(3)
|
||||||
|
show()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[gd_scene load_steps=4 format=2]
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://mini-game/ressources/font/joystix/ot/joystix monospace.otf" type="DynamicFontData" id=1]
|
[ext_resource path="res://mini-game/ressources/font/joystix/ot/joystix monospace.otf" type="DynamicFontData" id=1]
|
||||||
[ext_resource path="res://mini-game/scenes/decor/start_timer_UI.gd" type="Script" id=2]
|
[ext_resource path="res://mini-game/scenes/decor/startTimerUI.gd" type="Script" id=2]
|
||||||
|
|
||||||
[sub_resource type="DynamicFont" id=1]
|
[sub_resource type="DynamicFont" id=1]
|
||||||
size = 200
|
size = 200
|
||||||
|
@ -9,7 +9,7 @@ outline_size = 20
|
||||||
outline_color = Color( 0, 0, 0, 1 )
|
outline_color = Color( 0, 0, 0, 1 )
|
||||||
font_data = ExtResource( 1 )
|
font_data = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="start_timer_UI" type="Control"]
|
[node name="startTimerUI" type="Control"]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
margin_right = 0.00012207
|
margin_right = 0.00012207
|
|
@ -1,18 +0,0 @@
|
||||||
extends Control
|
|
||||||
|
|
||||||
|
|
||||||
onready var label : Label = $MarginContainer/Label
|
|
||||||
|
|
||||||
func _ready():
|
|
||||||
Signals.connect("update_timer",self,"update_timer")
|
|
||||||
hide()
|
|
||||||
|
|
||||||
|
|
||||||
func update_timer(score: String):
|
|
||||||
label.text = score
|
|
||||||
|
|
||||||
|
|
||||||
func init():
|
|
||||||
update_timer(String(3))
|
|
||||||
show()
|
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
[gd_scene load_steps=4 format=2]
|
|
||||||
|
|
||||||
[ext_resource path="res://mini-game/scripts/ScrollingBG.gd" type="Script" id=1]
|
|
||||||
|
|
||||||
[sub_resource type="Shader" id=1]
|
|
||||||
code = "shader_type canvas_item;
|
|
||||||
|
|
||||||
uniform float scroll_speed;
|
|
||||||
|
|
||||||
void fragment(){
|
|
||||||
vec2 u = UV;
|
|
||||||
u.x += scroll_speed*TIME;
|
|
||||||
vec4 color = texture(TEXTURE,u);
|
|
||||||
COLOR = color;
|
|
||||||
}
|
|
||||||
"
|
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id=2]
|
|
||||||
shader = SubResource( 1 )
|
|
||||||
shader_param/scroll_speed = 0.2
|
|
||||||
|
|
||||||
[node name="ScrollingBG" type="TextureRect"]
|
|
||||||
material = SubResource( 2 )
|
|
||||||
stretch_mode = 2
|
|
||||||
script = ExtResource( 1 )
|
|
||||||
__meta__ = {
|
|
||||||
"_edit_use_anchors_": false
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
[gd_scene format=2]
|
|
||||||
|
|
||||||
[node name="collision_obstacle" type="Area2D"]
|
|
|
@ -1,3 +0,0 @@
|
||||||
[gd_scene format=2]
|
|
||||||
|
|
||||||
[node name="pick_bonus" type="Area2D"]
|
|
|
@ -1,24 +1,5 @@
|
||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://mini-game/scripts/obstacle1.gd" type="Script" id=1]
|
[ext_resource path="res://mini-game/scenes/spawner/pickup.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://mini-game/ressources/sprites/obstacle/barrel.png" type="Texture" id=2]
|
|
||||||
[ext_resource path="res://mini-game/scenes/effets/collision_obstacle.tscn" type="PackedScene" id=3]
|
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[node name="obstacle2" instance=ExtResource( 1 )]
|
||||||
extents = Vector2( 28.3542, 36.1379 )
|
|
||||||
|
|
||||||
[node name="obstacle1" type="Node2D"]
|
|
||||||
script = ExtResource( 1 )
|
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="."]
|
|
||||||
scale = Vector2( 0.202437, 0.202437 )
|
|
||||||
texture = ExtResource( 2 )
|
|
||||||
|
|
||||||
[node name="collision_obstacle" parent="." instance=ExtResource( 3 )]
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="collision_obstacle"]
|
|
||||||
shape = SubResource( 1 )
|
|
||||||
|
|
||||||
[node name="notifier" type="VisibilityNotifier2D" parent="."]
|
|
||||||
|
|
||||||
[connection signal="body_entered" from="collision_obstacle" to="." method="_on_collision_obstacle_body_entered"]
|
|
||||||
|
|
|
@ -1,26 +1,7 @@
|
||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://mini-game/scripts/obstacle1.gd" type="Script" id=1]
|
[ext_resource path="res://mini-game/scenes/spawner/pickup.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://mini-game/ressources/sprites/obstacle/malus_enveloppe.png" type="Texture" id=2]
|
[ext_resource path="res://mini-game/ressources/sprites/obstacle/malus_enveloppe.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://mini-game/scenes/effets/collision_obstacle.tscn" type="PackedScene" id=3]
|
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[node name="obstacle2" instance=ExtResource( 1 )]
|
||||||
extents = Vector2( 46.8347, 33.7529 )
|
sprite_texture = ExtResource( 2 )
|
||||||
|
|
||||||
[node name="obstacle2" type="Node2D"]
|
|
||||||
script = ExtResource( 1 )
|
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="."]
|
|
||||||
position = Vector2( -0.0556164, -0.166861 )
|
|
||||||
scale = Vector2( 0.2, 0.2 )
|
|
||||||
texture = ExtResource( 2 )
|
|
||||||
|
|
||||||
[node name="collision_obstacle" parent="." instance=ExtResource( 3 )]
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="collision_obstacle"]
|
|
||||||
shape = SubResource( 1 )
|
|
||||||
|
|
||||||
[node name="notifier" type="VisibilityNotifier2D" parent="."]
|
|
||||||
position = Vector2( -0.333708, -0.333708 )
|
|
||||||
scale = Vector2( 4.70418, 3.36934 )
|
|
||||||
[connection signal="body_entered" from="collision_obstacle" to="." method="_on_collision_obstacle_body_entered"]
|
|
||||||
|
|
|
@ -1,25 +1,7 @@
|
||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://mini-game/scripts/obstacle1.gd" type="Script" id=1]
|
[ext_resource path="res://mini-game/scenes/spawner/pickup.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://mini-game/ressources/sprites/obstacle/telephoneconference.png" type="Texture" id=2]
|
[ext_resource path="res://mini-game/ressources/sprites/obstacle/telephoneconference.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://mini-game/scenes/effets/collision_obstacle.tscn" type="PackedScene" id=3]
|
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[node name="obstacle3" instance=ExtResource( 1 )]
|
||||||
extents = Vector2( 25.3346, 58.4363 )
|
sprite_texture = ExtResource( 2 )
|
||||||
|
|
||||||
[node name="obstacle3" type="Node2D"]
|
|
||||||
script = ExtResource( 1 )
|
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="."]
|
|
||||||
position = Vector2( 1.45743, -10.024 )
|
|
||||||
scale = Vector2( 0.0703989, 0.0703989 )
|
|
||||||
texture = ExtResource( 2 )
|
|
||||||
|
|
||||||
[node name="collision_obstacle" parent="." instance=ExtResource( 3 )]
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="collision_obstacle"]
|
|
||||||
position = Vector2( -1.33633, 0 )
|
|
||||||
shape = SubResource( 1 )
|
|
||||||
|
|
||||||
[node name="notifier" type="VisibilityNotifier2D" parent="."]
|
|
||||||
[connection signal="body_entered" from="collision_obstacle" to="." method="_on_collision_obstacle_body_entered"]
|
|
||||||
|
|
|
@ -1,25 +1,7 @@
|
||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://mini-game/scripts/obstacle1.gd" type="Script" id=1]
|
[ext_resource path="res://mini-game/scenes/spawner/pickup.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://mini-game/ressources/sprites/obstacle/telephoneflamme.png" type="Texture" id=2]
|
[ext_resource path="res://mini-game/ressources/sprites/obstacle/telephoneflamme.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://mini-game/scenes/effets/collision_obstacle.tscn" type="PackedScene" id=3]
|
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[node name="obstacle4" instance=ExtResource( 1 )]
|
||||||
extents = Vector2( 24.4662, 65.2837 )
|
sprite_texture = ExtResource( 2 )
|
||||||
|
|
||||||
[node name="obstacle4" type="Node2D"]
|
|
||||||
script = ExtResource( 1 )
|
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="."]
|
|
||||||
position = Vector2( 0.832382, -16.9321 )
|
|
||||||
scale = Vector2( 0.0711866, 0.0711866 )
|
|
||||||
texture = ExtResource( 2 )
|
|
||||||
|
|
||||||
[node name="collision_obstacle" parent="." instance=ExtResource( 3 )]
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="collision_obstacle"]
|
|
||||||
position = Vector2( 1.08099, -1.5749 )
|
|
||||||
shape = SubResource( 1 )
|
|
||||||
|
|
||||||
[node name="notifier" type="VisibilityNotifier2D" parent="."]
|
|
||||||
[connection signal="body_entered" from="collision_obstacle" to="." method="_on_collision_obstacle_body_entered"]
|
|
||||||
|
|
|
@ -1,28 +1,7 @@
|
||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://mini-game/scripts/obstacle1.gd" type="Script" id=1]
|
[ext_resource path="res://mini-game/scenes/spawner/pickup.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://mini-game/ressources/sprites/obstacle/dessin.png" type="Texture" id=2]
|
[ext_resource path="res://mini-game/ressources/sprites/obstacle/dessin.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://mini-game/scenes/effets/collision_obstacle.tscn" type="PackedScene" id=3]
|
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[node name="obstacle5" instance=ExtResource( 1 )]
|
||||||
extents = Vector2( 25.9509, 82.5121 )
|
sprite_texture = ExtResource( 2 )
|
||||||
|
|
||||||
[node name="obstacle5" type="Node2D"]
|
|
||||||
script = ExtResource( 1 )
|
|
||||||
__meta__ = {
|
|
||||||
"_edit_horizontal_guides_": [ ]
|
|
||||||
}
|
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="."]
|
|
||||||
position = Vector2( -0.582159, -32.5956 )
|
|
||||||
scale = Vector2( 0.073, 0.073 )
|
|
||||||
texture = ExtResource( 2 )
|
|
||||||
|
|
||||||
[node name="collision_obstacle" parent="." instance=ExtResource( 3 )]
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="collision_obstacle"]
|
|
||||||
position = Vector2( -1.05112, 3.99426 )
|
|
||||||
shape = SubResource( 1 )
|
|
||||||
|
|
||||||
[node name="notifier" type="VisibilityNotifier2D" parent="."]
|
|
||||||
[connection signal="body_entered" from="collision_obstacle" to="." method="_on_collision_obstacle_body_entered"]
|
|
||||||
|
|
93
mini-game/scenes/players/player.gd
Normal file
93
mini-game/scenes/players/player.gd
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
extends KinematicBody2D
|
||||||
|
|
||||||
|
var speed = Vector2.ZERO
|
||||||
|
|
||||||
|
export var jump_speed = 1100.0
|
||||||
|
export var gravity = 45.0
|
||||||
|
export var max_lives = 1
|
||||||
|
|
||||||
|
enum {
|
||||||
|
RUN,
|
||||||
|
JUMP,
|
||||||
|
IDLE
|
||||||
|
}
|
||||||
|
|
||||||
|
enum {
|
||||||
|
SCORE,
|
||||||
|
TIME
|
||||||
|
}
|
||||||
|
|
||||||
|
var jump_key = "dialogic_next"
|
||||||
|
|
||||||
|
var player_enabled = false
|
||||||
|
|
||||||
|
var state = RUN
|
||||||
|
var au_sol = true
|
||||||
|
|
||||||
|
var current_lives = max_lives
|
||||||
|
|
||||||
|
onready var animation = $AnimatedSprite
|
||||||
|
|
||||||
|
signal hit()
|
||||||
|
signal die()
|
||||||
|
signal score()
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
stop()
|
||||||
|
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
if player_enabled:
|
||||||
|
match state:
|
||||||
|
RUN:
|
||||||
|
animation.play("man_run")
|
||||||
|
JUMP:
|
||||||
|
speed = Vector2.ZERO
|
||||||
|
speed.y -= jump_speed
|
||||||
|
animation.play("man_jump")
|
||||||
|
state = IDLE
|
||||||
|
IDLE:
|
||||||
|
pass
|
||||||
|
speed.y += gravity
|
||||||
|
move_and_collide(speed*delta)
|
||||||
|
|
||||||
|
|
||||||
|
func _input(event):
|
||||||
|
if player_enabled and state == RUN and event.is_action_pressed(jump_key):
|
||||||
|
state = JUMP
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Area2D_body_entered(body):
|
||||||
|
if body is StaticBody2D:
|
||||||
|
state = RUN
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Area2D_body_exited(body):
|
||||||
|
if body is StaticBody2D:
|
||||||
|
state = JUMP
|
||||||
|
|
||||||
|
|
||||||
|
func start():
|
||||||
|
show()
|
||||||
|
player_enabled = true
|
||||||
|
|
||||||
|
|
||||||
|
func stop():
|
||||||
|
hide()
|
||||||
|
player_enabled = false
|
||||||
|
|
||||||
|
|
||||||
|
func hit():
|
||||||
|
print("hit")
|
||||||
|
current_lives -= 1
|
||||||
|
if current_lives > 0:
|
||||||
|
emit_signal("hit")
|
||||||
|
else:
|
||||||
|
current_lives = 0
|
||||||
|
emit_signal("die")
|
||||||
|
|
||||||
|
|
||||||
|
func bonus():
|
||||||
|
print("bonus")
|
||||||
|
emit_signal("score")
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
[ext_resource path="res://mini-game/ressources/sprites/player/dino/dino_run6.png" type="Texture" id=3]
|
[ext_resource path="res://mini-game/ressources/sprites/player/dino/dino_run6.png" type="Texture" id=3]
|
||||||
[ext_resource path="res://mini-game/ressources/sprites/player/dino/dino_run3.png" type="Texture" id=4]
|
[ext_resource path="res://mini-game/ressources/sprites/player/dino/dino_run3.png" type="Texture" id=4]
|
||||||
[ext_resource path="res://mini-game/ressources/sprites/player/dino/dino_jump2.png" type="Texture" id=5]
|
[ext_resource path="res://mini-game/ressources/sprites/player/dino/dino_jump2.png" type="Texture" id=5]
|
||||||
[ext_resource path="res://mini-game/scripts/player2.gd" type="Script" id=6]
|
[ext_resource path="res://mini-game/scenes/players/player.gd" type="Script" id=6]
|
||||||
[ext_resource path="res://mini-game/ressources/sprites/player/dino/dino_run0.png" type="Texture" id=7]
|
[ext_resource path="res://mini-game/ressources/sprites/player/dino/dino_run0.png" type="Texture" id=7]
|
||||||
[ext_resource path="res://mini-game/ressources/sprites/player/dino/dino_run4.png" type="Texture" id=8]
|
[ext_resource path="res://mini-game/ressources/sprites/player/dino/dino_run4.png" type="Texture" id=8]
|
||||||
[ext_resource path="res://mini-game/ressources/sprites/player/dino/dino_run2.png" type="Texture" id=9]
|
[ext_resource path="res://mini-game/ressources/sprites/player/dino/dino_run2.png" type="Texture" id=9]
|
||||||
|
@ -51,11 +51,9 @@ extents = Vector2( 4.46927, 10.285 )
|
||||||
[sub_resource type="RectangleShape2D" id=3]
|
[sub_resource type="RectangleShape2D" id=3]
|
||||||
extents = Vector2( 7.82863, 6.33675 )
|
extents = Vector2( 7.82863, 6.33675 )
|
||||||
|
|
||||||
[node name="player2" type="KinematicBody2D"]
|
[node name="player" type="KinematicBody2D"]
|
||||||
scale = Vector2( 10, 10 )
|
scale = Vector2( 10, 10 )
|
||||||
script = ExtResource( 6 )
|
script = ExtResource( 6 )
|
||||||
jump_vitesse = 1000.0
|
|
||||||
gravite = 40.0
|
|
||||||
|
|
||||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||||
position = Vector2( -1.76303, -0.98938 )
|
position = Vector2( -1.76303, -0.98938 )
|
||||||
|
@ -64,7 +62,7 @@ frames = SubResource( 1 )
|
||||||
animation = "man_jump"
|
animation = "man_jump"
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
position = Vector2( -0.0396851, -0.480505 )
|
position = Vector2( -0.0396847, -0.480505 )
|
||||||
shape = SubResource( 2 )
|
shape = SubResource( 2 )
|
||||||
|
|
||||||
[node name="Area2D" type="Area2D" parent="."]
|
[node name="Area2D" type="Area2D" parent="."]
|
|
@ -1,6 +0,0 @@
|
||||||
[gd_scene load_steps=2 format=2]
|
|
||||||
|
|
||||||
[ext_resource path="res://mini-game/scripts/player1.gd" type="Script" id=1]
|
|
||||||
|
|
||||||
[node name="player1" type="Node2D"]
|
|
||||||
script = ExtResource( 1 )
|
|
42
mini-game/scenes/spawner/pickup.gd
Normal file
42
mini-game/scenes/spawner/pickup.gd
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
export var sprite_texture : Texture
|
||||||
|
export var type := "bonus" setget , get_type
|
||||||
|
export var scroll_speed = 9
|
||||||
|
|
||||||
|
onready var sprite = $Sprite
|
||||||
|
onready var notifier = $notifier
|
||||||
|
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
sprite.texture = sprite_texture
|
||||||
|
notifier.connect("screen_exited", self, "_on_screen_exited")
|
||||||
|
|
||||||
|
|
||||||
|
func _on_screen_exited():
|
||||||
|
queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
move()
|
||||||
|
|
||||||
|
|
||||||
|
func get_type():
|
||||||
|
return type
|
||||||
|
|
||||||
|
|
||||||
|
func move():
|
||||||
|
self.position.x -= scroll_speed
|
||||||
|
|
||||||
|
|
||||||
|
func pickup():
|
||||||
|
queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Area2D_body_entered(body: Node) -> void:
|
||||||
|
if body.has_method("bonus") and body.has_method("hit"):
|
||||||
|
pickup()
|
||||||
|
if type == "bonus":
|
||||||
|
body.bonus()
|
||||||
|
elif type == "malus":
|
||||||
|
body.hit()
|
24
mini-game/scenes/spawner/pickup.tscn
Normal file
24
mini-game/scenes/spawner/pickup.tscn
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://mini-game/ressources/sprites/obstacle/barrel.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://mini-game/scenes/spawner/pickup.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
|
extents = Vector2( 28.3542, 36.1379 )
|
||||||
|
|
||||||
|
[node name="pickup" type="Node2D"]
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
sprite_texture = ExtResource( 1 )
|
||||||
|
type = "malus"
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
|
scale = Vector2( 0.202437, 0.202437 )
|
||||||
|
|
||||||
|
[node name="Area2D" type="Area2D" parent="."]
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="notifier" type="VisibilityNotifier2D" parent="."]
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]
|
51
mini-game/scenes/spawner/spawner.gd
Normal file
51
mini-game/scenes/spawner/spawner.gd
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
export (Array,PackedScene) var scenes
|
||||||
|
|
||||||
|
var random_scene = RandomNumberGenerator.new()
|
||||||
|
var scene_index = 0;
|
||||||
|
var last_object
|
||||||
|
var end_of_game = false
|
||||||
|
var timer_speed = 0.99
|
||||||
|
var random_threshold = 50
|
||||||
|
var scenes_offset = 0
|
||||||
|
|
||||||
|
onready var timer := $Timer
|
||||||
|
onready var items := $items
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Timer_timeout():
|
||||||
|
random_scene.randomize()
|
||||||
|
scene_index = random_scene.randi_range(1,100)
|
||||||
|
if(scene_index >= random_threshold):
|
||||||
|
scene_index = 1
|
||||||
|
else:
|
||||||
|
scene_index = 0
|
||||||
|
var tmp = scenes[scene_index+scenes_offset*2].instance()
|
||||||
|
items.add_child(tmp)
|
||||||
|
last_object = tmp
|
||||||
|
if(timer.wait_time <= 1):
|
||||||
|
timer.wait_time = 1
|
||||||
|
else:
|
||||||
|
timer.wait_time *= timer_speed
|
||||||
|
|
||||||
|
|
||||||
|
func start(difficulty, version):
|
||||||
|
match difficulty:
|
||||||
|
"easy":
|
||||||
|
timer_speed = 0.99
|
||||||
|
random_threshold = 50
|
||||||
|
"hard":
|
||||||
|
timer_speed = 0.95
|
||||||
|
random_threshold = 33
|
||||||
|
_:
|
||||||
|
pass
|
||||||
|
scenes_offset = version
|
||||||
|
timer.start()
|
||||||
|
|
||||||
|
|
||||||
|
func stop():
|
||||||
|
timer.stop()
|
||||||
|
for obj in $items.get_children():
|
||||||
|
remove_child(obj)
|
||||||
|
obj.queue_free()
|
|
@ -1,6 +1,6 @@
|
||||||
[gd_scene load_steps=12 format=2]
|
[gd_scene load_steps=12 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://mini-game/scripts/spawner.gd" type="Script" id=1]
|
[ext_resource path="res://mini-game/scenes/spawner/spawner.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://mini-game/scenes/obstacles/obstacle1.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://mini-game/scenes/obstacles/obstacle1.tscn" type="PackedScene" id=2]
|
||||||
[ext_resource path="res://mini-game/scenes/bonuses/bonus1.tscn" type="PackedScene" id=3]
|
[ext_resource path="res://mini-game/scenes/bonuses/bonus1.tscn" type="PackedScene" id=3]
|
||||||
[ext_resource path="res://mini-game/scenes/bonuses/bonus2.tscn" type="PackedScene" id=4]
|
[ext_resource path="res://mini-game/scenes/bonuses/bonus2.tscn" type="PackedScene" id=4]
|
||||||
|
@ -18,7 +18,6 @@ scenes = [ ExtResource( 3 ), ExtResource( 2 ), ExtResource( 4 ), ExtResource( 5
|
||||||
|
|
||||||
[node name="Timer" type="Timer" parent="."]
|
[node name="Timer" type="Timer" parent="."]
|
||||||
wait_time = 2.094
|
wait_time = 2.094
|
||||||
autostart = true
|
|
||||||
|
|
||||||
[node name="items" type="Node2D" parent="."]
|
[node name="items" type="Node2D" parent="."]
|
||||||
|
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
extends TextureRect
|
|
||||||
|
|
||||||
|
|
||||||
# Declare member variables here. Examples:
|
|
||||||
# var a = 2
|
|
||||||
# var b = "text"
|
|
||||||
|
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
|
||||||
|
|
||||||
func _ready():
|
|
||||||
Signals.connect("die",self,"game_over")
|
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
||||||
#func _process(delta):
|
|
||||||
# pass
|
|
||||||
func game_over():
|
|
||||||
material.set_shader_param("scroll_speed",0)
|
|
|
@ -1,9 +0,0 @@
|
||||||
extends Node2D
|
|
||||||
|
|
||||||
signal die
|
|
||||||
signal gain
|
|
||||||
signal update_score
|
|
||||||
signal update_timer
|
|
||||||
signal win
|
|
||||||
|
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
extends "scroll_movement.gd"
|
|
||||||
|
|
||||||
|
|
||||||
onready var notifier = $notifier
|
|
||||||
|
|
||||||
func _ready():
|
|
||||||
notifier.connect("screen_exited", self, "_on_screen_exited")
|
|
||||||
|
|
||||||
func _on_screen_exited():
|
|
||||||
queue_free()
|
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta):
|
|
||||||
move()
|
|
||||||
|
|
||||||
|
|
||||||
func _on_pick_bonus_body_entered(body):
|
|
||||||
if body.name == "player2" :
|
|
||||||
Signals.emit_signal("gain",1)
|
|
||||||
queue_free()
|
|
|
@ -1,22 +0,0 @@
|
||||||
extends "scroll_movement.gd"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
onready var notifier = $notifier
|
|
||||||
|
|
||||||
func _ready():
|
|
||||||
get_node("notifier").connect("screen_exited", self, "_on_screen_exited")
|
|
||||||
|
|
||||||
func _on_screen_exited():
|
|
||||||
print("Obstacle exited the screen")
|
|
||||||
queue_free()
|
|
||||||
|
|
||||||
func _physics_process(delta):
|
|
||||||
move()
|
|
||||||
|
|
||||||
|
|
||||||
func _on_collision_obstacle_body_entered(body):
|
|
||||||
if body.name == "player2" :
|
|
||||||
Signals.emit_signal("die")
|
|
||||||
queue_free()
|
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
extends Node2D
|
|
||||||
|
|
||||||
|
|
||||||
# Declare member variables here. Examples:
|
|
||||||
# var a = 2
|
|
||||||
# var b = "text"
|
|
||||||
onready var animation = $AnimatedSprite
|
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
|
||||||
func _ready():
|
|
||||||
animation.play("run")
|
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
||||||
#func _process(delta):
|
|
||||||
# pass
|
|
|
@ -1,111 +0,0 @@
|
||||||
extends KinematicBody2D
|
|
||||||
|
|
||||||
var vitesse = Vector2.ZERO
|
|
||||||
|
|
||||||
var score = 0
|
|
||||||
var score_goal = 10
|
|
||||||
|
|
||||||
export var jump_vitesse = 1100.0
|
|
||||||
export var gravite = 45.0
|
|
||||||
|
|
||||||
enum {
|
|
||||||
RUN,
|
|
||||||
JUMP,
|
|
||||||
IDLE
|
|
||||||
}
|
|
||||||
|
|
||||||
enum {
|
|
||||||
SCORE,
|
|
||||||
TIME
|
|
||||||
}
|
|
||||||
|
|
||||||
var jump_key = "dialogic_next"
|
|
||||||
|
|
||||||
var player_enabled = false
|
|
||||||
var game_mode = "score"
|
|
||||||
|
|
||||||
var state = RUN
|
|
||||||
var au_sol = true
|
|
||||||
|
|
||||||
# Declare member variables here. Examples:
|
|
||||||
# var a = 2
|
|
||||||
# var b = "text"
|
|
||||||
onready var animation = $AnimatedSprite
|
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
|
||||||
func _ready():
|
|
||||||
stop()
|
|
||||||
Signals.connect("gain",self,"increase_score")
|
|
||||||
Signals.connect("die",self,"player_die")
|
|
||||||
|
|
||||||
func _physics_process(delta):
|
|
||||||
if player_enabled:
|
|
||||||
match state:
|
|
||||||
RUN:
|
|
||||||
animation.play("man_run")
|
|
||||||
JUMP:
|
|
||||||
vitesse = Vector2.ZERO
|
|
||||||
vitesse.y -= jump_vitesse
|
|
||||||
animation.play("man_jump")
|
|
||||||
state = IDLE
|
|
||||||
IDLE:
|
|
||||||
pass
|
|
||||||
vitesse.y += gravite
|
|
||||||
move_and_collide(vitesse*delta)
|
|
||||||
|
|
||||||
|
|
||||||
func _input(event):
|
|
||||||
if player_enabled and state == RUN and event.is_action_pressed(jump_key):
|
|
||||||
state = JUMP
|
|
||||||
|
|
||||||
|
|
||||||
func _on_Area2D_body_entered(body):
|
|
||||||
if body is StaticBody2D:
|
|
||||||
state = RUN
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _on_Area2D_body_exited(body):
|
|
||||||
if body is StaticBody2D:
|
|
||||||
state = JUMP
|
|
||||||
|
|
||||||
|
|
||||||
func increase_score(scoretoadd):
|
|
||||||
match game_mode:
|
|
||||||
"score":
|
|
||||||
score+=scoretoadd
|
|
||||||
Signals.emit_signal("update_score", score)
|
|
||||||
if score >= score_goal:
|
|
||||||
Signals.emit_signal("win")
|
|
||||||
"time":
|
|
||||||
pass
|
|
||||||
_:
|
|
||||||
print("game_mode not recognized by player2 start func")
|
|
||||||
|
|
||||||
|
|
||||||
func player_win():
|
|
||||||
stop()
|
|
||||||
|
|
||||||
|
|
||||||
func player_die():
|
|
||||||
stop()
|
|
||||||
|
|
||||||
|
|
||||||
func start(mode: String, goal: int):
|
|
||||||
show()
|
|
||||||
match mode:
|
|
||||||
"score":
|
|
||||||
if (goal != 0):
|
|
||||||
score_goal = goal
|
|
||||||
game_mode = "score"
|
|
||||||
"time":
|
|
||||||
game_mode = "time"
|
|
||||||
_:
|
|
||||||
print("game_mode not recognized by player2 start func")
|
|
||||||
score = 0
|
|
||||||
player_enabled = true
|
|
||||||
|
|
||||||
|
|
||||||
func stop():
|
|
||||||
hide()
|
|
||||||
player_enabled = false
|
|
|
@ -1,14 +0,0 @@
|
||||||
extends Node2D
|
|
||||||
|
|
||||||
#export var scroll_speed = 6.3
|
|
||||||
export var scroll_speed = 9
|
|
||||||
|
|
||||||
func _ready():
|
|
||||||
Signals.connect("die",self,"game_over")
|
|
||||||
|
|
||||||
func move():
|
|
||||||
self.position.x -= scroll_speed
|
|
||||||
|
|
||||||
func game_over():
|
|
||||||
print("game_over")
|
|
||||||
scroll_speed = 0
|
|
|
@ -1,64 +0,0 @@
|
||||||
extends Node2D
|
|
||||||
|
|
||||||
export (Array,PackedScene) var scenes
|
|
||||||
|
|
||||||
var random_scene = RandomNumberGenerator.new()
|
|
||||||
var scene_index = 0;
|
|
||||||
var last_object
|
|
||||||
var end_of_game = false
|
|
||||||
var spawner_enabled = false
|
|
||||||
var timer_speed = 0.99
|
|
||||||
var random_threshold = 50
|
|
||||||
var scenes_offset = 0
|
|
||||||
|
|
||||||
onready var timer := $Timer
|
|
||||||
onready var items := $items
|
|
||||||
|
|
||||||
func _ready():
|
|
||||||
Signals.connect("die",self,"game_over")
|
|
||||||
Signals.connect("win",self,"game_over")
|
|
||||||
|
|
||||||
|
|
||||||
func _on_Timer_timeout():
|
|
||||||
if spawner_enabled:
|
|
||||||
random_scene.randomize()
|
|
||||||
scene_index = random_scene.randi_range(1,100)
|
|
||||||
if(scene_index >= random_threshold):
|
|
||||||
scene_index = 1
|
|
||||||
else:
|
|
||||||
scene_index = 0
|
|
||||||
var tmp = scenes[scene_index+scenes_offset*2].instance()
|
|
||||||
items.add_child(tmp)
|
|
||||||
last_object = tmp
|
|
||||||
if(timer.wait_time <= 1):
|
|
||||||
timer.wait_time = 1
|
|
||||||
else:
|
|
||||||
timer.wait_time *= timer_speed
|
|
||||||
timer.start()
|
|
||||||
|
|
||||||
|
|
||||||
func game_over():
|
|
||||||
timer.set_paused(true)
|
|
||||||
#last_object.queue_free()
|
|
||||||
|
|
||||||
|
|
||||||
func start(difficulty, version):
|
|
||||||
match difficulty:
|
|
||||||
"easy":
|
|
||||||
timer_speed = 0.99
|
|
||||||
random_threshold = 50
|
|
||||||
"hard":
|
|
||||||
timer_speed = 0.95
|
|
||||||
random_threshold = 33
|
|
||||||
_:
|
|
||||||
pass
|
|
||||||
scenes_offset = version
|
|
||||||
spawner_enabled = true
|
|
||||||
timer.set_paused(false)
|
|
||||||
|
|
||||||
|
|
||||||
func stop():
|
|
||||||
spawner_enabled = false
|
|
||||||
for obj in $items.get_children():
|
|
||||||
remove_child(obj)
|
|
||||||
obj.queue_free()
|
|
Loading…
Reference in a new issue