From 048d530add125efcb44ed077ba7e81b708962a52 Mon Sep 17 00:00:00 2001 From: Codelta Date: Tue, 30 Nov 2021 16:13:05 +0100 Subject: [PATCH] working trail + candy spawn + boss at spawn + candy types + count points --- assets/bosses/idle/boss-black-idle.png.import | 3 +- assets/bosses/idle/boss-red-idle.png.import | 3 +- assets/candy/candy-icon.svg | 16 ++ assets/candy/candy-icon.svg.import | 35 ++++ assets/candy/mandarin-icon.svg.import | 35 ++++ assets/candy/peanut-icon.svg.import | 35 ++++ project.godot | 52 +++++ src/actors/boss/Boss.gd | 22 +++ src/actors/boss/Boss.tscn | 15 ++ .../boss/spriteFrames/pereFouettard.tres | 35 ++++ src/actors/boss/spriteFrames/stNicolas.tres | 35 ++++ src/actors/candy/candy.gd | 36 +++- src/actors/candy/candy.tscn | 5 +- src/actors/candy/types/mandarinLarge.gd | 14 ++ .../mandarinLarge.tres | 0 src/actors/candy/types/mandarinSmall.gd | 11 ++ .../mandarinSmall.tres | 0 src/actors/candy/types/peanutLarge.gd | 15 ++ .../{spriteFrames => types}/peanutLarge.tres | 0 src/actors/candy/types/peanutSmall.gd | 15 ++ .../{spriteFrames => types}/peanutSmall.tres | 0 src/actors/player/player.gd | 20 +- src/actors/player/player.tscn | 12 +- src/{Game.gd => game.gd} | 80 +++++--- src/{Game.tscn => game.tscn} | 12 +- src/levels/levelDemo/levelDemo.gd | 20 ++ .../levelDemo.tscn} | 180 ++++++++++++------ src/scripts/gamestate.gd | 25 ++- src/scripts/server/candySpawner.gd | 17 -- .../server/candySpawners/CandySpawners.gd | 1 + .../server/candySpawners/CandySpawners.tscn | 1 - src/scripts/server/candySpawners/spawner.gd | 33 ++-- src/scripts/server/trails/Trails.gd | 93 ++++++++- src/scripts/server/trails/Trails.tscn | 2 + src/ui/components/ProgressBar.gd | 20 ++ src/ui/components/ProgressBar.tscn | 58 ++++++ src/ui/game-hud.tscn | 5 +- 37 files changed, 807 insertions(+), 154 deletions(-) create mode 100644 assets/candy/candy-icon.svg create mode 100644 assets/candy/candy-icon.svg.import create mode 100644 assets/candy/mandarin-icon.svg.import create mode 100644 assets/candy/peanut-icon.svg.import create mode 100644 src/actors/boss/Boss.gd create mode 100644 src/actors/boss/Boss.tscn create mode 100644 src/actors/boss/spriteFrames/pereFouettard.tres create mode 100644 src/actors/boss/spriteFrames/stNicolas.tres create mode 100644 src/actors/candy/types/mandarinLarge.gd rename src/actors/candy/{spriteFrames => types}/mandarinLarge.tres (100%) create mode 100644 src/actors/candy/types/mandarinSmall.gd rename src/actors/candy/{spriteFrames => types}/mandarinSmall.tres (100%) create mode 100644 src/actors/candy/types/peanutLarge.gd rename src/actors/candy/{spriteFrames => types}/peanutLarge.tres (100%) create mode 100644 src/actors/candy/types/peanutSmall.gd rename src/actors/candy/{spriteFrames => types}/peanutSmall.tres (100%) rename src/{Game.gd => game.gd} (58%) rename src/{Game.tscn => game.tscn} (61%) create mode 100644 src/levels/levelDemo/levelDemo.gd rename src/levels/{level-demo.tscn => levelDemo/levelDemo.tscn} (93%) delete mode 100644 src/scripts/server/candySpawner.gd create mode 100644 src/ui/components/ProgressBar.gd create mode 100644 src/ui/components/ProgressBar.tscn diff --git a/assets/bosses/idle/boss-black-idle.png.import b/assets/bosses/idle/boss-black-idle.png.import index acb8224..e70bc6b 100644 --- a/assets/bosses/idle/boss-black-idle.png.import +++ b/assets/bosses/idle/boss-black-idle.png.import @@ -20,7 +20,7 @@ compress/hdr_mode=0 compress/bptc_ldr=0 compress/normal_map=0 flags/repeat=0 -flags/filter=true +flags/filter=false flags/mipmaps=false flags/anisotropic=false flags/srgb=2 @@ -28,6 +28,7 @@ process/fix_alpha_border=true process/premult_alpha=false process/HDR_as_SRGB=false process/invert_color=false +process/normal_map_invert_y=false stream=false size_limit=0 detect_3d=true diff --git a/assets/bosses/idle/boss-red-idle.png.import b/assets/bosses/idle/boss-red-idle.png.import index e932aa4..ba60453 100644 --- a/assets/bosses/idle/boss-red-idle.png.import +++ b/assets/bosses/idle/boss-red-idle.png.import @@ -20,7 +20,7 @@ compress/hdr_mode=0 compress/bptc_ldr=0 compress/normal_map=0 flags/repeat=0 -flags/filter=true +flags/filter=false flags/mipmaps=false flags/anisotropic=false flags/srgb=2 @@ -28,6 +28,7 @@ process/fix_alpha_border=true process/premult_alpha=false process/HDR_as_SRGB=false process/invert_color=false +process/normal_map_invert_y=false stream=false size_limit=0 detect_3d=true diff --git a/assets/candy/candy-icon.svg b/assets/candy/candy-icon.svg new file mode 100644 index 0000000..6cb1d00 --- /dev/null +++ b/assets/candy/candy-icon.svg @@ -0,0 +1,16 @@ + + + + + + + \ No newline at end of file diff --git a/assets/candy/candy-icon.svg.import b/assets/candy/candy-icon.svg.import new file mode 100644 index 0000000..625171a --- /dev/null +++ b/assets/candy/candy-icon.svg.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/candy-icon.svg-b0ecad2afa4bc5d345d2a6ee18c96d31.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/candy/candy-icon.svg" +dest_files=[ "res://.import/candy-icon.svg-b0ecad2afa4bc5d345d2a6ee18c96d31.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/assets/candy/mandarin-icon.svg.import b/assets/candy/mandarin-icon.svg.import new file mode 100644 index 0000000..a75555b --- /dev/null +++ b/assets/candy/mandarin-icon.svg.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/mandarin-icon.svg-19bf430e5b349b7fee565c515e46cf10.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/candy/mandarin-icon.svg" +dest_files=[ "res://.import/mandarin-icon.svg-19bf430e5b349b7fee565c515e46cf10.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/assets/candy/peanut-icon.svg.import b/assets/candy/peanut-icon.svg.import new file mode 100644 index 0000000..532e1b0 --- /dev/null +++ b/assets/candy/peanut-icon.svg.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/peanut-icon.svg-3aea6e39c4269dbc4ed342e3fc052a8e.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/candy/peanut-icon.svg" +dest_files=[ "res://.import/peanut-icon.svg-3aea6e39c4269dbc4ed342e3fc052a8e.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/project.godot b/project.godot index 1758683..8c06310 100644 --- a/project.godot +++ b/project.godot @@ -8,6 +8,58 @@ config_version=4 +_global_script_classes=[ { +"base": "Node2D", +"class": "Candy", +"language": "GDScript", +"path": "res://src/actors/candy/candy.gd" +}, { +"base": "Node2D", +"class": "Game", +"language": "GDScript", +"path": "res://src/game.gd" +}, { +"base": "Candy", +"class": "MandarinLarge", +"language": "GDScript", +"path": "res://src/actors/candy/types/mandarinLarge.gd" +}, { +"base": "Candy", +"class": "MandarinSmall", +"language": "GDScript", +"path": "res://src/actors/candy/types/mandarinSmall.gd" +}, { +"base": "Candy", +"class": "PeanutLarge", +"language": "GDScript", +"path": "res://src/actors/candy/types/peanutLarge.gd" +}, { +"base": "Candy", +"class": "PeanutSmall", +"language": "GDScript", +"path": "res://src/actors/candy/types/peanutSmall.gd" +}, { +"base": "KinematicBody2D", +"class": "Player", +"language": "GDScript", +"path": "res://src/actors/player/player.gd" +}, { +"base": "Position2D", +"class": "Spawner", +"language": "GDScript", +"path": "res://src/scripts/server/candySpawners/spawner.gd" +} ] +_global_script_class_icons={ +"Candy": "res://assets/candy/candy-icon.svg", +"Game": "", +"MandarinLarge": "res://assets/candy/mandarin-big.png", +"MandarinSmall": "res://assets/candy/mandarin-small.png", +"PeanutLarge": "res://assets/candy/peanut-big.png", +"PeanutSmall": "res://assets/candy/peanut-small.png", +"Player": "", +"Spawner": "" +} + [application] config/name="schoolboybattle" diff --git a/src/actors/boss/Boss.gd b/src/actors/boss/Boss.gd new file mode 100644 index 0000000..e58fde6 --- /dev/null +++ b/src/actors/boss/Boss.gd @@ -0,0 +1,22 @@ +extends Node2D + + +enum TYPE_E {NICOLAS=0, FOUETTARD=1} + +export(int, "St Nicolas", "Pere Fouettard") var type = TYPE_E.NICOLAS + + +# Called when the node enters the scene tree for the first time. +func _ready(): + var sprite_frames: SpriteFrames + + if type == TYPE_E.FOUETTARD: + sprite_frames = preload("res://src/actors/boss/spriteFrames/pereFouettard.tres") + elif type == TYPE_E.NICOLAS: + sprite_frames = preload("res://src/actors/boss/spriteFrames/stNicolas.tres") + $AnimatedSprite.set_sprite_frames(sprite_frames) + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/src/actors/boss/Boss.tscn b/src/actors/boss/Boss.tscn new file mode 100644 index 0000000..f100859 --- /dev/null +++ b/src/actors/boss/Boss.tscn @@ -0,0 +1,15 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://src/actors/boss/spriteFrames/pereFouettard.tres" type="SpriteFrames" id=1] +[ext_resource path="res://src/actors/boss/Boss.gd" type="Script" id=2] + +[node name="Boss" type="Node2D"] +script = ExtResource( 2 ) + +[node name="AnimatedSprite" type="AnimatedSprite" parent="."] +position = Vector2( 0, -150 ) +scale = Vector2( 10, 10 ) +frames = ExtResource( 1 ) +animation = "idle" +frame = 1 +playing = true diff --git a/src/actors/boss/spriteFrames/pereFouettard.tres b/src/actors/boss/spriteFrames/pereFouettard.tres new file mode 100644 index 0000000..3659f47 --- /dev/null +++ b/src/actors/boss/spriteFrames/pereFouettard.tres @@ -0,0 +1,35 @@ +[gd_resource type="SpriteFrames" load_steps=8 format=2] + +[ext_resource path="res://assets/bosses/idle/boss-black-idle.png" type="Texture" id=1] + +[sub_resource type="AtlasTexture" id=1] +atlas = ExtResource( 1 ) +region = Rect2( 0, 0, 26, 39 ) + +[sub_resource type="AtlasTexture" id=2] +atlas = ExtResource( 1 ) +region = Rect2( 26, 0, 26, 39 ) + +[sub_resource type="AtlasTexture" id=3] +atlas = ExtResource( 1 ) +region = Rect2( 52, 0, 26, 39 ) + +[sub_resource type="AtlasTexture" id=4] +atlas = ExtResource( 1 ) +region = Rect2( 78, 0, 26, 39 ) + +[sub_resource type="AtlasTexture" id=5] +atlas = ExtResource( 1 ) +region = Rect2( 104, 0, 26, 39 ) + +[sub_resource type="AtlasTexture" id=6] +atlas = ExtResource( 1 ) +region = Rect2( 130, 0, 26, 39 ) + +[resource] +animations = [ { +"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ) ], +"loop": true, +"name": "idle", +"speed": 3.0 +} ] diff --git a/src/actors/boss/spriteFrames/stNicolas.tres b/src/actors/boss/spriteFrames/stNicolas.tres new file mode 100644 index 0000000..703b834 --- /dev/null +++ b/src/actors/boss/spriteFrames/stNicolas.tres @@ -0,0 +1,35 @@ +[gd_resource type="SpriteFrames" load_steps=8 format=2] + +[ext_resource path="res://assets/bosses/idle/boss-red-idle.png" type="Texture" id=1] + +[sub_resource type="AtlasTexture" id=1] +atlas = ExtResource( 1 ) +region = Rect2( 0, 0, 26, 39 ) + +[sub_resource type="AtlasTexture" id=2] +atlas = ExtResource( 1 ) +region = Rect2( 26, 0, 26, 39 ) + +[sub_resource type="AtlasTexture" id=3] +atlas = ExtResource( 1 ) +region = Rect2( 52, 0, 26, 39 ) + +[sub_resource type="AtlasTexture" id=4] +atlas = ExtResource( 1 ) +region = Rect2( 78, 0, 26, 39 ) + +[sub_resource type="AtlasTexture" id=5] +atlas = ExtResource( 1 ) +region = Rect2( 104, 0, 26, 39 ) + +[sub_resource type="AtlasTexture" id=6] +atlas = ExtResource( 1 ) +region = Rect2( 130, 0, 26, 39 ) + +[resource] +animations = [ { +"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ) ], +"loop": true, +"name": "idle", +"speed": 3.0 +} ] diff --git a/src/actors/candy/candy.gd b/src/actors/candy/candy.gd index 5fdf631..b3e1df7 100644 --- a/src/actors/candy/candy.gd +++ b/src/actors/candy/candy.gd @@ -1,5 +1,7 @@ extends Node2D +class_name Candy, "res://assets/candy/candy-icon.svg" + """######################################## VARIABLES ########################################""" @@ -9,9 +11,11 @@ var taken_by: KinematicBody2D = null var spawner: Node = null var targeted_position: Vector2 = Vector2.ZERO - puppet var puppet_targeted_pos = Vector2.ZERO +var points: int = 0 +var sprite_frame: SpriteFrames = null + """######################################## INIT @@ -24,7 +28,10 @@ func _init(): # Called when the node enters the scene tree for the first time. func _ready(): - self.puppet_targeted_pos = self.targeted_position + self.puppet_targeted_pos = self.targeted_position + +func set_candy_sprite_frame(sprite_frame: SpriteFrames): + $AnimatedSprite.set_sprite_frames(self.sprite_frame) """######################################## @@ -44,14 +51,17 @@ func _process(delta): self.position = lerp(self.position, self.targeted_position, 0.1) -# Picked up from the ground by a player +# Picked up / stolen by a player func _on_Area2D_body_entered(player): - if not player is KinematicBody2D: - return - + if not player is KinematicBody2D: return + assert(get_tree().is_network_server()) - self.set_collision_player(false) # Doesn't detect every player + if $Area2D.get_collision_mask_bit(0): + # Picked up from the ground + self.set_collision_player(false) # Doesn't detect every player anymore + self.spawner.candy_taken() # Free the spawner for + player.take_candy(self) @@ -67,7 +77,7 @@ func is_taken(): func set_collision_player(value: bool): $Area2D.set_collision_mask_bit(0, value) - + # false -> red / true -> black func set_color_team(is_black: bool): # Set the candy visual color @@ -78,3 +88,13 @@ func set_color_team(is_black: bool): func set_collision_team(is_black: bool): $Area2D.set_collision_mask_bit(3, not is_black) $Area2D.set_collision_mask_bit(4, is_black) + +func delete(): + assert(is_network_master()) + for id in gamestate.get_clients_list(): + rpc_id(id, "delete_candy_client", self.get_name()) + delete_candy_client(self.get_name()) + + +remote func delete_candy_client(candy_name): + self.queue_free() diff --git a/src/actors/candy/candy.tscn b/src/actors/candy/candy.tscn index 4d38c48..2cbf215 100644 --- a/src/actors/candy/candy.tscn +++ b/src/actors/candy/candy.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=2] [ext_resource path="res://src/actors/candy/candy.gd" type="Script" id=1] -[ext_resource path="res://src/actors/candy/spriteFrames/mandarinSmall.tres" type="SpriteFrames" id=2] +[ext_resource path="res://src/actors/candy/types/mandarinSmall.tres" type="SpriteFrames" id=2] [sub_resource type="CircleShape2D" id=1] radius = 56.0357 @@ -13,10 +13,11 @@ script = ExtResource( 1 ) scale = Vector2( 10, 10 ) frames = ExtResource( 2 ) animation = "idle" -frame = 5 +frame = 4 playing = true [node name="Area2D" type="Area2D" parent="."] +visible = false collision_layer = 2 collision_mask = 0 diff --git a/src/actors/candy/types/mandarinLarge.gd b/src/actors/candy/types/mandarinLarge.gd new file mode 100644 index 0000000..f631762 --- /dev/null +++ b/src/actors/candy/types/mandarinLarge.gd @@ -0,0 +1,14 @@ +extends Candy + +class_name MandarinLarge, "res://assets/candy/mandarin-big.png" + +# 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(): + points = 15 + sprite_frame = load("res://src/actors/candy/types/mandarinLarge.tres") + set_candy_sprite_frame(sprite_frame) diff --git a/src/actors/candy/spriteFrames/mandarinLarge.tres b/src/actors/candy/types/mandarinLarge.tres similarity index 100% rename from src/actors/candy/spriteFrames/mandarinLarge.tres rename to src/actors/candy/types/mandarinLarge.tres diff --git a/src/actors/candy/types/mandarinSmall.gd b/src/actors/candy/types/mandarinSmall.gd new file mode 100644 index 0000000..1bb7929 --- /dev/null +++ b/src/actors/candy/types/mandarinSmall.gd @@ -0,0 +1,11 @@ +extends Candy + +class_name MandarinSmall, "res://assets/candy/mandarin-small.png" + + +# Called when the node enters the scene tree for the first time. +func _ready(): + points = 5 + sprite_frame = load("res://src/actors/candy/types/mandarinSmall.tres") + set_candy_sprite_frame(sprite_frame) + diff --git a/src/actors/candy/spriteFrames/mandarinSmall.tres b/src/actors/candy/types/mandarinSmall.tres similarity index 100% rename from src/actors/candy/spriteFrames/mandarinSmall.tres rename to src/actors/candy/types/mandarinSmall.tres diff --git a/src/actors/candy/types/peanutLarge.gd b/src/actors/candy/types/peanutLarge.gd new file mode 100644 index 0000000..c3debba --- /dev/null +++ b/src/actors/candy/types/peanutLarge.gd @@ -0,0 +1,15 @@ +extends Candy + +class_name PeanutLarge, "res://assets/candy/peanut-big.png" + + +# 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(): + points = 10 + sprite_frame = load("res://src/actors/candy/types/peanutLarge.tres") + set_candy_sprite_frame(sprite_frame) diff --git a/src/actors/candy/spriteFrames/peanutLarge.tres b/src/actors/candy/types/peanutLarge.tres similarity index 100% rename from src/actors/candy/spriteFrames/peanutLarge.tres rename to src/actors/candy/types/peanutLarge.tres diff --git a/src/actors/candy/types/peanutSmall.gd b/src/actors/candy/types/peanutSmall.gd new file mode 100644 index 0000000..448e8b1 --- /dev/null +++ b/src/actors/candy/types/peanutSmall.gd @@ -0,0 +1,15 @@ +extends Candy + +class_name PeanutSmall, "res://assets/candy/peanut-small.png" + + +# 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(): + points = 1 + sprite_frame = load("res://src/actors/candy/types/peanutSmall.tres") + set_candy_sprite_frame(sprite_frame) diff --git a/src/actors/candy/spriteFrames/peanutSmall.tres b/src/actors/candy/types/peanutSmall.tres similarity index 100% rename from src/actors/candy/spriteFrames/peanutSmall.tres rename to src/actors/candy/types/peanutSmall.tres diff --git a/src/actors/player/player.gd b/src/actors/player/player.gd index efaece3..12f8490 100644 --- a/src/actors/player/player.gd +++ b/src/actors/player/player.gd @@ -1,5 +1,7 @@ extends KinematicBody2D +class_name Player + """######################################## VARIABLES ########################################""" @@ -16,6 +18,7 @@ var joystick_velocity = Vector2.ZERO var trail: Array = Array() +var player_name = "" var speed = 500 var gender = null var team = null @@ -32,11 +35,12 @@ func _init(): self.team = team_e.RED # Used as a constructor -func init(name: String, gender: bool, team: bool, position: Vector2): +func init(name: String, gender: bool, team: int, position: Vector2): $NameTag.set_text(name) self.gender = gender self.team = team self.position = position + self.player_name = name if team: self.set_collision_layer_bit(4, true) else: @@ -133,8 +137,8 @@ func get_animation(): func multiplayer_movements(): if is_network_master(): - rset("puppet_velocity", velocity) - rset("puppet_pos", position) + rset_unreliable("puppet_velocity", velocity) + rset_unreliable("puppet_pos", position) else: position = puppet_pos velocity = puppet_velocity @@ -182,6 +186,16 @@ func loose_candies(from: Node2D) -> Array: return stolen_candies +func arrive_at_home(): + print("I'm at home") + +func points_in_queue() -> int: + var points: int = 0 + for c in self.trail: + points += c.points + return points + + """######################################## SLOTS ########################################""" diff --git a/src/actors/player/player.tscn b/src/actors/player/player.tscn index 2fbf5e2..bbf873e 100644 --- a/src/actors/player/player.tscn +++ b/src/actors/player/player.tscn @@ -20,14 +20,14 @@ collision_mask = 4 script = ExtResource( 1 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="."] -position = Vector2( 0, 4.49091 ) +position = Vector2( 0, 3.49033 ) shape = SubResource( 1 ) [node name="AnimatedSprite" type="AnimatedSprite" parent="."] position = Vector2( 0, -3.00909 ) frames = ExtResource( 2 ) animation = "idle" -frame = 1 +frame = 3 playing = true [node name="Camera" type="Camera2D" parent="."] @@ -42,9 +42,9 @@ anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 margin_left = -13.9851 -margin_top = -15.9362 +margin_top = -18.0719 margin_right = 79.0149 -margin_bottom = 3.06382 +margin_bottom = 0.92807 rect_scale = Vector2( 0.3, 0.3 ) custom_fonts/font = SubResource( 2 ) text = "Player Name" @@ -52,7 +52,3 @@ align = 1 __meta__ = { "_edit_use_anchors_": false } - -[node name="CandiesTrail" type="Node2D" parent="."] -position = Vector2( 15.3043, 0 ) -scale = Vector2( 0.1, 0.1 ) diff --git a/src/Game.gd b/src/game.gd similarity index 58% rename from src/Game.gd rename to src/game.gd index f443a34..dfaa756 100644 --- a/src/Game.gd +++ b/src/game.gd @@ -1,24 +1,42 @@ extends Node2D +class_name Game """######################################## VARIABLES ########################################""" -var player: KinematicBody2D +var player: Player var is_server: bool +var points = { + 'red': 0, + 'black': 0 +} + +signal update_progressbar + """######################################## INIT ########################################""" -func init(players_init, server_only = false): - var player_scene = load("res://src/actors/player/player.tscn") +func init(players_init: Dictionary): + init_client(players_init) - # Create the players + if get_tree().is_network_server(): + self.init_server() + + if gamestate.get_server_only(): + $CameraServerOnly.visible = true + $CameraServerOnly.current = true + $CanvasLayer/HUD.visible = false + + +func init_client(players_init: Dictionary): + var player_scene = load("res://src/actors/player/player.tscn") var i_black = 0 var i_red = 0 @@ -46,24 +64,22 @@ func init(players_init, server_only = false): get_node("YSort/Players").add_child(p) - if get_tree().is_network_server(): - - # Candy spawners - var candy_spawner = load("res://src/scripts/server/candySpawners/CandySpawners.tscn").instance() - self.add_child(candy_spawner) - candy_spawner.init($YSort/Map/CandySpawners.get_children()) - - # Candy trails - var candy_trails = load("res://src/scripts/server/trails/Trails.tscn").instance() - self.add_child(candy_trails) - candy_trails.init($YSort/Players) - - if server_only: - $CameraServerOnly.visible = true - $CameraServerOnly.current = true - $CanvasLayer/HUD.visible = false + self.connect("update_progressbar", $CanvasLayer/HUD/ProgressBar, "update_progressbar") +func init_server(): + # Candy spawners + var candy_spawner = load("res://src/scripts/server/candySpawners/CandySpawners.tscn").instance() + self.add_child(candy_spawner) + candy_spawner.init($YSort/Map/CandySpawners.get_children()) + + # Candy trails + var trails = load("res://src/scripts/server/trails/Trails.tscn").instance() + self.add_child(trails) + trails.init($YSort/Players) + $YSort/Map.connect("player_arrived_at_home", self, "add_points") + $YSort/Map.connect("player_arrived_at_home", trails, "clear_trail") + func set_main_player(): # Connects the joystick's signal to the player of this instance $CanvasLayer/HUD/Joystick.connect( @@ -89,10 +105,6 @@ func _process(delta): if get_tree().is_network_server(): pass # self.draw_player_trail() - - # Shrunk the trail if it's too big FIXME : doesn't work ? - #if points_size > 5: - # $ThisPlayerTrail.points.resize(1) remote func spawn_candy(pos, type): @@ -102,3 +114,23 @@ remote func spawn_candy(pos, type): """######################################## SLOTS ########################################""" + +# Only called on the server +func add_points(player: Player): + assert(get_tree().is_network_server()) + + var team: bool = player.team + var points: int = player.points_in_queue() + + print(player.team) + match (player.team): + player.team_e.RED: self.points['red'] += points + player.team_e.BLACK: self.points['black'] += points + + for id in gamestate.get_clients_list(): + rpc_id(id, "update_progressbar_client", self.points) + + emit_signal("update_progressbar", self.points) + +remote func update_progressbar_client(points: Dictionary): + emit_signal("update_progressbar", points) diff --git a/src/Game.tscn b/src/game.tscn similarity index 61% rename from src/Game.tscn rename to src/game.tscn index 33bf434..a7c533b 100644 --- a/src/Game.tscn +++ b/src/game.tscn @@ -1,15 +1,15 @@ [gd_scene load_steps=4 format=2] -[ext_resource path="res://src/ui/game-hud.tscn" type="PackedScene" id=2] -[ext_resource path="res://src/levels/level-demo.tscn" type="PackedScene" id=3] -[ext_resource path="res://src/Game.gd" type="Script" id=4] +[ext_resource path="res://src/game.gd" type="Script" id=1] +[ext_resource path="res://src/levels/levelDemo/levelDemo.tscn" type="PackedScene" id=2] +[ext_resource path="res://src/ui/game-hud.tscn" type="PackedScene" id=3] [node name="Game" type="Node2D"] -script = ExtResource( 4 ) +script = ExtResource( 1 ) [node name="CanvasLayer" type="CanvasLayer" parent="."] -[node name="HUD" parent="CanvasLayer" instance=ExtResource( 2 )] +[node name="HUD" parent="CanvasLayer" instance=ExtResource( 3 )] [node name="YSort" type="YSort" parent="."] @@ -17,7 +17,7 @@ script = ExtResource( 4 ) [node name="Candies" type="YSort" parent="YSort"] -[node name="Map" parent="YSort" instance=ExtResource( 3 )] +[node name="Map" parent="YSort" instance=ExtResource( 2 )] position = Vector2( 6.10352e-05, 0.00012207 ) [node name="CameraServerOnly" type="Camera2D" parent="."] diff --git a/src/levels/levelDemo/levelDemo.gd b/src/levels/levelDemo/levelDemo.gd new file mode 100644 index 0000000..f299888 --- /dev/null +++ b/src/levels/levelDemo/levelDemo.gd @@ -0,0 +1,20 @@ +extends YSort + +signal player_arrived_at_home + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass + + +func _on_home_body_entered(body): + if not get_tree().is_network_server(): return + if not body is Player: return + + emit_signal("player_arrived_at_home", body) + diff --git a/src/levels/level-demo.tscn b/src/levels/levelDemo/levelDemo.tscn similarity index 93% rename from src/levels/level-demo.tscn rename to src/levels/levelDemo/levelDemo.tscn index bd07110..d4186ed 100644 --- a/src/levels/level-demo.tscn +++ b/src/levels/levelDemo/levelDemo.tscn @@ -1,20 +1,22 @@ -[gd_scene load_steps=74 format=2] - -[ext_resource path="res://assets/world/base/planks.png" type="Texture" id=1] -[ext_resource path="res://assets/world/base/path/path.png" type="Texture" id=2] -[ext_resource path="res://assets/bosses/carpet/carpets-black.png" type="Texture" id=3] -[ext_resource path="res://assets/world/base/snow.png" type="Texture" id=4] -[ext_resource path="res://assets/world/base/face-outside-2.png" type="Texture" id=5] -[ext_resource path="res://assets/world/base/face-outside-1.png" type="Texture" id=6] -[ext_resource path="res://assets/world/base/walls/walls.png" type="Texture" id=7] -[ext_resource path="res://assets/world/base/face.png" type="Texture" id=8] -[ext_resource path="res://assets/world/deco/barriers.png" type="Texture" id=9] -[ext_resource path="res://assets/bosses/carpet/carpets-red.png" type="Texture" id=10] -[ext_resource path="res://src/scripts/server/candySpawners/spawner.gd" type="Script" id=11] +[gd_scene load_steps=79 format=2] + +[ext_resource path="res://assets/world/base/snow.png" type="Texture" id=1] +[ext_resource path="res://assets/world/base/planks.png" type="Texture" id=2] +[ext_resource path="res://assets/world/base/face-outside-2.png" type="Texture" id=3] +[ext_resource path="res://assets/world/deco/barriers.png" type="Texture" id=4] +[ext_resource path="res://src/levels/levelDemo/levelDemo.gd" type="Script" id=5] +[ext_resource path="res://assets/bosses/carpet/carpets-black.png" type="Texture" id=6] +[ext_resource path="res://assets/bosses/carpet/carpets-red.png" type="Texture" id=7] +[ext_resource path="res://src/scripts/server/candySpawners/spawner.gd" type="Script" id=8] +[ext_resource path="res://assets/world/base/face-outside-1.png" type="Texture" id=9] +[ext_resource path="res://src/actors/boss/Boss.tscn" type="PackedScene" id=10] +[ext_resource path="res://assets/world/base/face.png" type="Texture" id=11] +[ext_resource path="res://assets/world/base/path/path.png" type="Texture" id=12] +[ext_resource path="res://assets/world/base/walls/walls.png" type="Texture" id=13] [sub_resource type="TileSet" id=1] 1/name = "snow.png 1" -1/texture = ExtResource( 4 ) +1/texture = ExtResource( 1 ) 1/tex_offset = Vector2( 0, 0 ) 1/modulate = Color( 1, 1, 1, 1 ) 1/region = Rect2( 0, 0, 13, 13 ) @@ -30,7 +32,7 @@ [sub_resource type="TileSet" id=2] 0/name = "path.png 0" -0/texture = ExtResource( 2 ) +0/texture = ExtResource( 12 ) 0/tex_offset = Vector2( 0, 0 ) 0/modulate = Color( 1, 1, 1, 1 ) 0/region = Rect2( 0, 0, 156, 52 ) @@ -169,7 +171,7 @@ points = PoolVector2Array( 13, 13, 0, 13, 0, 0, 13, 0 ) [sub_resource type="TileSet" id=41] 0/name = "face-outside-2.png 0" -0/texture = ExtResource( 5 ) +0/texture = ExtResource( 3 ) 0/tex_offset = Vector2( 0, 0 ) 0/modulate = Color( 1, 1, 1, 1 ) 0/region = Rect2( 0, 0, 13, 13 ) @@ -191,7 +193,7 @@ points = PoolVector2Array( 13, 13, 0, 13, 0, 0, 13, 0 ) } ] 0/z_index = 0 1/name = "face-outside-1.png 1" -1/texture = ExtResource( 6 ) +1/texture = ExtResource( 9 ) 1/tex_offset = Vector2( 0, 0 ) 1/modulate = Color( 1, 1, 1, 1 ) 1/region = Rect2( 0, 0, 13, 13 ) @@ -213,7 +215,7 @@ points = PoolVector2Array( 13, 13, 0, 13, 0, 0, 13, 0 ) } ] 1/z_index = 0 2/name = "walls.png 2" -2/texture = ExtResource( 7 ) +2/texture = ExtResource( 13 ) 2/tex_offset = Vector2( 0, 0 ) 2/modulate = Color( 1, 1, 1, 1 ) 2/region = Rect2( 0, 0, 52, 52 ) @@ -333,7 +335,7 @@ points = PoolVector2Array( 13, 13, 0, 13, 0, 0, 13, 0 ) } ] 2/z_index = 0 3/name = "face.png 3" -3/texture = ExtResource( 8 ) +3/texture = ExtResource( 11 ) 3/tex_offset = Vector2( 0, 0 ) 3/modulate = Color( 1, 1, 1, 1 ) 3/region = Rect2( 0, 0, 13, 13 ) @@ -355,7 +357,7 @@ points = PoolVector2Array( 13, 13, 0, 13, 0, 0, 13, 0 ) } ] 3/z_index = 0 4/name = "planks.png 4" -4/texture = ExtResource( 1 ) +4/texture = ExtResource( 2 ) 4/tex_offset = Vector2( 0, 0 ) 4/modulate = Color( 1, 1, 1, 1 ) 4/region = Rect2( 0, 0, 13, 13 ) @@ -371,7 +373,7 @@ points = PoolVector2Array( 13, 13, 0, 13, 0, 0, 13, 0 ) [sub_resource type="TileSet" id=42] 0/name = "carpets-black.png 0" -0/texture = ExtResource( 3 ) +0/texture = ExtResource( 6 ) 0/tex_offset = Vector2( 0, 0 ) 0/modulate = Color( 1, 1, 1, 1 ) 0/region = Rect2( 0, 0, 39, 39 ) @@ -394,7 +396,7 @@ points = PoolVector2Array( 13, 13, 0, 13, 0, 0, 13, 0 ) 0/shapes = [ ] 0/z_index = 0 1/name = "carpets-red.png 1" -1/texture = ExtResource( 10 ) +1/texture = ExtResource( 7 ) 1/tex_offset = Vector2( 0, 0 ) 1/modulate = Color( 1, 1, 1, 1 ) 1/region = Rect2( 0, 0, 39, 39 ) @@ -476,7 +478,7 @@ points = PoolVector2Array( 11, 17, 9, 17, 9, 11, 11, 11 ) [sub_resource type="TileSet" id=62] 0/name = "barriers.png 0" -0/texture = ExtResource( 9 ) +0/texture = ExtResource( 4 ) 0/tex_offset = Vector2( 0, 0 ) 0/modulate = Color( 1, 1, 1, 1 ) 0/region = Rect2( 0, 13, 39, 52 ) @@ -590,7 +592,7 @@ points = PoolVector2Array( 11, 17, 9, 17, 9, 11, 11, 11 ) } ] 0/z_index = 0 1/name = "barriers.png 1" -1/texture = ExtResource( 9 ) +1/texture = ExtResource( 4 ) 1/tex_offset = Vector2( 0, 0 ) 1/modulate = Color( 1, 1, 1, 1 ) 1/region = Rect2( 39, 0, 13, 26 ) @@ -617,7 +619,7 @@ points = PoolVector2Array( 11, 17, 9, 17, 9, 11, 11, 11 ) } ] 1/z_index = 0 2/name = "barriers.png 2" -2/texture = ExtResource( 9 ) +2/texture = ExtResource( 4 ) 2/tex_offset = Vector2( 0, 0 ) 2/modulate = Color( 1, 1, 1, 1 ) 2/region = Rect2( 39, 26, 13, 26 ) @@ -644,12 +646,46 @@ points = PoolVector2Array( 11, 17, 9, 17, 9, 11, 11, 11 ) } ] 2/z_index = 0 +[sub_resource type="GDScript" id=63] +script/source = "extends Node2D + + +enum TYPE_E {NICOLAS=0, FOUETTARD=1} + +export(int, \"St Nicolas\", \"Pere Fouettard\") var type = TYPE_E.NICOLAS + + +# Called when the node enters the scene tree for the first time. +func _ready(): + var sprite_frames: SpriteFrames + + if type == TYPE_E.FOUETTARD: + sprite_frames = preload(\"res://src/actors/boss/spriteFrames/pereFouettard.tres\") + elif type == TYPE_E.NICOLAS: + sprite_frames = preload(\"res://src/actors/boss/spriteFrames/stNicolas.tres\") + $AnimatedSprite.set_sprite_frames(sprite_frames) + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass +" + +[sub_resource type="RectangleShape2D" id=64] +extents = Vector2( 162.339, 259.837 ) + +[sub_resource type="RectangleShape2D" id=65] +extents = Vector2( 161.399, 259.573 ) + [node name="Map" type="YSort"] +script = ExtResource( 5 ) + +[node name="Tilemaps" type="Node2D" parent="."] -[node name="Background" type="Node2D" parent="."] +[node name="Background" type="Node2D" parent="Tilemaps"] z_index = -1 -[node name="Snow" type="TileMap" parent="Background"] +[node name="Snow" type="TileMap" parent="Tilemaps/Background"] scale = Vector2( 10, 10 ) tile_set = SubResource( 1 ) cell_size = Vector2( 13, 13 ) @@ -659,7 +695,7 @@ collision_mask = 0 format = 1 tile_data = PoolIntArray( -1114125, 1, 0, -1114124, 1, 0, -1114123, 1, 0, -1114122, 1, 0, -1114121, 1, 0, -1114120, 1, 0, -1114119, 1, 0, -1114118, 1, 0, -1114117, 1, 0, -1114116, 1, 0, -1114115, 1, 0, -1114114, 1, 0, -1114113, 1, 0, -1179648, 1, 0, -1179647, 1, 0, -1179646, 1, 0, -1179645, 1, 0, -1179644, 1, 0, -1179643, 1, 0, -1179642, 1, 0, -1179641, 1, 0, -1179640, 1, 0, -1179639, 1, 0, -1179638, 1, 0, -1179637, 1, 0, -1179636, 1, 0, -1179635, 1, 0, -1179634, 1, 0, -1179633, 1, 0, -1179632, 1, 0, -1179631, 1, 0, -1179630, 1, 0, -1179629, 1, 0, -1179628, 1, 0, -1179627, 1, 0, -1179626, 1, 0, -1179625, 1, 0, -1179624, 1, 0, -1179623, 1, 0, -1179622, 1, 0, -1179621, 1, 0, -1048589, 1, 0, -1048588, 1, 0, -1048587, 1, 0, -1048586, 1, 0, -1048585, 1, 0, -1048584, 1, 0, -1048583, 1, 0, -1048582, 1, 0, -1048581, 1, 0, -1048580, 1, 0, -1048579, 1, 0, -1048578, 1, 0, -1048577, 1, 0, -1114112, 1, 0, -1114111, 1, 0, -1114110, 1, 0, -1114109, 1, 0, -1114108, 1, 0, -1114107, 1, 0, -1114106, 1, 0, -1114105, 1, 0, -1114104, 1, 0, -1114103, 1, 0, -1114102, 1, 0, -1114101, 1, 0, -1114100, 1, 0, -1114099, 1, 0, -1114098, 1, 0, -1114097, 1, 0, -1114096, 1, 0, -1114095, 1, 0, -1114094, 1, 0, -1114093, 1, 0, -1114092, 1, 0, -1114091, 1, 0, -1114090, 1, 0, -1114089, 1, 0, -1114088, 1, 0, -1114087, 1, 0, -1114086, 1, 0, -1114085, 1, 0, -983053, 1, 0, -983052, 1, 0, -983051, 1, 0, -983050, 1, 0, -983049, 1, 0, -983048, 1, 0, -983047, 1, 0, -983046, 1, 0, -983045, 1, 0, -983044, 1, 0, -983043, 1, 0, -983042, 1, 0, -983041, 1, 0, -1048576, 1, 0, -1048575, 1, 0, -1048574, 1, 0, -1048573, 1, 0, -1048572, 1, 0, -1048571, 1, 0, -1048570, 1, 0, -1048569, 1, 0, -1048568, 1, 0, -1048567, 1, 0, -1048566, 1, 0, -1048565, 1, 0, -1048564, 1, 0, -1048563, 1, 0, -1048562, 1, 0, -1048561, 1, 0, -1048560, 1, 0, -1048559, 1, 0, -1048558, 1, 0, -1048557, 1, 0, -1048556, 1, 0, -1048555, 1, 0, -1048554, 1, 0, -1048553, 1, 0, -1048552, 1, 0, -1048551, 1, 0, -1048550, 1, 0, -1048549, 1, 0, -917517, 1, 0, -917516, 1, 0, -917515, 1, 0, -917514, 1, 0, -917513, 1, 0, -917512, 1, 0, -917511, 1, 0, -917510, 1, 0, -917509, 1, 0, -917508, 1, 0, -917507, 1, 0, -917506, 1, 0, -917505, 1, 0, -983040, 1, 0, -983039, 1, 0, -983038, 1, 0, -983037, 1, 0, -983036, 1, 0, -983035, 1, 0, -983034, 1, 0, -983033, 1, 0, -983032, 1, 0, -983031, 1, 0, -983030, 1, 0, -983029, 1, 0, -983028, 1, 0, -983027, 1, 0, -983026, 1, 0, -983025, 1, 0, -983024, 1, 0, -983023, 1, 0, -983022, 1, 0, -983021, 1, 0, -983020, 1, 0, -983019, 1, 0, -983018, 1, 0, -983017, 1, 0, -983016, 1, 0, -983015, 1, 0, -983014, 1, 0, -983013, 1, 0, -851981, 1, 0, -851980, 1, 0, -851979, 1, 0, -851978, 1, 0, -851977, 1, 0, -851976, 1, 0, -851975, 1, 0, -851974, 1, 0, -851973, 1, 0, -851972, 1, 0, -851971, 1, 0, -851970, 1, 0, -851969, 1, 0, -917504, 1, 0, -917503, 1, 0, -917502, 1, 0, -917501, 1, 0, -917500, 1, 0, -917499, 1, 0, -917498, 1, 0, -917497, 1, 0, -917496, 1, 0, -917495, 1, 0, -917494, 1, 0, -917493, 1, 0, -917492, 1, 0, -917491, 1, 0, -917490, 1, 0, -917489, 1, 0, -917488, 1, 0, -917487, 1, 0, -917486, 1, 0, -917485, 1, 0, -917484, 1, 0, -917483, 1, 0, -917482, 1, 0, -917481, 1, 0, -917480, 1, 0, -917479, 1, 0, -917478, 1, 0, -917477, 1, 0, -786445, 1, 0, -786444, 1, 0, -786443, 1, 0, -786442, 1, 0, -786441, 1, 0, -786440, 1, 0, -786439, 1, 0, -786438, 1, 0, -786437, 1, 0, -786436, 1, 0, -786435, 1, 0, -786434, 1, 0, -786433, 1, 0, -851968, 1, 0, -851967, 1, 0, -851966, 1, 0, -851965, 1, 0, -851964, 1, 0, -851963, 1, 0, -851962, 1, 0, -851961, 1, 0, -851960, 1, 0, -851959, 1, 0, -851958, 1, 0, -851957, 1, 0, -851956, 1, 0, -851955, 1, 0, -851954, 1, 0, -851953, 1, 0, -851952, 1, 0, -851951, 1, 0, -851950, 1, 0, -851949, 1, 0, -851948, 1, 0, -851947, 1, 0, -851946, 1, 0, -851945, 1, 0, -851944, 1, 0, -851943, 1, 0, -851942, 1, 0, -851941, 1, 0, -720909, 1, 0, -720908, 1, 0, -720907, 1, 0, -720906, 1, 0, -720905, 1, 0, -720904, 1, 0, -720903, 1, 0, -720902, 1, 0, -720901, 1, 0, -720900, 1, 0, -720899, 1, 0, -720898, 1, 0, -720897, 1, 0, -786432, 1, 0, -786431, 1, 0, -786430, 1, 0, -786429, 1, 0, -786428, 1, 0, -786427, 1, 0, -786426, 1, 0, -786425, 1, 0, -786424, 1, 0, -786423, 1, 0, -786422, 1, 0, -786421, 1, 0, -786420, 1, 0, -786419, 1, 0, -786418, 1, 0, -786417, 1, 0, -786416, 1, 0, -786415, 1, 0, -786414, 1, 0, -786413, 1, 0, -786412, 1, 0, -786411, 1, 0, -786410, 1, 0, -786409, 1, 0, -786408, 1, 0, -786407, 1, 0, -786406, 1, 0, -786405, 1, 0, -655373, 1, 0, -655372, 1, 0, -655371, 1, 0, -655370, 1, 0, -655369, 1, 0, -655368, 1, 0, -655367, 1, 0, -655366, 1, 0, -655365, 1, 0, -655364, 1, 0, -655363, 1, 0, -655362, 1, 0, -655361, 1, 0, -720896, 1, 0, -720895, 1, 0, -720894, 1, 0, -720893, 1, 0, -720892, 1, 0, -720891, 1, 0, -720890, 1, 0, -720889, 1, 0, -720888, 1, 0, -720887, 1, 0, -720886, 1, 0, -720885, 1, 0, -720884, 1, 0, -720883, 1, 0, -720882, 1, 0, -720881, 1, 0, -720880, 1, 0, -720879, 1, 0, -720878, 1, 0, -720877, 1, 0, -720876, 1, 0, -720875, 1, 0, -720874, 1, 0, -720873, 1, 0, -720872, 1, 0, -720871, 1, 0, -720870, 1, 0, -720869, 1, 0, -589837, 1, 0, -589836, 1, 0, -589835, 1, 0, -589834, 1, 0, -589833, 1, 0, -589832, 1, 0, -589831, 1, 0, -589830, 1, 0, -589829, 1, 0, -589828, 1, 0, -589827, 1, 0, -589826, 1, 0, -589825, 1, 0, -655360, 1, 0, -655359, 1, 0, -655358, 1, 0, -655357, 1, 0, -655356, 1, 0, -655355, 1, 0, -655354, 1, 0, -655353, 1, 0, -655352, 1, 0, -655351, 1, 0, -655350, 1, 0, -655349, 1, 0, -655348, 1, 0, -655347, 1, 0, -655346, 1, 0, -655345, 1, 0, -655344, 1, 0, -655343, 1, 0, -655342, 1, 0, -655341, 1, 0, -655340, 1, 0, -655339, 1, 0, -655338, 1, 0, -655337, 1, 0, -655336, 1, 0, -655335, 1, 0, -655334, 1, 0, -655333, 1, 0, -524301, 1, 0, -524300, 1, 0, -524299, 1, 0, -524298, 1, 0, -524297, 1, 0, -524296, 1, 0, -524295, 1, 0, -524294, 1, 0, -524293, 1, 0, -524292, 1, 0, -524291, 1, 0, -524290, 0, 0, -524289, 0, 0, -589824, 0, 0, -589822, 1, 0, -589821, 1, 0, -589820, 1, 0, -589819, 1, 0, -589807, 1, 0, -589806, 1, 0, -589805, 1, 0, -589804, 1, 0, -589803, 1, 0, -589802, 1, 0, -589801, 1, 0, -589800, 1, 0, -589799, 1, 0, -589798, 1, 0, -589797, 1, 0, -458765, 1, 0, -458764, 1, 0, -458763, 1, 0, -458762, 1, 0, -458761, 1, 0, -458760, 1, 0, -458759, 1, 0, -458758, 1, 0, -458757, 1, 0, -458756, 1, 0, -458755, 1, 0, -458754, 0, 0, -458753, 0, 0, -524288, 0, 0, -524286, 1, 0, -524285, 1, 0, -524284, 1, 0, -524283, 1, 0, -524271, 1, 0, -524270, 1, 0, -524269, 1, 0, -524268, 1, 0, -524267, 1, 0, -524266, 1, 0, -524265, 1, 0, -524264, 1, 0, -524263, 1, 0, -524262, 1, 0, -524261, 1, 0, -393229, 1, 0, -393228, 1, 0, -393227, 1, 0, -393226, 1, 0, -393225, 1, 0, -393224, 1, 0, -393223, 1, 0, -393222, 1, 0, -393221, 1, 0, -393220, 1, 0, -393219, 1, 0, -393218, 0, 0, -393217, 0, 0, -458752, 0, 0, -458745, 0, 0, -458744, 0, 0, -458743, 0, 0, -458742, 0, 0, -458741, 0, 0, -458740, 0, 0, -458739, 0, 0, -458738, 0, 0, -458737, 0, 0, -458736, 0, 0, -458735, 1, 0, -458734, 1, 0, -458733, 1, 0, -458732, 1, 0, -458731, 1, 0, -458730, 1, 0, -458729, 1, 0, -458728, 1, 0, -458727, 1, 0, -458726, 1, 0, -458725, 1, 0, -327693, 1, 0, -327692, 1, 0, -327691, 1, 0, -327690, 1, 0, -327689, 1, 0, -327688, 1, 0, -327687, 1, 0, -327686, 1, 0, -327685, 1, 0, -327684, 1, 0, -327683, 1, 0, -327682, 0, 0, -327681, 0, 0, -393216, 0, 0, -393209, 0, 0, -393208, 0, 0, -393207, 0, 0, -393206, 0, 0, -393205, 0, 0, -393204, 0, 0, -393203, 0, 0, -393202, 0, 0, -393201, 0, 0, -393200, 0, 0, -393199, 1, 0, -393198, 1, 0, -393197, 1, 0, -393196, 1, 0, -393195, 1, 0, -393194, 1, 0, -393193, 1, 0, -393192, 1, 0, -393191, 1, 0, -393190, 1, 0, -393189, 1, 0, -262157, 1, 0, -262156, 1, 0, -262155, 1, 0, -262154, 1, 0, -262153, 1, 0, -262152, 1, 0, -262151, 1, 0, -262150, 1, 0, -262149, 1, 0, -262148, 1, 0, -262147, 1, 0, -262146, 0, 0, -262145, 0, 0, -327680, 0, 0, -327679, 0, 0, -327678, 0, 0, -327677, 0, 0, -327676, 0, 0, -327675, 0, 0, -327674, 0, 0, -327673, 0, 0, -327672, 0, 0, -327666, 0, 0, -327665, 0, 0, -327664, 0, 0, -327663, 1, 0, -327662, 1, 0, -327661, 1, 0, -327660, 1, 0, -327659, 1, 0, -327658, 1, 0, -327657, 1, 0, -327656, 1, 0, -327655, 1, 0, -327654, 1, 0, -327653, 1, 0, -196621, 1, 0, -196620, 1, 0, -196619, 1, 0, -196618, 1, 0, -196617, 1, 0, -196616, 1, 0, -196615, 1, 0, -196614, 1, 0, -196613, 1, 0, -196612, 1, 0, -196611, 1, 0, -196610, 0, 0, -196609, 0, 0, -262144, 0, 0, -262143, 0, 0, -262142, 0, 0, -262141, 0, 0, -262140, 0, 0, -262139, 0, 0, -262138, 0, 0, -262137, 0, 0, -262136, 0, 0, -262129, 0, 0, -262128, 0, 0, -262127, 1, 0, -262126, 1, 0, -262125, 1, 0, -262124, 1, 0, -262123, 1, 0, -262122, 1, 0, -262121, 1, 0, -262120, 1, 0, -262119, 1, 0, -262118, 1, 0, -262117, 1, 0, -131085, 1, 0, -131084, 1, 0, -131083, 1, 0, -131082, 1, 0, -131081, 1, 0, -131080, 1, 0, -131079, 1, 0, -131078, 1, 0, -131077, 1, 0, -131076, 1, 0, -131075, 1, 0, -196598, 1, 0, -196597, 1, 0, -196596, 1, 0, -196593, 0, 0, -196592, 0, 0, -196591, 1, 0, -196590, 1, 0, -196589, 1, 0, -196588, 1, 0, -196587, 1, 0, -196586, 1, 0, -196585, 1, 0, -196584, 1, 0, -196583, 1, 0, -196582, 1, 0, -196581, 1, 0, -65549, 1, 0, -65548, 1, 0, -65547, 1, 0, -65546, 1, 0, -65545, 1, 0, -65544, 1, 0, -65543, 1, 0, -65542, 1, 0, -65541, 1, 0, -65540, 1, 0, -65539, 1, 0, -65538, 1, 0, -65537, 1, 0, -131072, 1, 0, -131071, 1, 0, -131070, 1, 0, -131069, 1, 0, -131068, 1, 0, -131067, 1, 0, -131066, 1, 0, -131065, 1, 0, -131064, 1, 0, -131063, 1, 0, -131062, 1, 0, -131061, 1, 0, -131060, 1, 0, -131059, 1, 0, -131058, 1, 0, -131057, 0, 0, -131056, 0, 0, -131055, 1, 0, -131054, 1, 0, -131053, 1, 0, -131052, 1, 0, -131051, 1, 0, -131050, 1, 0, -131049, 1, 0, -131048, 1, 0, -131047, 1, 0, -131046, 1, 0, -131045, 1, 0, -13, 1, 0, -12, 1, 0, -11, 1, 0, -10, 1, 0, -9, 1, 0, -8, 1, 0, -7, 1, 0, -6, 1, 0, -5, 1, 0, -4, 1, 0, -3, 1, 0, -2, 1, 0, -1, 1, 0, -65536, 1, 0, -65535, 1, 0, -65534, 1, 0, -65533, 1, 0, -65532, 1, 0, -65531, 1, 0, -65530, 1, 0, -65529, 1, 0, -65528, 1, 0, -65527, 1, 0, -65526, 1, 0, -65525, 1, 0, -65524, 1, 0, -65523, 1, 0, -65522, 1, 0, -65521, 0, 0, -65520, 0, 0, -65519, 1, 0, -65518, 1, 0, -65517, 1, 0, -65516, 1, 0, -65515, 1, 0, -65514, 1, 0, -65513, 1, 0, -65512, 1, 0, -65511, 1, 0, -65510, 1, 0, -65509, 1, 0, 65523, 1, 0, 65524, 1, 0, 65525, 1, 0, 65526, 1, 0, 65527, 1, 0, 65528, 1, 0, 65529, 1, 0, 65530, 1, 0, 65531, 1, 0, 65532, 1, 0, 65533, 1, 0, 65534, 1, 0, 65535, 1, 0, 0, 1, 0, 1, 1, 0, 2, 1, 0, 3, 1, 0, 4, 1, 0, 5, 1, 0, 6, 1, 0, 7, 1, 0, 8, 1, 0, 9, 1, 0, 10, 1, 0, 11, 1, 0, 12, 1, 0, 13, 1, 0, 14, 1, 0, 15, 0, 0, 16, 0, 0, 17, 1, 0, 18, 1, 0, 19, 1, 0, 20, 1, 0, 21, 1, 0, 22, 1, 0, 23, 1, 0, 24, 1, 0, 25, 1, 0, 26, 1, 0, 27, 1, 0, 131059, 1, 0, 131060, 1, 0, 131061, 1, 0, 131062, 1, 0, 131063, 1, 0, 131064, 1, 0, 131065, 1, 0, 131066, 1, 0, 131067, 1, 0, 131068, 1, 0, 131069, 1, 0, 131070, 1, 0, 131071, 1, 0, 65536, 1, 0, 65537, 1, 0, 65538, 1, 0, 65539, 1, 0, 65540, 1, 0, 65541, 1, 0, 65542, 1, 0, 65543, 1, 0, 65544, 1, 0, 65545, 1, 0, 65546, 1, 0, 65547, 1, 0, 65548, 1, 0, 65549, 1, 0, 65550, 1, 0, 65551, 0, 0, 65552, 0, 0, 65553, 1, 0, 65554, 1, 0, 65555, 1, 0, 65556, 1, 0, 65557, 1, 0, 65558, 1, 0, 65559, 1, 0, 65560, 1, 0, 65561, 1, 0, 65562, 1, 0, 65563, 1, 0, 196595, 1, 0, 196596, 1, 0, 196597, 1, 0, 196598, 1, 0, 196599, 1, 0, 196600, 1, 0, 196601, 1, 0, 196602, 1, 0, 196603, 1, 0, 196604, 1, 0, 196605, 1, 0, 196606, 1, 0, 196607, 1, 0, 131072, 1, 0, 131073, 1, 0, 131074, 1, 0, 131075, 1, 0, 131076, 1, 0, 131077, 1, 0, 131078, 1, 0, 131079, 1, 0, 131080, 1, 0, 131081, 1, 0, 131082, 1, 0, 131083, 1, 0, 131084, 1, 0, 131085, 1, 0, 131086, 1, 0, 131087, 0, 0, 131088, 0, 0, 131089, 1, 0, 131090, 1, 0, 131091, 1, 0, 131092, 1, 0, 131093, 1, 0, 131094, 1, 0, 131095, 1, 0, 131096, 1, 0, 131097, 1, 0, 131098, 1, 0, 131099, 1, 0, 262131, 1, 0, 262132, 1, 0, 262133, 1, 0, 262134, 1, 0, 262135, 1, 0, 262136, 1, 0, 262137, 1, 0, 262138, 1, 0, 262139, 1, 0, 262140, 1, 0, 262141, 1, 0, 262142, 1, 0, 262143, 1, 0, 196608, 1, 0, 196609, 1, 0, 196610, 1, 0, 196611, 1, 0, 196612, 1, 0, 196613, 1, 0, 196614, 1, 0, 196615, 1, 0, 196616, 1, 0, 196617, 1, 0, 196618, 1, 0, 196619, 1, 0, 196620, 1, 0, 196621, 1, 0, 196622, 1, 0, 196623, 1, 0, 196624, 1, 0, 196625, 1, 0, 196626, 1, 0, 196627, 1, 0, 196628, 1, 0, 196629, 1, 0, 196630, 1, 0, 196631, 1, 0, 196632, 1, 0, 196633, 1, 0, 196634, 1, 0, 196635, 1, 0, 327667, 1, 0, 327668, 1, 0, 327669, 1, 0, 327670, 1, 0, 327671, 1, 0, 327672, 1, 0, 327673, 1, 0, 327674, 1, 0, 327675, 1, 0, 327676, 1, 0, 327677, 1, 0, 327678, 1, 0, 327679, 1, 0, 262144, 1, 0, 262145, 1, 0, 262146, 1, 0, 262147, 1, 0, 262148, 1, 0, 262149, 1, 0, 262150, 1, 0, 262151, 1, 0, 262152, 1, 0, 262153, 1, 0, 262154, 1, 0, 262155, 1, 0, 262156, 1, 0, 262157, 1, 0, 262158, 1, 0, 262159, 1, 0, 262160, 1, 0, 262161, 1, 0, 262162, 1, 0, 262163, 1, 0, 262164, 1, 0, 262165, 1, 0, 262166, 1, 0, 262167, 1, 0, 262168, 1, 0, 262169, 1, 0, 262170, 1, 0, 262171, 1, 0, 393203, 1, 0, 393204, 1, 0, 393205, 1, 0, 393206, 1, 0, 393207, 1, 0, 393208, 1, 0, 393209, 1, 0, 393210, 1, 0, 393211, 1, 0, 393212, 1, 0, 393213, 1, 0, 393214, 1, 0, 393215, 1, 0, 327680, 1, 0, 327681, 1, 0, 327682, 1, 0, 327683, 1, 0, 327684, 1, 0, 327685, 1, 0, 327686, 1, 0, 327687, 1, 0, 327688, 1, 0, 327689, 1, 0, 327690, 1, 0, 327691, 1, 0, 327692, 1, 0, 327693, 1, 0, 327694, 1, 0, 327695, 1, 0, 327696, 1, 0, 327697, 1, 0, 327698, 1, 0, 327699, 1, 0, 327700, 1, 0, 327701, 1, 0, 327702, 1, 0, 327703, 1, 0, 327704, 1, 0, 327705, 1, 0, 327706, 1, 0, 327707, 1, 0, 458739, 1, 0, 458740, 1, 0, 458741, 1, 0, 458742, 1, 0, 458743, 1, 0, 458744, 1, 0, 458745, 1, 0, 458746, 1, 0, 458747, 1, 0, 458748, 1, 0, 458749, 1, 0, 458750, 1, 0, 458751, 1, 0, 393216, 1, 0, 393217, 1, 0, 393218, 1, 0, 393219, 1, 0, 393220, 1, 0, 393221, 1, 0, 393222, 1, 0, 393223, 1, 0, 393224, 1, 0, 393225, 1, 0, 393226, 1, 0, 393227, 1, 0, 393228, 1, 0, 393229, 1, 0, 393230, 1, 0, 393231, 1, 0, 393232, 1, 0, 393233, 1, 0, 393234, 1, 0, 393235, 1, 0, 393236, 1, 0, 393237, 1, 0, 393238, 1, 0, 393239, 1, 0, 393240, 1, 0, 393241, 1, 0, 393242, 1, 0, 393243, 1, 0, 524275, 1, 0, 524276, 1, 0, 524277, 1, 0, 524278, 1, 0, 524279, 1, 0, 524280, 1, 0, 524281, 1, 0, 524282, 1, 0, 524283, 1, 0, 524284, 1, 0, 524285, 1, 0, 524286, 1, 0, 524287, 1, 0, 458752, 1, 0, 458753, 1, 0, 458754, 1, 0, 458755, 1, 0, 458756, 1, 0, 458757, 1, 0, 458758, 1, 0, 458759, 1, 0, 458760, 1, 0, 458761, 1, 0, 458762, 1, 0, 458763, 1, 0, 458764, 1, 0, 458765, 1, 0, 458766, 1, 0, 458767, 1, 0, 458768, 1, 0, 458769, 1, 0, 458770, 1, 0, 458771, 1, 0, 458772, 1, 0, 458773, 1, 0, 458774, 1, 0, 458775, 1, 0, 458776, 1, 0, 458777, 1, 0, 458778, 1, 0, 458779, 1, 0, 589811, 1, 0, 589812, 1, 0, 589813, 1, 0, 589814, 1, 0, 589815, 1, 0, 589816, 1, 0, 589817, 1, 0, 589818, 1, 0, 589819, 1, 0, 589820, 1, 0, 589821, 1, 0, 589822, 1, 0, 589823, 1, 0, 524288, 1, 0, 524289, 1, 0, 524290, 1, 0, 524291, 1, 0, 524292, 1, 0, 524293, 1, 0, 524294, 1, 0, 524295, 1, 0, 524296, 1, 0, 524297, 1, 0, 524298, 1, 0, 524299, 1, 0, 524300, 1, 0, 524301, 1, 0, 524302, 1, 0, 524303, 1, 0, 524304, 1, 0, 524305, 1, 0, 524306, 1, 0, 524307, 1, 0, 524308, 1, 0, 524309, 1, 0, 524310, 1, 0, 524311, 1, 0, 524312, 1, 0, 524313, 1, 0, 524314, 1, 0, 524315, 1, 0, 655347, 1, 0, 655348, 1, 0, 655349, 1, 0, 655350, 1, 0, 655351, 1, 0, 655352, 1, 0, 655353, 1, 0, 655354, 1, 0, 655355, 1, 0, 655356, 1, 0, 655357, 1, 0, 655358, 1, 0, 655359, 1, 0, 589824, 1, 0, 589825, 1, 0, 589826, 1, 0, 589827, 1, 0, 589828, 1, 0, 589829, 1, 0, 589830, 1, 0, 589831, 1, 0, 589832, 1, 0, 589833, 1, 0, 589834, 1, 0, 589835, 1, 0, 589836, 1, 0, 589837, 1, 0, 589838, 1, 0, 589839, 1, 0, 589840, 1, 0, 589841, 1, 0, 589842, 1, 0, 589843, 1, 0, 589844, 1, 0, 589845, 1, 0, 589846, 1, 0, 589847, 1, 0, 589848, 1, 0, 589849, 1, 0, 589850, 1, 0, 589851, 1, 0, 720883, 1, 0, 720884, 1, 0, 720885, 1, 0, 720886, 1, 0, 720887, 1, 0, 720888, 1, 0, 720889, 1, 0, 720890, 1, 0, 720891, 1, 0, 720892, 1, 0, 720893, 1, 0, 720894, 1, 0, 720895, 1, 0, 655360, 1, 0, 655361, 1, 0, 655362, 1, 0, 655363, 1, 0, 655364, 1, 0, 655365, 1, 0, 655366, 1, 0, 655367, 1, 0, 655368, 1, 0, 655369, 1, 0, 655370, 1, 0, 655371, 1, 0, 655372, 1, 0, 655373, 1, 0, 655374, 1, 0, 655375, 1, 0, 655376, 1, 0, 655377, 1, 0, 655378, 1, 0, 655379, 1, 0, 655380, 1, 0, 655381, 1, 0, 655382, 1, 0, 655383, 1, 0, 655384, 1, 0, 655385, 1, 0, 655386, 1, 0, 655387, 1, 0, 786419, 1, 0, 786420, 1, 0, 786421, 1, 0, 786422, 1, 0, 786423, 1, 0, 786424, 1, 0, 786425, 1, 0, 786426, 1, 0, 786427, 1, 0, 786428, 1, 0, 786429, 1, 0, 786430, 1, 0, 786431, 1, 0, 720896, 1, 0, 720897, 1, 0, 720898, 1, 0, 720899, 1, 0, 720900, 1, 0, 720901, 1, 0, 720902, 1, 0, 720903, 1, 0, 720904, 1, 0, 720905, 1, 0, 720906, 1, 0, 720907, 1, 0, 720908, 1, 0, 720909, 1, 0, 720910, 1, 0, 720911, 1, 0, 720912, 1, 0, 720913, 1, 0, 720914, 1, 0, 720915, 1, 0, 720916, 1, 0, 720917, 1, 0, 720918, 1, 0, 720919, 1, 0, 720920, 1, 0, 720921, 1, 0, 720922, 1, 0, 720923, 1, 0, 851955, 1, 0, 851956, 1, 0, 851957, 1, 0, 851958, 1, 0, 851959, 1, 0, 851960, 1, 0, 851961, 1, 0, 851962, 1, 0, 851963, 1, 0, 851964, 1, 0, 851965, 1, 0, 851966, 1, 0, 851967, 1, 0, 786432, 1, 0, 786433, 1, 0, 786434, 1, 0, 786435, 1, 0, 786436, 1, 0, 786437, 1, 0, 786438, 1, 0, 786439, 1, 0, 786440, 1, 0, 786441, 1, 0, 786442, 1, 0, 786443, 1, 0, 786444, 1, 0, 786445, 1, 0, 786446, 1, 0, 786447, 1, 0, 786448, 1, 0, 786449, 1, 0, 786450, 1, 0, 786451, 1, 0, 786452, 1, 0, 786453, 1, 0, 786454, 1, 0, 786455, 1, 0, 786456, 1, 0, 786457, 1, 0, 786458, 1, 0, 786459, 1, 0, 917491, 1, 0, 917492, 1, 0, 917493, 1, 0, 917494, 1, 0, 917495, 1, 0, 917496, 1, 0, 917497, 1, 0, 917498, 1, 0, 917499, 1, 0, 917500, 1, 0, 917501, 1, 0, 917502, 1, 0, 917503, 1, 0, 851968, 1, 0, 851969, 1, 0, 851970, 1, 0, 851971, 1, 0, 851972, 1, 0, 851973, 1, 0, 851974, 1, 0, 851975, 1, 0, 851976, 1, 0, 851977, 1, 0, 851978, 1, 0, 851979, 1, 0, 851980, 1, 0, 851981, 1, 0, 851982, 1, 0, 851983, 1, 0, 851984, 1, 0, 851985, 1, 0, 851986, 1, 0, 851987, 1, 0, 851988, 1, 0, 851989, 1, 0, 851990, 1, 0, 851991, 1, 0, 851992, 1, 0, 851993, 1, 0, 851994, 1, 0, 851995, 1, 0, 983027, 1, 0, 983028, 1, 0, 983029, 1, 0, 983030, 1, 0, 983031, 1, 0, 983032, 1, 0, 983033, 1, 0, 983034, 1, 0, 983035, 1, 0, 983036, 1, 0, 983037, 1, 0, 983038, 1, 0, 983039, 1, 0, 917504, 1, 0, 917505, 1, 0, 917506, 1, 0, 917507, 1, 0, 917508, 1, 0, 917509, 1, 0, 917510, 1, 0, 917511, 1, 0, 917512, 1, 0, 917513, 1, 0, 917514, 1, 0, 917515, 1, 0, 917516, 1, 0, 917517, 1, 0, 917518, 1, 0, 917519, 1, 0, 917520, 1, 0, 917521, 1, 0, 917522, 1, 0, 917523, 1, 0, 917524, 1, 0, 917525, 1, 0, 917526, 1, 0, 917527, 1, 0, 917528, 1, 0, 917529, 1, 0, 917530, 1, 0, 917531, 1, 0, 1048563, 1, 0, 1048564, 1, 0, 1048565, 1, 0, 1048566, 1, 0, 1048567, 1, 0, 1048568, 1, 0, 1048569, 1, 0, 1048570, 1, 0, 1048571, 1, 0, 1048572, 1, 0, 1048573, 1, 0, 1048574, 1, 0, 1048575, 1, 0, 983040, 1, 0, 983041, 1, 0, 983042, 1, 0, 983043, 1, 0, 983044, 1, 0, 983045, 1, 0, 983046, 1, 0, 983047, 1, 0, 983048, 1, 0, 983049, 1, 0, 983050, 1, 0, 983051, 1, 0, 983052, 1, 0, 983053, 1, 0, 983054, 1, 0, 983055, 1, 0, 983056, 1, 0, 983057, 1, 0, 983058, 1, 0, 983059, 1, 0, 983060, 1, 0, 983061, 1, 0, 983062, 1, 0, 983063, 1, 0, 983064, 1, 0, 983065, 1, 0, 983066, 1, 0, 983067, 1, 0, 1114099, 1, 0, 1114100, 1, 0, 1114101, 1, 0, 1114102, 1, 0, 1114103, 1, 0, 1114104, 1, 0, 1114105, 1, 0, 1114106, 1, 0, 1114107, 1, 0, 1114108, 1, 0, 1114109, 1, 0, 1114110, 1, 0, 1114111, 1, 0, 1048576, 1, 0, 1048577, 1, 0, 1048578, 1, 0, 1048579, 1, 0, 1048580, 1, 0, 1048581, 1, 0, 1048582, 1, 0, 1048583, 1, 0, 1048584, 1, 0, 1048585, 1, 0, 1048586, 1, 0, 1048587, 1, 0, 1048588, 1, 0, 1048589, 1, 0, 1048590, 1, 0, 1048591, 1, 0, 1048592, 1, 0, 1048593, 1, 0, 1048594, 1, 0, 1048595, 1, 0, 1048596, 1, 0, 1048597, 1, 0, 1048598, 1, 0, 1048599, 1, 0, 1048600, 1, 0, 1048601, 1, 0, 1048602, 1, 0, 1048603, 1, 0, 1179635, 1, 0, 1179636, 1, 0, 1179637, 1, 0, 1179638, 1, 0, 1179639, 1, 0, 1179640, 1, 0, 1179641, 1, 0, 1179642, 1, 0, 1179643, 1, 0, 1179644, 1, 0, 1179645, 1, 0, 1179646, 1, 0, 1179647, 1, 0, 1114112, 1, 0, 1114113, 1, 0, 1114114, 1, 0, 1114115, 1, 0, 1114116, 1, 0, 1114117, 1, 0, 1114118, 1, 0, 1114119, 1, 0, 1114120, 1, 0, 1114121, 1, 0, 1114122, 1, 0, 1114123, 1, 0, 1114124, 1, 0, 1114125, 1, 0, 1114126, 1, 0, 1114127, 1, 0, 1114128, 1, 0, 1114129, 1, 0, 1114130, 1, 0, 1114131, 1, 0, 1114132, 1, 0, 1114133, 1, 0, 1114134, 1, 0, 1114135, 1, 0, 1114136, 1, 0, 1114137, 1, 0, 1114138, 1, 0, 1114139, 1, 0, 1245171, 1, 0, 1245172, 1, 0, 1245173, 1, 0, 1245174, 1, 0, 1245175, 1, 0, 1245176, 1, 0, 1245177, 1, 0, 1245178, 1, 0, 1245179, 1, 0, 1245180, 1, 0, 1245181, 1, 0, 1245182, 1, 0, 1245183, 1, 0, 1179648, 1, 0, 1179649, 1, 0, 1179650, 1, 0, 1179651, 1, 0, 1179652, 1, 0, 1179653, 1, 0, 1179654, 1, 0, 1179655, 1, 0, 1179656, 1, 0, 1179657, 1, 0, 1179658, 1, 0, 1179659, 1, 0, 1179660, 1, 0, 1179661, 1, 0, 1179662, 1, 0, 1179663, 1, 0, 1179664, 1, 0, 1179665, 1, 0, 1179666, 1, 0, 1179667, 1, 0, 1179668, 1, 0, 1179669, 1, 0, 1179670, 1, 0, 1179671, 1, 0, 1179672, 1, 0, 1179673, 1, 0, 1179674, 1, 0, 1179675, 1, 0 ) -[node name="Path" type="TileMap" parent="Background"] +[node name="Path" type="TileMap" parent="Tilemaps/Background"] scale = Vector2( 10, 10 ) tile_set = SubResource( 2 ) cell_size = Vector2( 13, 13 ) @@ -669,7 +705,7 @@ collision_mask = 0 format = 1 tile_data = PoolIntArray( -655361, 0, 8, -720896, 0, 6, -720895, 0, 196609, -720894, 0, 196609, -720893, 0, 3, -720890, 0, 196608, -720889, 0, 196610, -720884, 0, 196611, -589825, 0, 65544, -655360, 0, 65547, -655357, 0, 131073, -655356, 0, 196610, -655351, 0, 196611, -524289, 0, 196616, -589824, 0, 196619, -65525, 0, 196608, -65524, 0, 3, 12, 0, 65536, 65536, 0, 8, 65537, 0, 10, 65538, 0, 10, 65539, 0, 10, 65540, 0, 10, 65541, 0, 10, 65542, 0, 10, 65543, 0, 10, 65544, 0, 11, 65548, 0, 65536, 196607, 0, 8, 131072, 0, 65541, 131073, 0, 65546, 131074, 0, 65546, 131075, 0, 65546, 131076, 0, 65546, 131077, 0, 65546, 131078, 0, 65546, 131079, 0, 65546, 131080, 0, 65542, 131081, 0, 11, 131084, 0, 65536, 131087, 0, 8, 131088, 0, 11, 262143, 0, 65544, 196608, 0, 65546, 196609, 0, 65546, 196610, 0, 65546, 196611, 0, 65546, 196612, 0, 65546, 196613, 0, 65546, 196614, 0, 65546, 196615, 0, 65546, 196616, 0, 65546, 196617, 0, 65547, 196619, 0, 8, 196620, 0, 65543, 196623, 0, 65544, 196624, 0, 65547, 327678, 0, 8, 327679, 0, 65541, 262144, 0, 65546, 262145, 0, 65546, 262146, 0, 65546, 262147, 0, 65546, 262148, 0, 65546, 262149, 0, 131078, 262150, 0, 196617, 262151, 0, 131077, 262152, 0, 65546, 262153, 0, 65542, 262154, 0, 10, 262155, 0, 65541, 262156, 0, 65542, 262157, 0, 11, 262159, 0, 65544, 262160, 0, 65547, 393214, 0, 196616, 393215, 0, 131077, 327680, 0, 65546, 327681, 0, 65546, 327682, 0, 65546, 327683, 0, 131078, 327684, 0, 196617, 327685, 0, 196619, 327687, 0, 196616, 327688, 0, 196617, 327689, 0, 131077, 327690, 0, 65546, 327691, 0, 65546, 327692, 0, 65546, 327693, 0, 65542, 327694, 0, 10, 327695, 0, 131082, 327696, 0, 196619, 458751, 0, 196616, 393216, 0, 196617, 393217, 0, 196617, 393218, 0, 196617, 393219, 0, 196619, 393225, 0, 196616, 393226, 0, 196617, 393227, 0, 196617, 393228, 0, 196617, 393229, 0, 196617, 393230, 0, 196618, 393231, 0, 196619, 458766, 0, 65536, 458768, 0, 196611, 524298, 0, 1, 524299, 0, 196609, 524300, 0, 3, 524302, 0, 65536, 589834, 0, 65536, 589836, 0, 131073, 589837, 0, 196609, 589838, 0, 131075, 589841, 0, 0, 655370, 0, 131072, 655377, 0, 131072, 720909, 0, 196611 ) -[node name="Inside" type="TileMap" parent="Background"] +[node name="Inside" type="TileMap" parent="Tilemaps/Background"] light_mask = 3 scale = Vector2( 10, 10 ) tile_set = SubResource( 41 ) @@ -681,7 +717,7 @@ collision_mask = 0 format = 1 tile_data = PoolIntArray( -589829, 2, 1, -589828, 2, 196609, -589827, 2, 196609, -589826, 2, 196610, -655359, 2, 0, -524293, 2, 65536, -524292, 3, 0, -524291, 3, 0, -524290, 3, 0, -524289, 4, 0, -589824, 4, 0, -589823, 2, 65536, -589818, 2, 1, -589817, 2, 196609, -589816, 2, 196609, -589815, 2, 196609, -589814, 2, 196609, -589813, 2, 196609, -589812, 2, 196609, -589811, 2, 196609, -589810, 2, 196609, -589809, 2, 196609, -589808, 2, 196609, -589807, 2, 3, -458757, 2, 65536, -458756, 4, 0, -458755, 4, 0, -458754, 4, 0, -458753, 4, 0, -524288, 4, 0, -524287, 2, 65536, -524282, 2, 65536, -524281, 3, 0, -524280, 3, 0, -524279, 3, 0, -524278, 3, 0, -524277, 3, 0, -524276, 3, 0, -524275, 3, 0, -524274, 3, 0, -524273, 3, 0, -524272, 3, 0, -524271, 2, 65536, -393221, 2, 65536, -393220, 4, 0, -393219, 4, 0, -393218, 4, 0, -393217, 4, 0, -458752, 4, 0, -458751, 2, 131073, -458750, 2, 196609, -458749, 2, 196609, -458748, 2, 196609, -458747, 2, 196609, -458746, 2, 131075, -458745, 4, 0, -458744, 4, 0, -458743, 4, 0, -458742, 4, 0, -458741, 4, 0, -458740, 4, 0, -458739, 4, 0, -458738, 4, 0, -458737, 4, 0, -458736, 4, 0, -458735, 2, 65536, -327685, 2, 65536, -327684, 4, 0, -327683, 4, 0, -327682, 4, 0, -327681, 4, 0, -393216, 4, 0, -393215, 3, 0, -393214, 3, 0, -393213, 3, 0, -393212, 3, 0, -393211, 3, 0, -393210, 3, 0, -393209, 4, 0, -393208, 4, 0, -393207, 4, 0, -393206, 4, 0, -393205, 4, 0, -393204, 4, 0, -393203, 4, 0, -393202, 4, 0, -393201, 4, 0, -393200, 4, 0, -393199, 2, 65536, -262149, 2, 65536, -262148, 4, 0, -262147, 4, 0, -262146, 4, 0, -262145, 4, 0, -327680, 4, 0, -327679, 4, 0, -327678, 4, 0, -327677, 4, 0, -327676, 4, 0, -327675, 4, 0, -327674, 4, 0, -327673, 4, 0, -327672, 4, 0, -327671, 2, 1, -327670, 2, 196609, -327669, 2, 196609, -327668, 2, 196609, -327667, 2, 3, -327666, 4, 0, -327665, 4, 0, -327664, 4, 0, -327663, 2, 65536, -196613, 2, 131073, -196612, 2, 196609, -196611, 2, 196609, -196610, 2, 3, -196609, 4, 0, -262144, 4, 0, -262143, 4, 0, -262142, 4, 0, -262141, 4, 0, -262140, 4, 0, -262139, 4, 0, -262138, 4, 0, -262137, 4, 0, -262136, 4, 0, -262135, 2, 65536, -262134, 1, 0, -262133, 0, 0, -262132, 1, 0, -262131, 2, 131073, -262130, 2, 3, -262129, 4, 0, -262128, 4, 0, -262127, 2, 65536, -131077, 1, 0, -131076, 0, 0, -131075, 1, 0, -131074, 2, 131073, -131073, 2, 196609, -196608, 2, 196609, -196607, 2, 196609, -196606, 2, 196609, -196605, 2, 196609, -196604, 2, 196609, -196603, 2, 196609, -196602, 2, 196609, -196601, 2, 196609, -196600, 2, 196609, -196599, 2, 131075, -196595, 1, 0, -196594, 2, 65536, -196593, 4, 0, -196592, 4, 0, -196591, 2, 65536, -65538, 1, 0, -65537, 0, 0, -131072, 1, 0, -131071, 0, 0, -131070, 1, 0, -131069, 0, 0, -131068, 1, 0, -131067, 0, 0, -131066, 1, 0, -131065, 0, 0, -131064, 1, 0, -131063, 0, 0, -131058, 2, 65536, -131057, 4, 0, -131056, 4, 0, -131055, 2, 65536, -65522, 2, 65536, -65521, 4, 0, -65520, 4, 0, -65519, 2, 131073, -65518, 2, 196609, -65517, 2, 196609, -65516, 2, 3, 14, 2, 65536, 15, 4, 0, 16, 4, 0, 17, 3, 0, 18, 3, 0, 19, 3, 0, 20, 2, 65536, 65550, 2, 131072, 65551, 4, 0, 65552, 4, 0, 65553, 4, 0, 65554, 4, 0, 65555, 4, 0, 65556, 2, 65536, 131086, 1, 0, 131087, 4, 0, 131088, 4, 0, 131089, 4, 0, 131090, 4, 0, 131091, 4, 0, 131092, 2, 65536, 196622, 4, 0, 196623, 4, 0, 196624, 4, 0, 196625, 4, 0, 196626, 4, 0, 196627, 4, 0, 196628, 2, 65536, 262158, 4, 0, 262159, 4, 0, 262160, 4, 0, 262161, 4, 0, 262164, 2, 65536, 327694, 2, 196608, 327695, 2, 196609, 327696, 2, 196609, 327697, 2, 196609, 327698, 2, 196609, 327699, 2, 196609, 327700, 2, 131075, 393230, 0, 0, 393231, 1, 0, 393232, 0, 0, 393233, 1, 0, 393234, 0, 0, 393235, 1, 0, 393236, 0, 0 ) -[node name="Spawn" type="TileMap" parent="Background"] +[node name="Spawn" type="TileMap" parent="Tilemaps/Background"] scale = Vector2( 10, 10 ) tile_set = SubResource( 42 ) cell_size = Vector2( 13, 13 ) @@ -691,9 +727,9 @@ collision_mask = 0 format = 1 tile_data = PoolIntArray( -458756, 1, 0, -458755, 1, 1, -458754, 1, 2, -393220, 1, 65536, -393219, 1, 65537, -393218, 1, 65538, -327684, 1, 65536, -327683, 1, 65537, -327682, 1, 65538, -262148, 1, 131072, -262147, 1, 131073, -262146, 1, 131074, 65553, 0, 0, 65554, 0, 1, 65555, 0, 2, 131089, 0, 65536, 131090, 0, 65537, 131091, 0, 65538, 196625, 0, 65536, 196626, 0, 65537, 196627, 0, 65538, 262161, 0, 131072, 262162, 0, 131073, 262163, 0, 131074 ) -[node name="Dynamic" type="YSort" parent="."] +[node name="Dynamic" type="YSort" parent="Tilemaps"] -[node name="Barriers" type="TileMap" parent="Dynamic"] +[node name="Barriers" type="TileMap" parent="Tilemaps/Dynamic"] scale = Vector2( 10, 10 ) tile_set = SubResource( 62 ) cell_size = Vector2( 13, 13 ) @@ -704,29 +740,59 @@ collision_mask = 0 format = 1 tile_data = PoolIntArray( 393222, 0, 196608, 393223, 0, 0, 393224, 0, 65537, 458760, 0, 131072, 458761, 0, 0, 458762, 0, 1, 458763, 0, 0, 458764, 0, 0, 458765, 0, 65537, 524301, 0, 196610, 524303, 0, 65538, 589835, 0, 65538, 589839, 0, 131074, 655371, 0, 131072, 655372, 0, 1, 655373, 0, 0, 655374, 0, 0, 655375, 0, 131073 ) -[node name="Foreground" type="Node2D" parent="."] +[node name="Foreground" type="Node2D" parent="Tilemaps"] z_index = 1 +[node name="Bosses" type="YSort" parent="."] + +[node name="Red" parent="Bosses" instance=ExtResource( 10 )] +position = Vector2( -242.993, -1017.08 ) + +[node name="Black" parent="Bosses" instance=ExtResource( 10 )] +position = Vector2( 2463.64, 176.88 ) +script = SubResource( 63 ) +type = 1 + +[node name="SpawnZones" type="Node2D" parent="."] + +[node name="ZoneRed" type="Area2D" parent="SpawnZones"] +position = Vector2( -409.254, -802.713 ) +collision_layer = 8 +collision_mask = 10 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="SpawnZones/ZoneRed"] +position = Vector2( 52.3496, 22.7908 ) +shape = SubResource( 64 ) + +[node name="ZoneBlack" type="Area2D" parent="SpawnZones"] +position = Vector2( 2407.1, 396.239 ) +collision_layer = 16 +collision_mask = 18 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="SpawnZones/ZoneBlack"] +position = Vector2( 30.9768, -6.34738 ) +shape = SubResource( 65 ) + [node name="SpawnPointsRed" type="Node2D" parent="."] position = Vector2( -6.10352e-05, -0.00012207 ) [node name="0" type="Position2D" parent="SpawnPointsRed"] -position = Vector2( -422.019, -602.768 ) +position = Vector2( -425.799, -606.548 ) [node name="1" type="Position2D" parent="SpawnPointsRed"] -position = Vector2( -282.703, -616.172 ) +position = Vector2( -312.941, -667.829 ) [node name="2" type="Position2D" parent="SpawnPointsRed"] -position = Vector2( -354.253, -754.013 ) +position = Vector2( -424.809, -752.753 ) [node name="3" type="Position2D" parent="SpawnPointsRed"] -position = Vector2( -211.811, -770.315 ) +position = Vector2( -209.291, -743.857 ) [node name="4" type="Position2D" parent="SpawnPointsRed"] -position = Vector2( -433.199, -941.217 ) +position = Vector2( -425.639, -883.261 ) [node name="5" type="Position2D" parent="SpawnPointsRed"] -position = Vector2( -291.215, -944.93 ) +position = Vector2( -316.413, -818.938 ) [node name="SpawnPointsBlack" type="Node2D" parent="."] position = Vector2( -6.10352e-05, -0.00012207 ) @@ -750,67 +816,71 @@ position = Vector2( 2279.61, 549.918 ) position = Vector2( 2542.72, 412.654 ) [node name="CandySpawners" type="Node2D" parent="."] +visible = false [node name="0" type="Position2D" parent="CandySpawners"] position = Vector2( 2015, -585 ) -script = ExtResource( 11 ) +script = ExtResource( 8 ) [node name="1" type="Position2D" parent="CandySpawners"] position = Vector2( 1885, -715 ) -script = ExtResource( 11 ) +script = ExtResource( 8 ) [node name="2" type="Position2D" parent="CandySpawners"] position = Vector2( 1495, -715 ) -script = ExtResource( 11 ) +script = ExtResource( 8 ) [node name="3" type="Position2D" parent="CandySpawners"] position = Vector2( 585, -585 ) -script = ExtResource( 11 ) +script = ExtResource( 8 ) [node name="4" type="Position2D" parent="CandySpawners"] position = Vector2( 325, -585 ) -script = ExtResource( 11 ) +script = ExtResource( 8 ) [node name="5" type="Position2D" parent="CandySpawners"] position = Vector2( 325, -975 ) -script = ExtResource( 11 ) +script = ExtResource( 8 ) [node name="6" type="Position2D" parent="CandySpawners"] position = Vector2( 455, -975 ) -script = ExtResource( 11 ) +script = ExtResource( 8 ) [node name="7" type="Position2D" parent="CandySpawners"] position = Vector2( 845, -1235 ) -script = ExtResource( 11 ) +script = ExtResource( 8 ) [node name="8" type="Position2D" parent="CandySpawners"] position = Vector2( 2535, -325 ) -script = ExtResource( 11 ) +script = ExtResource( 8 ) [node name="9" type="Position2D" parent="CandySpawners"] position = Vector2( 325, 715 ) -script = ExtResource( 11 ) +script = ExtResource( 8 ) [node name="10" type="Position2D" parent="CandySpawners"] position = Vector2( 195, 715 ) -script = ExtResource( 11 ) +script = ExtResource( 8 ) [node name="11" type="Position2D" parent="CandySpawners"] position = Vector2( 65, 585 ) -script = ExtResource( 11 ) +script = ExtResource( 8 ) [node name="12" type="Position2D" parent="CandySpawners"] position = Vector2( -455, 585 ) -script = ExtResource( 11 ) +script = ExtResource( 8 ) [node name="13" type="Position2D" parent="CandySpawners"] position = Vector2( -585, -65 ) -script = ExtResource( 11 ) +script = ExtResource( 8 ) [node name="14" type="Position2D" parent="CandySpawners"] position = Vector2( -845, -455 ) -script = ExtResource( 11 ) +script = ExtResource( 8 ) [node name="15" type="Position2D" parent="CandySpawners"] position = Vector2( 1495, -65 ) -script = ExtResource( 11 ) +script = ExtResource( 8 ) + +[connection signal="body_entered" from="SpawnZones/ZoneRed" to="." method="_on_home_body_entered"] +[connection signal="body_entered" from="SpawnZones/ZoneBlack" to="." method="_on_home_body_entered"] diff --git a/src/scripts/gamestate.gd b/src/scripts/gamestate.gd index 9ad04a4..695ff80 100644 --- a/src/scripts/gamestate.gd +++ b/src/scripts/gamestate.gd @@ -93,15 +93,15 @@ Start / stop game #####################""" -remote func pre_start_game(players_init): +remote func pre_start_game(players_init: Dictionary): print(players_init) - var game = load("res://src/Game.tscn").instance() + var game = preload("res://src/game.tscn").instance() get_tree().get_root().add_child(game) # Hide the LocalConnection node (not remove it) get_tree().get_root().get_node("LocalConnection").hide() # Init the Game node - game.init(players_init, self.server_only) + game.init(players_init) # Tell server we are ready to start if not get_tree().is_network_server(): @@ -133,6 +133,13 @@ Getters and setters func get_players_list(): return self.players +# Returns the player list except the server (id = 1) if it's present +func get_clients_list(): + if self.server_only: + return self.get_players_list() + var clients = self.players.duplicate() + clients.erase(1) + return clients func get_player_name(): return self.player_name @@ -207,8 +214,8 @@ remote func ready_to_start(): # Wait for every player to be ready if id_players_ready.size() == players.size(): # If everyone is ready - for p in players: - rpc_id(p, "post_start_game") + for player_id in self.get_clients_list(): + rpc_id(player_id, "post_start_game") post_start_game() @@ -222,19 +229,19 @@ func begin_game(): # setup teams and player genders var all_players = players.duplicate(false) # all_players[1] = player_name - var players_init = {} + var players_init: Dictionary = {} for id in all_players: players_init[id] = { "name": all_players[id], "gender": randf() > 0.5, - "team": team_toggler + "team": int(team_toggler) } team_toggler = not team_toggler # tell everyone to get ready - for p in all_players: - rpc_id(p, "pre_start_game", players_init) + for id in self.get_clients_list(): + rpc_id(id, "pre_start_game", players_init) pre_start_game(players_init) diff --git a/src/scripts/server/candySpawner.gd b/src/scripts/server/candySpawner.gd deleted file mode 100644 index 056e206..0000000 --- a/src/scripts/server/candySpawner.gd +++ /dev/null @@ -1,17 +0,0 @@ -extends Node - - -# 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(): - print("I AM LOADED") - #pass # Replace with function body. - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - print("Spawn candy") diff --git a/src/scripts/server/candySpawners/CandySpawners.gd b/src/scripts/server/candySpawners/CandySpawners.gd index ae68580..ec90643 100644 --- a/src/scripts/server/candySpawners/CandySpawners.gd +++ b/src/scripts/server/candySpawners/CandySpawners.gd @@ -25,5 +25,6 @@ func _on_Timer_timeout(): if available_spawners.size() == 0: return + # Choose a random spawner var spawner:Position2D = available_spawners[randi() % available_spawners.size()] spawner.server_spawn() diff --git a/src/scripts/server/candySpawners/CandySpawners.tscn b/src/scripts/server/candySpawners/CandySpawners.tscn index 1d18a88..a174600 100644 --- a/src/scripts/server/candySpawners/CandySpawners.tscn +++ b/src/scripts/server/candySpawners/CandySpawners.tscn @@ -6,7 +6,6 @@ script = ExtResource( 1 ) [node name="Timer" type="Timer" parent="."] -wait_time = 0.1 autostart = true [connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"] diff --git a/src/scripts/server/candySpawners/spawner.gd b/src/scripts/server/candySpawners/spawner.gd index fc7539a..c92ec8f 100644 --- a/src/scripts/server/candySpawners/spawner.gd +++ b/src/scripts/server/candySpawners/spawner.gd @@ -1,9 +1,16 @@ extends Position2D +class_name Spawner export var spawned: bool = false -var candy_scene +var candy_scene: Resource +var types = [ + preload("res://src/actors/candy/types/mandarinLarge.gd"), + preload("res://src/actors/candy/types/mandarinSmall.gd"), + preload("res://src/actors/candy/types/peanutLarge.gd"), + preload("res://src/actors/candy/types/peanutSmall.gd") +] # Called when the node enters the scene tree for the first time. func _ready(): @@ -14,26 +21,30 @@ func _ready(): func server_spawn(): assert(get_tree().is_network_server()) + var candy_type: int = randi() % types.size() + self.spawned = true - for id in gamestate.get_players_list(): - rpc_id(id, "spawn_candy") + for id in gamestate.get_clients_list(): + rpc_id(id, "spawn_candy", candy_type) - self.spawn_candy() + self.spawn_candy(candy_type) -# Canned on every client -remote func spawn_candy(): - var candy: Node2D = self.candy_scene.instance() +# Called on every client +remote func spawn_candy(candy_type: int): + var candy = self.candy_scene.instance() + candy.set_script(types[candy_type]) candy.set_network_master(1) - #if get_tree().is_network_server(): - # candy.position = self.position - #else: + candy.targeted_position = self.position candy.position = self.position - if get_tree().is_network_server(): candy.spawner = self candy.set_collision_player(true) get_node("../../../Candies").add_child(candy) + + +func candy_taken(): + self.spawned = false diff --git a/src/scripts/server/trails/Trails.gd b/src/scripts/server/trails/Trails.gd index 5faa750..e402310 100644 --- a/src/scripts/server/trails/Trails.gd +++ b/src/scripts/server/trails/Trails.gd @@ -5,6 +5,11 @@ const PLAYER_LINE_DISTANCE_DRAW = 100 const DISTANCE_BETWEEN_CANDIES = 120 +"""######################################## + INIT +########################################""" + + # Called when the node enters the scene tree for the first time. func init(players_node: Node2D): var players = gamestate.get_players_list() @@ -14,23 +19,37 @@ func init(players_node: Node2D): var line_2d = Line2D.new() line_2d.set_name(str(id)) - line_2d.set_default_color(Color(1, 1, 1, 0)) + line_2d.set_default_color(Color(1, 1, 1, 0.0)) add_child(line_2d) line_2d.add_point(p.get_position()) line_2d.add_point(p.get_position()) +"""######################################## + PROCESS +########################################""" + + # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): var players = get_tree().get_root().get_node("Game/YSort/Players") + # Create the lines behind the players - self.draw_lines(players) + self.place_trails(players) # Place the candies self.place_candies(players) + # Collect the candies which have to be collected + self.collect_candies(players) + -func draw_lines(players): +"""######################################## + PLAYER TRAILS +########################################""" + + +func place_trails(players): for p in players.get_children(): var id = p.get_name() var line = self.get_node(id) @@ -42,6 +61,11 @@ func draw_lines(players): line.add_point(p.position, 0) +"""######################################## + PLACE CANDIES +########################################""" + + func place_candies(players): for p in players.get_children(): var trail: Line2D = get_tree().get_root().get_node("Game/Trails/" + p.get_name()) @@ -51,14 +75,24 @@ func place_candies(players): # the index of the current point in on the player's trail var i: int = 0 var segment_lengh = distance_between_trail_points(trail, i) + var end_of_trail: bool = false for c in p.trail: # for each candy the player has picked up - while remaining_dist > segment_lengh: + while remaining_dist > segment_lengh and not end_of_trail: remaining_dist -= segment_lengh - i += 1 - segment_lengh = distance_between_trail_points(trail, i) + if trail.points.size()-1 < i+2: + end_of_trail = true + else: + i += 1 + segment_lengh = distance_between_trail_points(trail, i) + # place the candy somewhere in this segment of the line + + # div by zero protection + if segment_lengh == 0: + segment_lengh = 1 var factor = remaining_dist / segment_lengh + if end_of_trail: factor = 1 c.targeted_position = lerp(trail.points[i], trail.points[i+1], factor) @@ -66,9 +100,54 @@ func place_candies(players): remaining_dist = self.DISTANCE_BETWEEN_CANDIES + remaining_dist -# Returns the distance between the points i and i+1 +# Returns the distance between the points i and i+10 func distance_between_trail_points(trail: Line2D, i: int) -> float : return sqrt( pow(trail.points[i].x - trail.points[i+1].x, 2) + pow(trail.points[i].y - trail.points[i+1].y, 2) ) + + +"""######################################## + COLLECT CANDIES +########################################""" + + +func collect_candies(players: Node2D): + pass + + +"""######################################## + SLOTS +########################################""" + + +func clear_trail(player: Player): + assert(get_tree().is_network_server()) + + var line_2d: Line2D = get_node(player.get_name()) + line_2d.clear_points() + line_2d.add_point(player.get_position()) + line_2d.add_point(player.get_position()) + + for c in player.trail: + c = c as Candy + c.delete() + player.trail.clear() + + # TODO animate candies collection + """ + var old_line_2d = get_node(player.get_name()) + var new_line_2d = Line2D.new() + + old_line_2d.set_name(old_line_2d.get_name() + "_collect_candies") + print(old_line_2d.get_name()) + remove_child(old_line_2d) + $Collect.add_child(old_line_2d) + + new_line_2d.set_name(str(player.get_name())) + new_line_2d.set_default_color(Color(1, 1, 1, 0.5)) + add_child(new_line_2d) + new_line_2d.add_point(player.get_position()) + new_line_2d.add_point(player.get_position()) + """ diff --git a/src/scripts/server/trails/Trails.tscn b/src/scripts/server/trails/Trails.tscn index 6a04fd0..05054ab 100644 --- a/src/scripts/server/trails/Trails.tscn +++ b/src/scripts/server/trails/Trails.tscn @@ -4,3 +4,5 @@ [node name="Trails" type="Node2D"] script = ExtResource( 1 ) + +[node name="Collect" type="Node2D" parent="."] diff --git a/src/ui/components/ProgressBar.gd b/src/ui/components/ProgressBar.gd new file mode 100644 index 0000000..cbdfad8 --- /dev/null +++ b/src/ui/components/ProgressBar.gd @@ -0,0 +1,20 @@ +extends Control + + +# 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(): + pass + + +func update_progressbar(points: Dictionary): + print(points) + $LabelRed.set_text(str(points['red'])) + $LabelBlack.set_text(str(points['black'])) + if points['red'] != 0 or points['black'] != 0: + var ratio: float = float(points['red']) / float(points['red'] + points['black']) + $ProgressBar.set_value(ratio) diff --git a/src/ui/components/ProgressBar.tscn b/src/ui/components/ProgressBar.tscn new file mode 100644 index 0000000..f90945f --- /dev/null +++ b/src/ui/components/ProgressBar.tscn @@ -0,0 +1,58 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://src/ui/components/ProgressBar.gd" type="Script" id=1] + +[sub_resource type="StyleBoxFlat" id=1] +bg_color = Color( 0.694118, 0, 0, 1 ) + +[sub_resource type="StyleBoxFlat" id=2] +bg_color = Color( 0.184314, 0.176471, 0.176471, 1 ) + +[node name="ProgressBar" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="LabelRed" type="Label" parent="."] +anchor_left = 0.5 +anchor_right = 0.5 +margin_left = -193.489 +margin_top = 40.5866 +margin_right = -153.489 +margin_bottom = 54.5866 +text = "0" +align = 2 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ProgressBar" type="ProgressBar" parent="."] +anchor_left = 0.5 +anchor_right = 0.5 +margin_left = -144.0 +margin_top = 40.5866 +margin_right = 143.0 +margin_bottom = 54.5866 +custom_styles/fg = SubResource( 1 ) +custom_styles/bg = SubResource( 2 ) +max_value = 1.0 +value = 0.5 +percent_visible = false +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="LabelBlack" type="Label" parent="."] +anchor_left = 0.5 +anchor_right = 0.5 +margin_left = 149.945 +margin_top = 41.2764 +margin_right = 189.945 +margin_bottom = 55.2764 +text = "0" +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/src/ui/game-hud.tscn b/src/ui/game-hud.tscn index 96003b5..f3de7a3 100644 --- a/src/ui/game-hud.tscn +++ b/src/ui/game-hud.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=3 format=2] [ext_resource path="res://src/ui/components/Joystick.tscn" type="PackedScene" id=1] +[ext_resource path="res://src/ui/components/ProgressBar.tscn" type="PackedScene" id=2] [node name="HUD" type="Control"] anchor_right = 1.0 @@ -15,3 +16,5 @@ margin_left = 20.0 margin_top = -370.0 margin_right = 20.0 margin_bottom = -370.0 + +[node name="ProgressBar" parent="." instance=ExtResource( 2 )]