Advertisement
konalisp

Monogame Demo

Sep 16th, 2014
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.73 KB | None | 0 0
  1. using System;
  2. using Microsoft.Xna.Framework;
  3. using Microsoft.Xna.Framework.Audio;
  4. using Microsoft.Xna.Framework.Content;
  5. using Microsoft.Xna.Framework.Graphics;
  6. using Microsoft.Xna.Framework.Input;
  7. using Microsoft.Xna.Framework.Media;
  8.  
  9. public class Entry {
  10.     static public int Main () {
  11.         using (GameProper game = new GameProper()) {
  12.                 game.Run();
  13.         }
  14.         return 0;
  15.     }
  16. }
  17.  
  18. public class GameProper : Microsoft.Xna.Framework.Game {
  19.    
  20.     SpriteBatch spriteBatch;
  21.     GraphicsDeviceManager graphics;
  22.    
  23.     private Texture2D background;
  24.     private Texture2D shuttle;
  25.     private Texture2D earth;
  26.    
  27.     public GameProper() {
  28.         graphics = new GraphicsDeviceManager(this);
  29.         Content.RootDirectory = "content";
  30.     }
  31.    
  32.     protected override void LoadContent() {
  33.         // Create a new SpriteBatch, which can be used to draw textures.
  34.         spriteBatch = new SpriteBatch(GraphicsDevice);
  35.      
  36.         // This is the code we added earlier.
  37.         background = Content.Load<Texture2D>("stars"); // change these names to the names of your images
  38.         shuttle = Content.Load<Texture2D>("shuttle");  // if you are using your own images.
  39.         earth = Content.Load<Texture2D>("earth");
  40.     }
  41.    
  42.     protected override void Draw(GameTime gameTime) {
  43.         graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
  44.        
  45.         spriteBatch.Begin();
  46.        
  47.         spriteBatch.Draw(background, new Rectangle(0, 0, 800, 480), Color.White);
  48.         spriteBatch.Draw(earth, new Vector2(400, 240), Color.White);
  49.         spriteBatch.Draw(shuttle, new Vector2(450, 240), Color.White);
  50.        
  51.         spriteBatch.End();
  52.        
  53.         base.Draw(gameTime);
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement