Compare commits

..

No commits in common. "1af9952b43a9050ed97e27fcb1f1e23dc3c50d39" and "7e00d5a05475e98b884dc9d74e741bd0f37dcf80" have entirely different histories.

12 changed files with 125 additions and 162 deletions

View file

@ -1,45 +0,0 @@
extends Node2D
signal game_over
onready var background := $background
onready var foreground := $foreground
onready var spawner := $spawner
onready var player := $player2
onready var scoreUI := $scoreUI
var next_timeline := ""
func _ready():
Signals.connect("die", self, "on_game_over")
func setup(mode: String, next: String):
print("minigame: " + mode + " " + next)
set_mode(mode)
next_timeline = next
func set_mode(mode: String):
match mode:
_:
print("unkonwn mini-game mode")
func start():
print("starting minigame")
foreground.start()
player.start()
spawner.start()
func stop():
foreground.stop()
player.stop()
spawner.stop()
func on_game_over():
stop()
emit_signal("game_over", next_timeline)

View file

@ -1,9 +0,0 @@
extends Node2D
onready var texture : TextureRect = $TextureRect
func stop():
texture.material.set_shader_param("scroll_speed", 0)
func start():
texture.material.set_shader_param("scroll_speed", 0.2)

View file

@ -1,46 +1,23 @@
[gd_scene load_steps=6 format=2] [gd_scene load_steps=4 format=2]
[ext_resource path="res://mini-game/scenes/decor/foreground.gd" type="Script" id=1] [ext_resource path="res://mini-game/scenes/effets/ScrollingBG.tscn" type="PackedScene" id=1]
[ext_resource path="res://mini-game/ressources/backgrounds/road3.png" type="Texture" id=2] [ext_resource path="res://mini-game/ressources/backgrounds/road3.png" type="Texture" id=2]
[sub_resource type="Shader" id=1] [sub_resource type="RectangleShape2D" 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.0
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 552.889, 78.6175 ) extents = Vector2( 552.889, 78.6175 )
[node name="foreground" type="Node2D"] [node name="foreground" type="Node2D"]
script = ExtResource( 1 )
[node name="TextureRect" type="TextureRect" parent="."] [node name="ScrollingBG" parent="." instance=ExtResource( 1 )]
material = SubResource( 2 ) margin_left = 0.734742
margin_top = -356.0 margin_top = -356.907
margin_right = 1920.0 margin_right = 1920.73
margin_bottom = 723.0 margin_bottom = 723.093
rect_scale = Vector2( 0.533, 0.913 ) rect_scale = Vector2( 0.533041, 0.912837 )
texture = ExtResource( 2 ) texture = ExtResource( 2 )
stretch_mode = 2
__meta__ = {
"_edit_use_anchors_": false,
"_editor_description_": ""
}
[node name="StaticBody2D" type="StaticBody2D" parent="."] [node name="StaticBody2D" type="StaticBody2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"] [node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
position = Vector2( 497.671, 612.885 ) position = Vector2( 497.671, 612.885 )
shape = SubResource( 3 ) shape = SubResource( 1 )

View file

@ -1,11 +0,0 @@
extends Control
onready var label : RichTextLabel = $RichTextLabel
func _ready():
Signals.connect("update_score",self,"update_score")
func update_score(score: int):
label.text = String(score)

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=4 format=2] [gd_scene load_steps=4 format=2]
[ext_resource path="res://mini-game/scenes/decor/scoreUI.gd" type="Script" id=2] [ext_resource path="res://mini-game/scripts/update_score.gd" type="Script" id=1]
[sub_resource type="DynamicFontData" id=1] [sub_resource type="DynamicFontData" id=1]
antialiased = false antialiased = false
@ -12,7 +12,6 @@ outline_color = Color( 0, 0, 0, 1 )
font_data = SubResource( 1 ) font_data = SubResource( 1 )
[node name="scoreUI" type="Control"] [node name="scoreUI" type="Control"]
script = ExtResource( 2 )
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
@ -33,6 +32,7 @@ tab_size = 1
text = "0" text = "0"
fit_content_height = true fit_content_height = true
scroll_active = false scroll_active = false
script = ExtResource( 1 )
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }

View file

