/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here mainCamera = new Camera(GraphicsDevice.Viewport); GameMap.Instance(this); menuManager = new Menu(this); GameAudio.Instance(this); player = new Player(this, mainCamera, graphics); menuManager.addDev("Brennan", "wanker"); menuManager.addDev("Adam", "Another wanker"); menuManager.addDev("Jack", "Team wanker"); base.Initialize(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); GameMap.LoadContent(); menuManager.LoadContent(); GameAudio.LoadContent(); player.LoadContent(); //GameAudio.PlaySong(index); // TODO: use this.Content to load your game content here }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { var deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds; player.Update(gameTime); if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } if (Keyboard.GetState().IsKeyDown(Keys.A)) { GameMap.CurrentMap = GameMap.GetMap("map"); } else if (Keyboard.GetState().IsKeyDown(Keys.B)) { GameMap.CurrentMap = GameMap.GetMap("map2"); } // TODO: Add your update logic here int index = GameAudio.GetAudio("song"); if (Keyboard.GetState().IsKeyDown(Keys.Q)) { GameAudio.PlaySong(index); } else if (Keyboard.GetState().IsKeyDown(Keys.W)) { GameAudio.PauseSong(index); } else if (Keyboard.GetState().IsKeyDown(Keys.Space)) { GameAudio.StopSong(index); } base.Update(gameTime); }