Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

38 map generation #59

Merged
merged 8 commits into from
Apr 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 19 additions & 22 deletions src/Client/Systems/Renderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Collections.Generic;
using Client.Components;
using Client.Menu;
using System.Runtime.CompilerServices;

namespace Client.Systems;

Expand All @@ -19,7 +20,8 @@ public class Renderer : Shared.Systems.System
private GraphicsDeviceManager m_graphics;
private SpriteFont m_font;
private Texture2D m_sand;

private List<Rectangle> m_backgroundTiles = new();

public Renderer(Systems.Camera camera, GraphicsDeviceManager graphics, SpriteFont font, Texture2D sand) :
base(
typeof(Position), typeof(Sprite)
Expand All @@ -29,6 +31,10 @@ public Renderer(Systems.Camera camera, GraphicsDeviceManager graphics, SpriteFon
m_graphics = graphics;
m_font = font;
m_sand = sand;

for (int i = 0; i < 6; i++)
for (int j = 0; j < 6; j++)
m_backgroundTiles.Add(new Rectangle(-100 + i * 500, -100 + j * 500, 500, 500));
}

public override void update(TimeSpan elapsedTime) { }
Expand All @@ -45,22 +51,21 @@ public void render(TimeSpan elapsedTime, SpriteBatch spriteBatch)
matrix *= Matrix.CreateTranslation(new Vector3(offset, 0));
matrix *= Matrix.CreateScale(scaleX, scaleY, 1);


//spriteBatch.Begin();
spriteBatch.Begin(transformMatrix: matrix);

Rectangle rect = new(0, 0, 500, 500);
spriteBatch.Draw(
m_sand,
rect,
null,
Color.White,
0,
Vector2.Zero,
SpriteEffects.None,
0
);
foreach (Rectangle rect in m_backgroundTiles)
spriteBatch.Draw(
m_sand,
rect,
null,
Color.White,
0,
Vector2.Zero,
SpriteEffects.None,
0
);

var heads = new List<Entity>();
var bodies = new List<Entity>();
var tails = new List<Entity>();
Expand All @@ -79,21 +84,13 @@ public void render(TimeSpan elapsedTime, SpriteBatch spriteBatch)
}

foreach (Entity entity in others)
{
renderEntity(elapsedTime, spriteBatch, entity);
}
foreach (Entity entity in tails)
{
renderEntity(elapsedTime, spriteBatch, entity);
}
foreach (Entity entity in bodies)
{
renderEntity(elapsedTime, spriteBatch, entity);
}
foreach (Entity entity in heads)
{
renderEntity(elapsedTime, spriteBatch, entity);
}

spriteBatch.End();
}
Expand Down
Loading