Skip to content

Commit

Permalink
38 map generation (#59)
Browse files Browse the repository at this point in the history
* add single tile

* orientation is radians

* zoom out + bigger tile

* remove extra thrust

* Added all tiles
  • Loading branch information
caden-maxwell authored Apr 9, 2024
1 parent 48b12e9 commit 853931a
Showing 1 changed file with 19 additions and 22 deletions.
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

0 comments on commit 853931a

Please sign in to comment.