rendered paste body public class BlockManager : DrawableGameComponent
{
private struct block
{
public Vector2 Position;
public Color BColor;
public block( int x, int y ) {
Position = new Vector2( x, y );
BColor = Color.White;
}
}
private LinkedList<block> blocks;
private Texture2D tex;
private ContentManager content;
private SpriteBatch spritebatch;
private Game g;
public BlockManager( Game ga ) : base( ga ) {
g = ga;
blocks = new LinkedList<block>();
//spritebatch = new SpriteBatch( g.GraphicsDevice );
}
protected override void LoadContent() {
content = new ContentManager( g.Services );
content.RootDirectory = "Content";
tex = content.Load<Texture2D>( "block" );
spritebatch = new SpriteBatch( g.GraphicsDevice );
base.LoadContent();
}
public void Add( int x, int y ) {
blocks.AddLast( new block( x, y ) );
}
public void Clear() {
blocks.Clear();
}
public override void Draw( GameTime gameTime ) {
spritebatch.Begin( SpriteBlendMode.AlphaBlend );
foreach ( block b in blocks ) {
spritebatch.Draw( tex, b.Position, b.BColor );
}
spritebatch.End();
base.Draw( gameTime );
}
public override void Update( GameTime gameTime ) {
base.Update( gameTime );
}
}