diff --git a/Blocktest/BlocktestGame.cs b/Blocktest/BlocktestGame.cs
index 9bfd4cc..fe5c19f 100644
--- a/Blocktest/BlocktestGame.cs
+++ b/Blocktest/BlocktestGame.cs
@@ -33,6 +33,10 @@ public void SetScene(IScene newScene) {
///
protected override void Initialize() {
+ _graphics.PreferredBackBufferHeight = 720;
+ _graphics.PreferredBackBufferWidth = 1280;
+ _graphics.ApplyChanges();
+
BlockManagerShared.Initialize();
base.Initialize();
}
diff --git a/Blocktest/Code/Block System/RenderableTile.cs b/Blocktest/Code/Block System/RenderableTile.cs
index bc84d7d..74aa7c7 100644
--- a/Blocktest/Code/Block System/RenderableTile.cs
+++ b/Blocktest/Code/Block System/RenderableTile.cs
@@ -9,7 +9,8 @@ public class RenderableTile : TileShared {
public RenderableTile(TileShared tile, bool background) : base(tile.SourceBlock,
tile.Transform.Position / GlobalsShared.GridSize) {
Renderable = new Renderable(Transform, background ? Layer.BackgroundBlocks : Layer.ForegroundBlocks,
- BlockSpritesManager.AllBlocksSprites[tile.SourceBlock.BlockUid].BlockSprite, tile.Color);
+ BlockSpritesManager.AllBlocksSprites[tile.SourceBlock.BlockUid].BlockSprite,
+ background ? Color.Gray : Color.White);
}
///
diff --git a/Blocktest/Code/Rendering/Camera.cs b/Blocktest/Code/Rendering/Camera.cs
index b52beb9..4d1db61 100644
--- a/Blocktest/Code/Rendering/Camera.cs
+++ b/Blocktest/Code/Rendering/Camera.cs
@@ -5,7 +5,7 @@ public sealed class Camera {
private readonly Color _backgroundColor;
private readonly Vector2 _size;
- public readonly List RenderedComponents = new();
+ public readonly HashSet RenderedComponents = [];
public readonly RenderTarget2D RenderTarget;
public Vector2 Position;
@@ -23,7 +23,7 @@ public void Draw(GraphicsDevice graphics, SpriteBatch spriteBatch) {
graphics.SetRenderTarget(RenderTarget);
graphics.Clear(_backgroundColor);
- spriteBatch.Begin();
+ spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointClamp);
foreach (Renderable component in RenderedComponents) {
if (component.Appearance == null) {
diff --git a/Blocktest/Code/Rendering/Drawable.cs b/Blocktest/Code/Rendering/Drawable.cs
index 0c700db..9f12dbb 100644
--- a/Blocktest/Code/Rendering/Drawable.cs
+++ b/Blocktest/Code/Rendering/Drawable.cs
@@ -21,4 +21,8 @@ public void Draw(RenderContext context, Rectangle dest, Color color) {
}
public Point Size => Bounds.Size;
+
+ public override int GetHashCode() {
+ return HashCode.Combine(Bounds, Texture);
+ }
}
\ No newline at end of file
diff --git a/Blocktest/Code/Scenes/GameScene.cs b/Blocktest/Code/Scenes/GameScene.cs
index 297acc4..3a57209 100644
--- a/Blocktest/Code/Scenes/GameScene.cs
+++ b/Blocktest/Code/Scenes/GameScene.cs
@@ -37,7 +37,7 @@ public GameScene(BlocktestGame game, bool doConnect, IPEndPoint? ip) {
_spriteBatch = new SpriteBatch(game.GraphicsDevice);
_game = game;
- _camera = new Camera(Vector2.Zero, new Vector2(512, 256), game.GraphicsDevice);
+ _camera = new Camera(Vector2.Zero, new Vector2(640, 360), game.GraphicsDevice);
_backgroundTilemapSprites = new RenderableTilemap(_worldState.Foreground, _camera);
_foregroundTilemapSprites = new RenderableTilemap(_worldState.Background, _camera);
@@ -79,14 +79,14 @@ public void Draw(GameTime gameTime, GraphicsDevice graphicsDevice) {
graphicsDevice.Clear(Color.CornflowerBlue);
_camera.Draw(graphicsDevice, _spriteBatch);
- const bool pixelPerfect = false;
+ const bool pixelPerfect = true;
Rectangle destinationRectangle = pixelPerfect ? GetPixelPerfectRect() : GetFitRect();
_camera.RenderLocation = destinationRectangle;
graphicsDevice.Clear(Color.Black);
- _spriteBatch.Begin(samplerState: pixelPerfect ? SamplerState.PointClamp : null);
+ _spriteBatch.Begin(samplerState: SamplerState.PointClamp);
_spriteBatch.Draw(_camera.RenderTarget, destinationRectangle, Color.White);
float deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds;
@@ -165,7 +165,8 @@ private void HandleInput() {
if (currentMouseState.LeftButton != ButtonState.Pressed &&
currentMouseState.RightButton != ButtonState.Pressed ||
- !_camera.RenderLocation.Contains(currentMouseState.Position)) {
+ !_camera.RenderLocation.Contains(currentMouseState.Position) ||
+ _gameDesktop.IsMouseOverGUI) {
return;
}
diff --git a/Shared/Code/Block System/TileShared.cs b/Shared/Code/Block System/TileShared.cs
index a251370..f49bd7c 100644
--- a/Shared/Code/Block System/TileShared.cs
+++ b/Shared/Code/Block System/TileShared.cs
@@ -11,11 +11,6 @@ namespace Shared.Code.Block_System;
public class TileShared : INetSerializable {
public readonly Transform Transform;
- ///
- /// Color of the tile.
- ///
- public Color Color = Color.White;
-
///
/// The type of block this tile is.
///
@@ -33,15 +28,11 @@ public TileShared(BlockShared newBlock, Vector2Int position) {
}
public void Serialize(NetDataWriter writer) {
- writer.Put(Color.R);
- writer.Put(Color.G);
- writer.Put(Color.B);
writer.Put(Transform);
writer.Put(SourceBlock.BlockUid);
}
public void Deserialize(NetDataReader reader) {
- Color = new Color(reader.GetByte(), reader.GetByte(), reader.GetByte());
Transform.Deserialize(reader);
SourceBlock = BlockManagerShared.AllBlocks[reader.GetString()];
}