diff --git a/project.godot b/project.godot index 8401bc7..a69e0ac 100644 --- a/project.godot +++ b/project.godot @@ -17,7 +17,8 @@ config/icon="res://icon.png" [autoload] -Event="*res://scenes/Event.cs" +Event="*res://scripts/Event.cs" +Game="*res://scenes/game/Game.tscn" [display] diff --git a/scenes/game/Game.cs b/scenes/game/Game.cs new file mode 100644 index 0000000..799297f --- /dev/null +++ b/scenes/game/Game.cs @@ -0,0 +1,31 @@ +using Godot; + +public sealed class Game : Node +{ + [Export] + private int _energy { get; set; } = 3; + [Export] + private int _bolts { get; set; } = 0; + + public enum PhysicsLayer : ushort { + Player = 1, + Platform = 2, + Enemy = 3, + Collectable = 4 + } + + public override void _Ready() + { + var eventBus = GetNode("/root/Event"); + eventBus.Connect("EnergyCollected", this, "OnEnergyCollected"); + } + + private void OnEnergyCollected(int energy) + { + _energy += energy; + if (OS.IsDebugBuild()) + { + GD.Print("Energy: " + _energy); + } + } +} diff --git a/scenes/game/Game.tscn b/scenes/game/Game.tscn new file mode 100644 index 0000000..02b25da --- /dev/null +++ b/scenes/game/Game.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://scenes/game/Game.cs" type="Script" id=1] + +[node name="Game" type="Node"] +script = ExtResource( 1 )