/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); switch (GameElements.currentstate) { case GameElements.State.Level: GameElements.RunDraw(spriteBatch); break; case GameElements.State.Highscore: GameElements.HighscoreDraw(spriteBatch); break; case GameElements.State.Quit: this.Exit(); break; default: GameElements.MenuDraw(spriteBatch); break; } spriteBatch.End(); base.Draw(gameTime); }
/// <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) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } switch (GameElements.currentstate) { case GameElements.State.Level: GameElements.currentstate = GameElements.RunUpdate(Content, Window, gameTime); break; case GameElements.State.Highscore: GameElements.currentstate = GameElements.HighscoreUpdate(); break; case GameElements.State.Quit: this.Exit(); break; default: GameElements.currentstate = GameElements.MenuUpdate(gameTime); break; } base.Update(gameTime); }
/// <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); enemies = new List <Enemies>(); Random random = new Random(); player = new Player(Content.Load <Texture2D>("sprites/player/tempplayer"), 380, 400); Texture2D tempSprite = Content.Load <Texture2D>("sprites/enemies/tempenemy"); for (int i = 0; i < 5; i++) { int rndX = random.Next(100, Window.ClientBounds.Width - tempSprite.Width - 100); int tempY = 100; NormalZombieBear temp = new NormalZombieBear(tempSprite, rndX, tempY, 1f, 0, 0); enemies.Add(temp); } bas = new Base(Content.Load <Texture2D>("sprites/player/Stacket"), 0, 280); //font = Content.Load<SpriteFont>("sprites/Fonts/firstfont"); GameElements.LoadContent(Content, Window); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); GameElements.LoadContent(Content, Window); }
/// <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() { GameElements.currentstate = GameElements.State.Menu; GameElements.Initialize(); base.Initialize(); }