From 20bc188ad2bfb5d63bf3411ea77a92b575917973 Mon Sep 17 00:00:00 2001 From: Maxwell Edwards <93385879+MaxEdwards20@users.noreply.github.com> Date: Thu, 28 Mar 2024 15:44:12 -0600 Subject: [PATCH] Blueprint (#16) * Adds more TODO items throughout the code * Renames files --- .github/workflows/dotnet.yml | 4 +-- README.md | 8 +++-- src/Client/{IO => Menu}/IInputDevice.cs | 0 src/Client/{IO => Menu}/MenuKeyboardInput.cs | 3 +- src/Client/Menu/SelectControlsView.cs | 33 +++++++++++++++++++ src/Client/Systems/Camera.cs | 11 +++++++ src/Client/Systems/CollisionDetection.cs | 10 ++++++ src/Client/Systems/MouseInput.cs | 8 +++-- src/Client/Systems/ParticleEffects.cs | 6 ++++ src/Client/Systems/WormMovement.cs | 8 +++-- ...Entity Interpolation.sln => DuneSnake.sln} | 0 src/Shared/Components/LifeTime.cs | 15 +++++++++ src/Shared/Components/Particle.cs | 6 ++++ src/Shared/Components/SpicePower.cs | 20 +++++++++++ src/Shared/Entities/Particle.cs | 19 +++++++++++ src/Shared/Entities/Player.cs | 28 ---------------- src/Shared/Entities/Spice.cs | 1 + src/Shared/Entities/Utility.cs | 2 ++ src/Shared/Entities/WormHead.cs | 2 ++ 19 files changed, 145 insertions(+), 39 deletions(-) rename src/Client/{IO => Menu}/IInputDevice.cs (100%) rename src/Client/{IO => Menu}/MenuKeyboardInput.cs (99%) create mode 100644 src/Client/Menu/SelectControlsView.cs create mode 100644 src/Client/Systems/Camera.cs create mode 100644 src/Client/Systems/CollisionDetection.cs create mode 100644 src/Client/Systems/ParticleEffects.cs rename src/{Entity Interpolation.sln => DuneSnake.sln} (100%) create mode 100644 src/Shared/Components/LifeTime.cs create mode 100644 src/Shared/Components/Particle.cs create mode 100644 src/Shared/Components/SpicePower.cs create mode 100644 src/Shared/Entities/Particle.cs delete mode 100644 src/Shared/Entities/Player.cs diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index f457a0d..fd57fd9 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -16,6 +16,6 @@ jobs: with: dotnet-version: 6.0.x - name: Restore dependencies - run: dotnet restore src/Entity\ Interpolation.sln + run: dotnet restore src/DuneSnake.sln - name: Build - run: dotnet build src/Entity\ Interpolation.sln --no-restore + run: dotnet build src/DuneSnake.sln --no-restore diff --git a/README.md b/README.md index d64a7a0..4235ab5 100644 --- a/README.md +++ b/README.md @@ -16,11 +16,13 @@ A game of Snake built using C# in the MonoGame framework, themed around everyone ## Items to Develop -- [ ] Animated Sprite for the spice - Satchel +- [ ] 3 different animated sprites for the spice - Satchel - [ ] Collision detection. Know whether we hit spice or another sandworm +- [ ] Keyboard vs. Mouse input menu screen +- [ ] Camera movement - [ ] Map generation - [ ] Let player name themselves -- [ ] Mouse input support - Satchel +- [ ] Mouse input support - Satchel - [ ] Food generation that refreshes as we play the game - [ ] On collision, sandworm breaks apart and is available as food for other snakes - [ ] Record players score, kills and highest position. Probably can be added to the `GameScores` object. @@ -28,8 +30,8 @@ A game of Snake built using C# in the MonoGame framework, themed around everyone - [ ] Particle system for the death of a sandworm - [ ] Sound effects on death of worm and when food is eaten - Satchel - ## Done :) + - [x] MAX: Decide how to build the snake. Tons of entities? Or one entity with a list of positions? - [x] MAX: Setup basic menuing diff --git a/src/Client/IO/IInputDevice.cs b/src/Client/Menu/IInputDevice.cs similarity index 100% rename from src/Client/IO/IInputDevice.cs rename to src/Client/Menu/IInputDevice.cs diff --git a/src/Client/IO/MenuKeyboardInput.cs b/src/Client/Menu/MenuKeyboardInput.cs similarity index 99% rename from src/Client/IO/MenuKeyboardInput.cs rename to src/Client/Menu/MenuKeyboardInput.cs index 1a87949..295620c 100644 --- a/src/Client/IO/MenuKeyboardInput.cs +++ b/src/Client/Menu/MenuKeyboardInput.cs @@ -16,8 +16,7 @@ namespace Client.IO /// Derived input device for the PC Keyboard /// // Added to support serialization - - + public class MenuKeyboardInput : IInputDevice { private KeyboardState m_statePrevious = Keyboard.GetState(); diff --git a/src/Client/Menu/SelectControlsView.cs b/src/Client/Menu/SelectControlsView.cs new file mode 100644 index 0000000..2a61ccb --- /dev/null +++ b/src/Client/Menu/SelectControlsView.cs @@ -0,0 +1,33 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Content; + +namespace Client.Menu; + +// TODO +public class SelectControlsView : GameStateView +{ + public override void loadContent(ContentManager contentManager) + { + throw new System.NotImplementedException(); + } + + public override MenuStateEnum processInput(GameTime gameTime) + { + throw new System.NotImplementedException(); + } + + public override void update(GameTime gameTime) + { + throw new System.NotImplementedException(); + } + + public override void RegisterCommands() + { + throw new System.NotImplementedException(); + } + + public override void render(GameTime gameTime) + { + throw new System.NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/Client/Systems/Camera.cs b/src/Client/Systems/Camera.cs new file mode 100644 index 0000000..e41cf34 --- /dev/null +++ b/src/Client/Systems/Camera.cs @@ -0,0 +1,11 @@ +using System; + +namespace Client.Systems; + +public class Camera : Shared.Systems.System +{ + public override void update(TimeSpan elapsedTime) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/Client/Systems/CollisionDetection.cs b/src/Client/Systems/CollisionDetection.cs new file mode 100644 index 0000000..d645076 --- /dev/null +++ b/src/Client/Systems/CollisionDetection.cs @@ -0,0 +1,10 @@ +using System; + +namespace Client.Systems; + +public class CollisionDetection : Shared.Systems.System +{ + public override void update(TimeSpan elapsedTime) + { + } +} \ No newline at end of file diff --git a/src/Client/Systems/MouseInput.cs b/src/Client/Systems/MouseInput.cs index 3dfee17..9765ed0 100644 --- a/src/Client/Systems/MouseInput.cs +++ b/src/Client/Systems/MouseInput.cs @@ -1,6 +1,10 @@ +using System; + namespace Client.Systems; -public class MouseInput +public class MouseInput : Shared.Systems.System { - + public override void update(TimeSpan elapsedTime) + { + } } \ No newline at end of file diff --git a/src/Client/Systems/ParticleEffects.cs b/src/Client/Systems/ParticleEffects.cs new file mode 100644 index 0000000..f99fe85 --- /dev/null +++ b/src/Client/Systems/ParticleEffects.cs @@ -0,0 +1,6 @@ +namespace Client.Systems; + +public class ParticleEffects +{ + +} \ No newline at end of file diff --git a/src/Client/Systems/WormMovement.cs b/src/Client/Systems/WormMovement.cs index 4e7798c..10f80d5 100644 --- a/src/Client/Systems/WormMovement.cs +++ b/src/Client/Systems/WormMovement.cs @@ -1,6 +1,10 @@ +using System; + namespace Client.Systems; -public class WormMovement +public class WormMovement : Shared.Systems.System { - + public override void update(TimeSpan elapsedTime) + { + } } \ No newline at end of file diff --git a/src/Entity Interpolation.sln b/src/DuneSnake.sln similarity index 100% rename from src/Entity Interpolation.sln rename to src/DuneSnake.sln diff --git a/src/Shared/Components/LifeTime.cs b/src/Shared/Components/LifeTime.cs new file mode 100644 index 0000000..41841d0 --- /dev/null +++ b/src/Shared/Components/LifeTime.cs @@ -0,0 +1,15 @@ +namespace Shared.Components; + +public class LifeTime: Component +{ + public TimeSpan lifeTime { get; private set; } + public LifeTime(TimeSpan lifeTime) + { + this.lifeTime = lifeTime; + } + + public void update(TimeSpan elapsedTime) + { + lifeTime -= elapsedTime; + } +} \ No newline at end of file diff --git a/src/Shared/Components/Particle.cs b/src/Shared/Components/Particle.cs new file mode 100644 index 0000000..7f51f2e --- /dev/null +++ b/src/Shared/Components/Particle.cs @@ -0,0 +1,6 @@ +namespace Shared.Components; + +public class Particle: Component +{ + +} \ No newline at end of file diff --git a/src/Shared/Components/SpicePower.cs b/src/Shared/Components/SpicePower.cs new file mode 100644 index 0000000..321e95f --- /dev/null +++ b/src/Shared/Components/SpicePower.cs @@ -0,0 +1,20 @@ +namespace Shared.Components; + +public class SpicePower: Component +{ + public int power { get; private set; } + public SpicePower(int power) + { + this.power = power; + } + + public void addPower(int power) + { + this.power += power; + } + + public void removePower(int power) + { + this.power -= power; + } +} \ No newline at end of file diff --git a/src/Shared/Entities/Particle.cs b/src/Shared/Entities/Particle.cs new file mode 100644 index 0000000..539c299 --- /dev/null +++ b/src/Shared/Entities/Particle.cs @@ -0,0 +1,19 @@ +using Microsoft.Xna.Framework; +using Shared.Components; +using Shared.Components.Appearance; + +namespace Shared.Entities; + +public class Particle +{ + public Entity create( Vector2 position, Vector2 velocity, Vector2 size, TimeSpan lifeTime, float moveRate, float rotationRate ) + { + Entity entity = new Entity(); + entity.add(new Position(position)); + entity.add(new Movement(moveRate, rotationRate)); + entity.add(new Appearance("Textures/particle")); // TODO + entity.add(new Size(size)); + entity.add(new LifeTime(lifeTime)); + return entity; + } +} \ No newline at end of file diff --git a/src/Shared/Entities/Player.cs b/src/Shared/Entities/Player.cs deleted file mode 100644 index 550263f..0000000 --- a/src/Shared/Entities/Player.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.Xna.Framework; -using Shared.Components; -using Shared.Components.Appearance; -using Shared.Systems; - -namespace Shared.Entities -{ - public class Player - { - public static Entity create(Color color, Vector2 position, float size, float moveRate, float rotateRate) - { - Entity entity = new Entity(); - entity.add(new Position(position)); - entity.add(new Size(new Vector2(size, size))); - entity.add(new Movement(moveRate, rotateRate)); - - List inputs = new List(); - inputs.Add(Input.Type.SnakeUp); - inputs.Add(Input.Type.RotateLeft); - inputs.Add(Input.Type.RotateRight); - inputs.Add(Input.Type.SnakeDown); - inputs.Add(Input.Type.Boost); - entity.add(new Input(inputs)); - - return entity; - } - } -} diff --git a/src/Shared/Entities/Spice.cs b/src/Shared/Entities/Spice.cs index d66b5ad..a3648e6 100644 --- a/src/Shared/Entities/Spice.cs +++ b/src/Shared/Entities/Spice.cs @@ -13,6 +13,7 @@ public Entity create(Color color, Vector2 position, float size) entity.add(new Position(position)); entity.add(new Size(new Vector2(size, size))); entity.add(new Collision()); + entity.add(new SpicePower(0)); return entity; } } \ No newline at end of file diff --git a/src/Shared/Entities/Utility.cs b/src/Shared/Entities/Utility.cs index a349b8b..621c483 100644 --- a/src/Shared/Entities/Utility.cs +++ b/src/Shared/Entities/Utility.cs @@ -3,6 +3,8 @@ namespace Shared.Entities; + +// NOTE: We will probably move this over to the wormMovement system where behavior lives public class Utility { public static void thrust(Entity entity, TimeSpan elapsedTime) diff --git a/src/Shared/Entities/WormHead.cs b/src/Shared/Entities/WormHead.cs index aedee89..81b07b9 100644 --- a/src/Shared/Entities/WormHead.cs +++ b/src/Shared/Entities/WormHead.cs @@ -4,6 +4,7 @@ namespace Shared.Entities; +// This is the Player. We only move the head, all the other parts of the snake follow. public class WormHead { public static Entity create(Color color, Vector2 position, float size, float moveRate, float rotateRate) @@ -15,6 +16,7 @@ public static Entity create(Color color, Vector2 position, float size, float mov entity.add(new Size(new Vector2(size, size))); entity.add(new Movement(moveRate, rotateRate)); entity.add(new Collision()); + entity.add(new SpicePower(0)); List inputs = new List(); inputs.Add(Input.Type.SnakeUp);