public void drawSprite(FTexture2D sprite, double tile_x, double tile_y) { spriteBatch.Begin(); Vector2 pos = new Vector2(); pos.X = pix_x + (((float)tile_x * (float)pix_per_tile_width) - (float)tile_offset_x * (float)pix_per_tile_width) - sprite.offset_x * (float)pix_per_tile_width/64; pos.Y = pix_y + (((float)tile_y * (float)pix_per_tile_height) - (float)tile_offset_y * (float)pix_per_tile_height) - sprite.offset_y * (float)pix_per_tile_height / 64; Vector2 scale = new Vector2((float)pix_per_tile_width / 64, (float)pix_per_tile_height / 64); spriteBatch.Draw(sprite.texture, pos, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f); spriteBatch.End(); }
public void drawCulledSprite(FTexture2D sprite, double tile_x, double tile_y, int cull_start_x, int cull_start_y, int cull_width, int cull_height) { spriteBatch.Begin(); Vector2 pos = new Vector2(); Rectangle culler = new Rectangle(cull_start_x, cull_start_y, cull_width, cull_height); pos.X = pix_x + (((float)tile_x * (float)pix_per_tile_width) - (float)tile_offset_x * (float)pix_per_tile_width) - (sprite.offset_x * (float)pix_per_tile_width / 64) + (culler.X * (float)pix_per_tile_width / 64); pos.Y = pix_y + (((float)tile_y * (float)pix_per_tile_height) - (float)tile_offset_y * (float)pix_per_tile_height) - (sprite.offset_y * (float)pix_per_tile_height / 64) + (culler.Y * (float)pix_per_tile_width / 64); Vector2 scale = new Vector2((float)pix_per_tile_width / 64, (float)pix_per_tile_height / 64); spriteBatch.Draw(sprite.texture, pos, culler, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f); spriteBatch.End(); }