C#
Весь исходный код
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace MyMonoGame
{
/// This is the main type for your game.
public class Game1 : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
// переменная для текстур
Texture2D grass;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
graphics.IsFullScreen = true;
graphics.PreferredBackBufferWidth = 800;
graphics.PreferredBackBufferHeight = 480;
graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
}
/// Allows the game to perform any initialization it needs to before starting
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
/// LoadContent will be called once per game and is the place to load
/// all of your content.
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// открываем картинку из Content/MonoGame (ресурс называется по имени файла без расширения)
grass = Content.Load<Texture2D>("ogorod");
}
/// UnloadContent will be called once per game and is the place to unload
/// game-specific content.
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
Exit();
// TODO: Add your update logic here
base.Update(gameTime);
}
/// This is called when the game should draw itself.
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
// рисуем картинку
spriteBatch.Begin();
spriteBatch.Draw(grass, Vector2.Zero, Color.White);
spriteBatch.End();
base.Draw(gameTime);
}
}
}