public virtual void DrawLine(Vector2 a, Vector2 b, int thickness, Color color) { Vector2 start; Vector2 end; if (a.X < b.X) { start = a; end = b; } else { start = b; end = a; } float angle = (float)Math.Atan2((double)(end.Y - start.Y), (double)(end.X - start.X)); //this.Draw(GraphicsDispenser.getTexture("pixel_bmp"), start, new Vector2(a.X + (b - a).Length, a.Y) this.Draw(GraphicsDispenser.GetTexture("pixel_bmp") //, new Rectangle(start.X, start.Y, (int)((end - start).Length()), start.Y) , new Rectangle((int)start.X , (int)start.Y , (int)((end - start).Length()) , thickness) , null , color , angle , Vector2.Zero , SpriteEffects.None , 0f); }
/// <summary> /// Render map centered on focus with line of sight /// </summary> public void Draw(ZSpriteBatch spriteBatch) { UpdateLoS(); // draw map for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { //spriteBatch.Draw(map.GetBlockAt(x, y).Graphic.Texture, new Vector2(x * Game.MAP_BLOCK_SIZE, y * Game.MAP_BLOCK_SIZE), Color.White); //player.Location.Coordinates.X + x, y); //Coord coord = new Coord(focus.Location.Coordinates.X + x - Game.VISIBLE_MAP_OFFSET, focus.Location.Coordinates.Y + y - Game.VISIBLE_MAP_OFFSET); Coord coord = this[x, y]; //int r = GameMap.LightMap[x, y].R; if (map.IsInMap(coord) && visiblePositions[x, y]) { Texture2D texture = map.GetBlockAt(coord).Graphic.Texture; spriteBatch.Draw(texture, new Rectangle(x * Game.MAP_BLOCK_SIZE, y * Game.MAP_BLOCK_SIZE, Game.MAP_BLOCK_SIZE, Game.MAP_BLOCK_SIZE), GameMap.LightMap[coord.X, coord.Y]); } else if (map.IsInMap(coord)) { Texture2D texture = map.GetBlockAt(coord).Graphic.Texture; spriteBatch.DrawRectangle(x * Game.MAP_BLOCK_SIZE, y * Game.MAP_BLOCK_SIZE, Game.MAP_BLOCK_SIZE, Game.MAP_BLOCK_SIZE, Color.Gray); //spriteBatch.Draw(texture, // new Rectangle(x * Game.MAP_BLOCK_SIZE, y * Game.MAP_BLOCK_SIZE, Game.MAP_BLOCK_SIZE, Game.MAP_BLOCK_SIZE), // Color.White); } else { spriteBatch.Draw(GraphicsDispenser.GetTexture("void_bmp"), new Rectangle(x * Game.MAP_BLOCK_SIZE, y * Game.MAP_BLOCK_SIZE, Game.MAP_BLOCK_SIZE, Game.MAP_BLOCK_SIZE), Color.White); } } } this.ResetVision(); }
public Sprite(string nImgLoc) { imgLoc = nImgLoc; texture = GraphicsDispenser.GetTexture(nImgLoc); }