• Create Account

Banner advertising on our site currently available from just \$5!

Posted 31 May 2013 - 01:53 AM

protected override void Initialize()
{
cube = new Cube(device);

camera = new Camera(new Vector3(0.5f, 1.5f, 0.5f), 0, GraphicsDevice.Viewport.AspectRatio, 0.5f, 100f);
effect = new BasicEffect(GraphicsDevice);
cubes = new DrawableList<Cube>(this, camera, effect);
device = GraphicsDevice;

for (int x = 0; x < mapCoordsX; x++)
{
mapX[x] = x;
}

for (int z = 0; z < mapCoordsZ; z++)
{
mapZ[z] = z;
}

for (int y = 0; y < mapCoordsY; y++)
{
mapY[y] = y;
}

base.Initialize();
}

/// <summary>
/// LoadContent will be called once per game and is the place to load
/// </summary>
{
cube.CreateCubeVertexBuffer();
cube.CreateCubeIndexBuffer();
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);

for (int x = 0; x < 50; x++)
{
for (int z = 0; z < 50; z++)
{
cubes.Add(new Vector3(mapX[x], 0f, mapZ[z]), Matrix.Identity, grass);
}
}

}


Here's both of the methods. Would it make sense to put the CreateBuffer methods in the constructor of the cube?

"cubes" is a drawable list made up of cubes

Posted 31 May 2013 - 01:51 AM

protected override void Initialize()
{
cube = new Cube(device);

camera = new Camera(new Vector3(0.5f, 1.5f, 0.5f), 0, GraphicsDevice.Viewport.AspectRatio, 0.5f, 100f);
effect = new BasicEffect(GraphicsDevice);
cubes = new DrawableList<Cube>(this, camera, effect);
device = GraphicsDevice;

for (int x = 0; x < mapCoordsX; x++)
{
mapX[x] = x;
}

for (int z = 0; z < mapCoordsZ; z++)
{
mapZ[z] = z;
}

for (int y = 0; y < mapCoordsY; y++)
{
mapY[y] = y;
}

base.Initialize();
}

/// <summary>
/// LoadContent will be called once per game and is the place to load
/// </summary>
{
cube.CreateCubeVertexBuffer();
cube.CreateCubeIndexBuffer();
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);

for (int x = 0; x < 50; x++)
{
for (int z = 0; z < 50; z++)
{
cubes.Add(new Vector3(mapX[x], 0f, mapZ[z]), Matrix.Identity, grass);
}
}