コード例 #1
0
        /// <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.Black);

            // TODO: Add your drawing code here

            spriteBatch.Begin();

            printText.print("Antal fiender" + enemies.Count, spriteBatch, 0, 0);
            //player.draw(spriteBatch);
            player.Draw(spriteBatch);

            foreach (Enemy e in enemies)
            {
                e.Draw(spriteBatch);
            }

            foreach (Enemy e in enemies)
            {
                if (e.IsAlive)
                {
                    e.Update(Window);
                }
                else
                {
                    enemies.Remove(e);
                }
            }


            spriteBatch.End();


            base.Draw(gameTime);
        }
コード例 #2
0
        public static void RunDraw(SpriteBatch spriteBatch)
        {
            #region Draw sprite
            // ritar ut de olika fiendera, pwoerups och player
            background.Draw(spriteBatch);
            player.Draw(spriteBatch);
            foreach (Enemy e in enemies)
            {
                e.Draw(spriteBatch);
            }
            foreach (Enemy e2 in bossD1)
            {
                e2.Draw(spriteBatch);
            }
            foreach (Enemy e2 in bossD2)
            {
                e2.Draw(spriteBatch);
            }
            foreach (GoldCoin gc in goldCoins)
            {
                gc.Draw(spriteBatch);
            }
            foreach (GoldCoin sh in goldShield)
            {
                sh.Draw(spriteBatch);
            }
            foreach (pwTorpedo pw in pwTorpedo)
            {
                pw.Draw(spriteBatch);
            }
            #endregion
            #region Text
            // Ritar ut text på skärmen
            // vasar information om poeng, din sköld, hur många torpeder du har
            //vilken level och vilken fiende våg  du är på
            printText.print("points:" + player.points, spriteBatch, 0, 0);
            printText.print("points:" + hsItem.Points, spriteBatch, 100, 0);
            printText.print("Shield:" + player.shields, spriteBatch, 0, 20);
            printText.print("Level:" + GameElements.lv, spriteBatch, 0, 40);
            printText.print("Wave:" + GameElements.wave, spriteBatch, 0, 60);
            printText.print("Torpedo:" + player.PW, spriteBatch, 0, 80);
            // visar Bossens HP om fiendevåg är 4 och on level inte är 2
            if (wave == 4 && lv != 2)
            {
                printText.print("Boss HP:" + GameElements.HPD1, spriteBatch, 380, 0);
            }
            // visar Bossens HP om fiendevåg är 9
            if (wave == 9)
            {
                printText.print("Boss HP:" + GameElements.HPD2, spriteBatch, 380, 0);
            }

            #endregion
        }