private void DrawEnemyAt(List<Vector2> a_positions, Vector2 viewportSize, Camera a_camera, float a_scale) { Rectangle enemySource = new Rectangle(0, 0, (int)(m_enemyTexture.Width), (int)(m_enemyTexture.Height)); //Destination rectangle in windows coordinates only scaling for (int i = 0; i <a_positions.Count(); i++) { Vector2 EnemyViewPos = a_camera.GetViewPosition(a_positions[i].X, a_positions[i].Y, viewportSize); //Vector2 destRect = a_camera.GetViewPosition(a_positions[i].X, a_positions[i].Y, ViewPort); Rectangle enemyRect = new Rectangle((int)(EnemyViewPos.X - a_scale), (int)(EnemyViewPos.Y - a_scale), (int)a_scale, (int)a_scale); m_spriteBatch.Draw(m_enemyTexture, enemyRect,enemySource, Color.White); } }
public void DrawLevel(float a_elapsedTime, GraphicsDevice a_graphicsDevice, Model.Level a_level, Camera a_camera, Vector2 a_playerPosition, int a_points, List<Vector2> a_drawEnemy) { Vector2 viewportSize = new Vector2(a_graphicsDevice.Viewport.Width, a_graphicsDevice.Viewport.Height); float scale = a_camera.GetScale(); a_graphicsDevice.Clear(Microsoft.Xna.Framework.Color.Transparent); Rectangle background = new Rectangle(0, 0, (int)(m_backgroundTexture.Width*2), (int)(m_backgroundTexture.Height)); Rectangle backgroundSource = new Rectangle(0, 0, (int)viewportSize.X, (int)viewportSize.Y); //draw all images m_spriteBatch.Begin(); m_spriteBatch.Draw(m_backgroundTexture, background, backgroundSource, Color.White); //draw level for (int x = 0; x < Model.Level.g_levelWidth; x++) { for (int y = 0; y < Model.Level.g_levelHeight; y++) { Vector2 viewPos = a_camera.GetViewPosition(x, y, viewportSize); DrawTile(viewPos.X, viewPos.Y, scale, a_level.m_tiles[x, y]); } } //DrawEnemy DrawEnemyAt(a_drawEnemy, viewportSize, a_camera, scale); // DrawEnemyAt(a_drawEnemy, viewportSize, a_camera, scale); m_time += a_elapsedTime / 10.0f; // Vector2 smokePosition = a_camera.GetViewPosition(25.5f, 10f, viewportSize); // m_smoke.DrawSmoke(m_time, smokePosition, 20f, m_spriteBatch, m_smokeTexture); Vector2 displacement = new Vector2(a_graphicsDevice.Viewport.Width, a_graphicsDevice.Viewport.Height); m_smoke.DrawSmoke(m_time, displacement, m_viewScale, m_spriteBatch, m_smokeTexture); //Vector2 a_playerSpeed = new Vector2(); Vector2 playerViewPos = a_camera.GetViewPosition(a_playerPosition.X, a_playerPosition.Y, viewportSize); DrawPlayerAt(playerViewPos, scale); DrawUI(a_points); m_spriteBatch.End(); }