Skip to content

Commit

Permalink
Fixes bug on leaderboard placement (#117)
Browse files Browse the repository at this point in the history
* Fixes bug on leaderboard placement

* new gameplay pic
  • Loading branch information
MaxEdwards20 authored Apr 19, 2024
1 parent 8747315 commit eedea1e
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 39 deletions.
Binary file modified gameplay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions src/Client/ClientMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public ClientMain()
protected override void Initialize()
{
// For Graders: You can change the resolution here
// m_graphics.PreferredBackBufferWidth = 1920;
// m_graphics.PreferredBackBufferHeight = 1080;
m_graphics.PreferredBackBufferWidth = 1920/2;
m_graphics.PreferredBackBufferHeight = 1080/2;
m_graphics.PreferredBackBufferWidth = 1920;
m_graphics.PreferredBackBufferHeight = 1080;
// m_graphics.PreferredBackBufferWidth = 1920/2;
// m_graphics.PreferredBackBufferHeight = 1080/2;
m_graphics.ApplyChanges();

// Load the controls
Expand Down
5 changes: 0 additions & 5 deletions src/Client/GameModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class GameModel
private Systems.Interpolation m_systemInterpolation;
private Systems.Renderer m_renderer;
private Shared.Systems.WormMovement m_systemWormMovement;
private Shared.Systems.GrowthHandler m_systemGrowthHandler;
private Controls m_controls;
private GraphicsDeviceManager m_graphics;
private SpriteFont m_font;
Expand Down Expand Up @@ -65,7 +64,6 @@ public void update(TimeSpan elapsedTime)
{
m_systemNetwork.update(elapsedTime, MessageQueueClient.instance.getMessages(), m_playerData);
m_systemKeyboardInput.update(elapsedTime);
m_systemGrowthHandler.update(elapsedTime);
m_systemWormMovement.update(elapsedTime);
m_systemInterpolation.update(elapsedTime);
m_systemCamera.update(elapsedTime);
Expand Down Expand Up @@ -110,7 +108,6 @@ public bool initialize(ContentManager contentManager, Controls controls, Graphic
m_systemCamera = new Systems.Camera(new Vector2(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), m_playerData);

m_renderer = new Systems.Renderer(m_systemCamera, graphics, m_font, m_fontSmall, m_sand, m_contentManager);
m_systemGrowthHandler = new Shared.Systems.GrowthHandler();
m_systemWormMovement = new Shared.Systems.WormMovement();
m_systemNetwork = new Systems.Network(m_playerName, m_playerData);

Expand Down Expand Up @@ -300,7 +297,6 @@ private void addEntity(Entity entity)
// NOTE: Update the systems we use here
m_entities[entity.id] = entity;
m_systemKeyboardInput.add(entity);
m_systemGrowthHandler.add(entity);
m_systemWormMovement.add(entity);
m_renderer.add(entity);
m_systemNetwork.add(entity);
Expand All @@ -320,7 +316,6 @@ private void removeEntity(uint id)
m_systemScore.SaveScore(m_entities[id]); // We call this every time
m_entities.Remove(id);
m_systemKeyboardInput.remove(id);
m_systemGrowthHandler.remove(id);
m_systemWormMovement.remove(id);
m_systemNetwork.remove(id);
m_renderer.remove(id);
Expand Down
1 change: 1 addition & 0 deletions src/Client/Systems/Network.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ private void handleUpdateEntity(TimeSpan elapsedTime, UpdateEntity message, Play
}
}
heads.Sort((a, b) => a.get<Stats>().Score.CompareTo(b.get<Stats>().Score));
heads.Reverse(); // Largest to smallest
playerData.addPosition(heads.IndexOf(entity) + 1);
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/Server/GameModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class GameModel
private readonly Dictionary<int, uint> m_clientToEntityId = new();
private readonly WormMovement m_systemWormMovement = new();
private readonly CollisionDetection m_systemCollisionDetection = new();
private readonly GrowthHandler m_SystemGrowthHandler = new();
private readonly Network m_systemNetwork = new();
private readonly SpiceGen m_systemSpiceGen = new(MapSize.MAP_SIZE - 200, 300);
private const int wallSize = 100;
Expand All @@ -30,7 +29,6 @@ public void update(TimeSpan elapsedTime)
{
m_systemNetwork.update(elapsedTime, MessageQueueServer.instance.getMessages());
m_systemCollisionDetection.update(elapsedTime);
m_SystemGrowthHandler.update(elapsedTime);
m_systemWormMovement.update(elapsedTime);
m_systemSpiceGen.update(elapsedTime);
}
Expand Down Expand Up @@ -105,7 +103,6 @@ private void addEntity(Entity entity)
m_entities[entity.id] = entity;
m_systemNetwork.add(entity);
m_systemCollisionDetection.add(entity);
m_SystemGrowthHandler.add(entity);
m_systemWormMovement.add(entity);
m_systemSpiceGen.add(entity);
}
Expand All @@ -121,7 +118,6 @@ private void removeEntity(uint id)
m_entities.Remove(id);
m_systemNetwork.remove(id);
m_systemCollisionDetection.remove(id);
m_SystemGrowthHandler.remove(id);
m_systemWormMovement.remove(id);
m_systemSpiceGen.remove(id);
}
Expand Down
9 changes: 5 additions & 4 deletions src/Server/Systems/CollisionDetection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,18 @@ public override void update(TimeSpan elapsedTime)
{
continue;
}
if (entity.contains<SpicePower>() && !entity.contains<Worm>() )

if (entity.contains<Shared.Components.Wall>())
{
wormToSpice(elapsedTime, head, entity);
wormToWall(entity, head, worm);
}
else if (entity.contains<Worm>())
{
wormToWorm(head, worm, entity);
}
else if (entity.contains<Shared.Components.Wall>())
else if (entity.contains<SpicePower>() && !entity.contains<Worm>() )
{
wormToWall(entity, head, worm);
wormToSpice(elapsedTime, head, entity);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/Entities/PlayerData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class PlayerData
{
public int clientId { get; set; }

public int highestPosition { get; private set; } = 1;
public int highestPosition { get; private set; } = 9999;

public int kills { get; private set; }
[DataMember(Name = "score")] public int score { get; set; }
Expand Down
21 changes: 0 additions & 21 deletions src/Shared/Systems/GrowthHandler.cs

This file was deleted.

0 comments on commit eedea1e

Please sign in to comment.