@ -1,14 +1,12 @@
[gd_scene load_steps=7 format=2] [gd_scene load_steps=6 format=2]
[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/player2.tscn" type="PackedScene" id=3]
[ext_resource path="res://mini-game/MiniGame.gd" type="Script" id=4]
[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]
[node name="MiniGame" type="Node2D"] [node name="main" type="Node2D"]
script = ExtResource( 4 )
[node name="background" parent="." instance=ExtResource( 1 )] [node name="background" parent="." instance=ExtResource( 1 )]
position = Vector2( 1, -125 ) position = Vector2( 1, -125 )

View file

@ -11,6 +11,4 @@ scenes = [ ExtResource( 3 ), ExtResource( 2 ) ]
[node name="Timer" type="Timer" parent="."] [node name="Timer" type="Timer" parent="."]
wait_time = 2.094 wait_time = 2.094
autostart = true autostart = true
[node name="items" type="Node2D" parent="."]
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"] [connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]

View file

@ -13,8 +13,6 @@ enum {
IDLE IDLE
} }
var player_enabled = false;
var state = RUN var state = RUN
var au_sol = true var au_sol = true
@ -25,56 +23,54 @@ onready var animation = $AnimatedSprite
# 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 _ready(): func _ready():
stop()
Signals.connect("gain",self,"increase_score") Signals.connect("gain",self,"increase_score")
Signals.connect("die",self,"player_die") Signals.connect("die",self,"player_die")
func _physics_process(delta): func _physics_process(delta):
if player_enabled: match state:
match state: RUN:
RUN: animation.play("run")
animation.play("run") JUMP:
JUMP: vitesse = Vector2.ZERO
vitesse = Vector2.ZERO vitesse.y -= jump_vitesse
vitesse.y -= jump_vitesse animation.play("jump")
animation.play("jump") state = IDLE
state = IDLE print("jump")
IDLE: IDLE:
pass pass
vitesse.y += gravite vitesse.y += gravite
move_and_collide(vitesse*delta) move_and_collide(vitesse*delta)
func _input(event): func _input(event):
if player_enabled and state == RUN and event.is_action_pressed("ui_accept"): if state == RUN and event.is_action_pressed("ui_accept"):
state = JUMP state = JUMP
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _on_Area2D_body_entered(body): func _on_Area2D_body_entered(body):
print("landing")
if body is StaticBody2D: if body is StaticBody2D:
print("Yep a dino is landing")
state = RUN state = RUN
func _on_Area2D_body_exited(body): func _on_Area2D_body_exited(body):
print("jumping")
if body is StaticBody2D: if body is StaticBody2D:
print("Yep a dino is jumping")
state = JUMP state = JUMP
func increase_score(scoretoadd): func increase_score(scoretoadd):
score+=scoretoadd score+=scoretoadd
Signals.emit_signal("update_score",score) Signals.emit_signal("update_score",score)
print(score)
func player_die(): func player_die():
stop() queue_free()
func start():
show()
player_enabled = true
func stop():
hide()
player_enabled = false

View file

@ -7,35 +7,20 @@ var scene_index = 0;
var last_object var last_object
var end_of_game = false var end_of_game = false
var spawner_enabled = false
func _ready(): func _ready():
Signals.connect("die",self,"game_over") Signals.connect("die",self,"game_over")
func _on_Timer_timeout(): func _on_Timer_timeout():
if spawner_enabled: random_scene.randomize()
random_scene.randomize() scene_index = random_scene.randi_range(0,scenes.size()-1)
scene_index = random_scene.randi_range(0,scenes.size()-1) print(scene_index)
var tmp = scenes[scene_index].instance() var tmp = scenes[scene_index].instance()
$items.add_child(tmp) add_child_below_node(self,tmp)
last_object = tmp last_object = tmp
self.get_node("Timer").wait_time *= 0.99 self.get_node("Timer").wait_time *= 0.99
self.get_node("Timer").start() self.get_node("Timer").start()
func game_over(): func game_over():
self.get_node("Timer").set_paused(true) self.get_node("Timer").set_paused(true)
last_object.queue_free() last_object.queue_free()
func start():
spawner_enabled = true
func stop():
spawner_enabled = false
for obj in $items.get_children():
remove_child(obj)
obj.queue_free()

View file

@ -0,0 +1,10 @@
extends RichTextLabel
func _ready():
Signals.connect("update_score",self,"update_score")
func update_score(score):
self.text = String(score)

44
tests/NodeTest.gd Normal file
View file

@ -0,0 +1,44 @@
extends Node
onready var _LineNode: LineNode = self.get_node("Line")
var _json_structure = {
"speaker": {
"id": 5,
"emotion": "happy"
},
"scene": {
"id": 2
},
"dialog": {
"message": "plop",
"choices_multiple": [
{
"title": "test",
"conditions": [
{
"id": "coucou",
"value": 5
}
],
"infobox": {
"text": "info info",
"conditions": [
{
"id": "zzzz",
"value": 1
}
]
}
},
{
"title": "cc",
"conditions": []
}
]
}
}
func _on_Button_pressed():
_LineNode.set_text(JSON.print(_json_structure))

20
tests/NodeTest.tscn Normal file
View file

@ -0,0 +1,20 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/Line_Node.tscn" type="PackedScene" id=1]
[ext_resource path="res://tests/NodeTest.gd" type="Script" id=2]
[node name="NodeTest" type="Node"]
script = ExtResource( 2 )
[node name="Line" parent="." instance=ExtResource( 1 )]
[node name="Button" type="Button" parent="."]
margin_left = 378.27
margin_top = 132.451
margin_right = 427.27
margin_bottom = 152.451
text = "LOAD"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="Button" to="." method="_on_Button_pressed"]