Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Graphics;
- using Microsoft.Xna.Framework.Input;
- using System;
- namespace GameBase
- {
- public class Game1 : Game
- {
- GraphicsDeviceManager graphics;
- SpriteBatch spriteBatch;
- EntityMgr entityMgr;
- Texture2D bulletTexture;
- public Game1()
- {
- graphics = new GraphicsDeviceManager(this);
- Content.RootDirectory = "Content";
- entityMgr = new EntityMgr();
- }
- protected override void Initialize()
- {
- // TODO: Add your initialization logic here
- base.Initialize();
- }
- protected override void LoadContent()
- {
- spriteBatch = new SpriteBatch(GraphicsDevice);
- bulletTexture = this.Content.Load<Texture2D>("bullet");
- }
- protected override void UnloadContent()
- {
- }
- protected override void Update(GameTime gameTime)
- {
- KeyboardState kbState = Keyboard.GetState();
- MouseState mouseState = Mouse.GetState();
- if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
- Exit();
- Entity firstEntity;
- Entity stenen = new Entity();
- firstEntity = stenen;
- Entity secondEntity;
- Entity stenen2 = new Entity();
- secondEntity = stenen2;
- Entity lastEntity;
- Entity stenen3 = new Entity();
- lastEntity = stenen3;
- base.Update(gameTime);
- entityMgr.Update(gameTime);
- if(kbState.IsKeyDown(Keys.G))
- {
- Random random = new Random();
- Vector2 position;
- position.X = random.Next(0, 1920);
- position.Y = random.Next(0, 1080);
- entityMgr.AddEntity(new Bullet(bulletTexture, position));
- }
- }
- protected override void Draw(GameTime gameTime)
- {
- GraphicsDevice.Clear(Color.White);
- entityMgr.Draw(spriteBatch);
- base.Draw(gameTime);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement