//fills all 10,000 tiles with random floor textures public void generateWorld(string bias, List <Texture2D> textures) { int i = 0; int j = 0; List <Biome> Biomes = generateBiomes(bias, textures); Random R = new Random(Guid.NewGuid().GetHashCode()); Biome B = null; //check for null space for (i = 0; i < worldSize; i++) { for (j = 0; j < worldSize; j++) { if (worldMap[i, j] == null) { B = closestBiome(Biomes, i, j); tile t = new tile(false, false, false, B.getTexture(), B.getType(), "flavor text"); worldMap[i, j] = t; } } } return; } //end of generateWorld()
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { int WIDTH = (G.graphicsWidth / G.tileSize); int HEIGHT = (G.graphicsHeight / G.tileSize); int i, j = 0; int camX = 0; int camY = 0; GraphicsDevice.Clear(Color.TransparentBlack); spriteBatch.Begin(); //draw TILES camX = M.getCamX(); camY = M.getCamY(); for (i = 0; i < HEIGHT; i++) { for (j = 0; j < WIDTH; j++) { tile T = M.getTileAt(camX + j, camY + i); Vector2 pos = new Vector2(j * G.tileSize, i * G.tileSize); spriteBatch.Draw(T.getTexture(), pos, null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 1f); } } //draw all HUD elements for (i = 0; i < HM.hudGraphicsCount(); i++) { //ignore hidden stuff if (HM.getGraphicAt(i).getState() == VISIBILITY.HIDDEN) { continue; } HudGraphic HG = HM.getGraphicAt(i); spriteBatch.Draw(HG.getTexture(), HG.getPosition(), null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 1f); } //draw all hud text for (i = 0; i < HM.hudTextCount(); i++) { //ignore hidden stuff if (HM.getTextAt(i).getState() == VISIBILITY.HIDDEN) { continue; } HudText HT = HM.getTextAt(i); spriteBatch.DrawString(HT.getFont(), HT.getText(), HT.getPosition(), Color.White, 0, new Vector2(0, 0), 1f, SpriteEffects.None, 0); } //draw crosshair spriteBatch.Draw(TM.crosshair, new Vector2(G.mouseX, G.mouseY), null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 1f); //draw bottom bar //spriteBatch.Draw(TM.UI[0], new Vector2(0, 700), null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 1f); //draw current position //string position = "pos:(" + camX + "," + camY + ")"; //spriteBatch.DrawString(defaultFont, position, new Vector2(0, 702), Color.White, 0, new Vector2(0, 0), 1f, SpriteEffects.None, 0); //draw current time //string date = "day:" + DT.getDay(); //spriteBatch.DrawString(defaultFont, date, new Vector2(150, 702), Color.White, 0, new Vector2(0, 0), 1f, SpriteEffects.None, 0); //draw resources base.Draw(gameTime); spriteBatch.End(); return; }