Esempio n. 1
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin();

            //start drawing

            for (int i = 0; i < enemyList.Count; i++)
            {
                if (enemyList[i].GetType() == typeof(enemyStruct))
                {
                    enemyStruct tempEnemy = (enemyStruct)enemyList[i];
                    //render enemy;
                    spriteBatch.Draw(enemy, new Vector2(tempEnemy.x, tempEnemy.y), Color.White);
                    spriteBatch.Draw(boundingbox, new Vector2(tempEnemy.x, tempEnemy.y), Color.White);
                }
            }

            spriteBatch.Draw(player, new Vector2(playerX, playerY), Color.White);
            spriteBatch.Draw(boundingbox, new Vector2(playerX, playerY), Color.White);

            spriteBatch.Draw(sword, new Vector2(swordOffsetX + playerX, swordOffsetY + playerY), Color.White);

            for (int i = 0; i < trailFragmentList.Count; i++)
            {
                if (trailFragmentList[i].GetType() == typeof(trailFragment))
                {
                    trailFragment tempTrail = (trailFragment)trailFragmentList[i];
                    spriteBatch.Draw(trail, new Rectangle(tempTrail.x, tempTrail.y, tempTrail.width, tempTrail.height), Color.White);
                }
            }

            //ui stuff
            for (int i = 0; i < playerHealth; i++)
            {
                spriteBatch.Draw(heart, new Vector2(i * 32, 0), Color.White);
            }

            spriteBatch.Draw(cursor, new Vector2(Mouse.GetState().X, Mouse.GetState().Y), Color.White);

            //end drawing
            spriteBatch.End();

            base.Draw(gameTime);
        }
Esempio n. 2
0
        public void updateTrailFragments()
        {
            for (int i = 0; i < trailFragmentList.Count; i++)
            {
                if (trailFragmentList[i].GetType() == typeof(trailFragment))
                {
                    trailFragment tempTrail = (trailFragment)trailFragmentList[i];
                    //make it smaller
                    tempTrail.width--;
                    tempTrail.height--;

                    trailFragmentList[i] = tempTrail;

                    //remove if too old
                    if (tempTrail.width <= 0 && tempTrail.height <= 0)
                    {
                        trailFragmentList.Remove(trailFragmentList[i]);
                    }
                }
            }
        }