Advertisement
Michael_smith

Untitled

Mar 31st, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.32 KB | None | 0 0
  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Graphics;
  3. using Microsoft.Xna.Framework.Input;
  4. using System;
  5.  
  6. namespace GameBase
  7. {
  8.    
  9.     public class Game1 : Game
  10.     {
  11.         GraphicsDeviceManager graphics;
  12.         SpriteBatch spriteBatch;
  13.         EntityMgr entityMgr;
  14.         Texture2D bulletTexture;
  15.  
  16.         public Game1()
  17.         {
  18.             graphics = new GraphicsDeviceManager(this);
  19.             Content.RootDirectory = "Content";
  20.             entityMgr = new EntityMgr();
  21.         }
  22.      
  23.         protected override void Initialize()
  24.         {
  25.             // TODO: Add your initialization logic here
  26.  
  27.             base.Initialize();
  28.         }
  29.  
  30.    
  31.         protected override void LoadContent()
  32.         {
  33.            
  34.             spriteBatch = new SpriteBatch(GraphicsDevice);
  35.             bulletTexture = this.Content.Load<Texture2D>("bullet");
  36.  
  37.          
  38.         }
  39.  
  40.         protected override void UnloadContent()
  41.         {
  42.            
  43.         }
  44.  
  45.      
  46.         protected override void Update(GameTime gameTime)
  47.         {
  48.             KeyboardState kbState = Keyboard.GetState();
  49.             MouseState mouseState = Mouse.GetState();
  50.  
  51.             if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
  52.                 Exit();
  53.  
  54.             Entity firstEntity;
  55.             Entity stenen = new Entity();
  56.             firstEntity = stenen;
  57.  
  58.  
  59.             Entity secondEntity;
  60.             Entity stenen2 = new Entity();
  61.             secondEntity = stenen2;
  62.  
  63.  
  64.             Entity lastEntity;
  65.             Entity stenen3 = new Entity();
  66.             lastEntity = stenen3;
  67.  
  68.  
  69.             base.Update(gameTime);
  70.             entityMgr.Update(gameTime);
  71.  
  72.             if(kbState.IsKeyDown(Keys.G))
  73.             {
  74.                 Random random = new Random();
  75.                 Vector2 position;
  76.                 position.X = random.Next(0, 1920);
  77.                 position.Y = random.Next(0, 1080);
  78.                 entityMgr.AddEntity(new Bullet(bulletTexture, position));
  79.  
  80.  
  81.             }
  82.         }
  83.  
  84.         protected override void Draw(GameTime gameTime)
  85.         {
  86.            
  87.             GraphicsDevice.Clear(Color.White);
  88.             entityMgr.Draw(spriteBatch);
  89.  
  90.             base.Draw(gameTime);
  91.         }
  92.     }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement