Example #1
0
 public AnimatedSprite(Texture2D texture, int rows, int columns, int time)
 {
     mTextureMap = new TextureMap(texture, rows, columns);
     animationTime = time / mTextureMap.totalFrames;
     count = 0;
     mDone = false;
 }
Example #2
0
        public GameScreen(ref SpriteBatch sb, ref Player p, TextureMap eMap, 
            TextureMap lMap, TextureMap bMap, params string[] bgNames)
        {
            max_time = 100;
            enemyTimer = 0;
            bg2pos = new Vector2(0.0f, -800.0f);
            SB = sb;
            PlayerShip = p;
            pressedPause = false;
            Backgrounds = new List<TextureMap>();
            DrawableEntities = new List<GameEntity>();
            foreach (string bg in bgNames)
            {
                Backgrounds.Add(new TextureMap(Constants.content.Load<Texture2D>(bg), 1, 1));
            }

            enemyMap = eMap;
            laserMap = lMap;
            bossMap = bMap;

            r = new Random();
            veltemp = Vector2.Zero;
            for (int i = 0; i < 5; ++i)
            {
                veltemp.Y = r.Next(1, 5);
                Constants.mEnemyManager.addEnemy(new Enemy(
                    new Vector2(r.Next(100, Constants.graphics.PreferredBackBufferWidth - 100), 0.0f),
                    veltemp, enemyMap, laserMap, Enemy.ENEMY_TYPE.SIDEWINDER));
            }
        }
Example #3
0
 public Button(TextureMap tex, Vector2 pos, OnClickEvent evt)
 {
     Position = pos;
     OnClick = evt;
     Texture = tex;
     width = tex.width;
     height = tex.height;
 }
Example #4
0
 public Projectile(Vector2 position, TextureMap map, Vector2 vel, PROJECTILE_MASK mask)
     : base(position, map, ENTITY_TYPE.PROJECTILE)
 {
     Mask = mask;
     mInitPosition = position;
     mVelocity = vel;
     mLife = 150;
 }
Example #5
0
 public Projectile(Vector2 position, TextureMap map, int life, PROJECTILE_MASK mask)
     : base(position, map, ENTITY_TYPE.PROJECTILE)
 {
     Mask = mask;
     mInitPosition = position;
     mVelocity = Constants.DEFAULT_PROJECTILE_VELOCITY;
     mLife = life;
 }
Example #6
0
 public Enemy(Vector2 position, Vector2 velocity, TextureMap map, TextureMap tMap, ENEMY_TYPE t)
     : base(position, map, ENTITY_TYPE.AI)
 {
     Type = t;
     Gun = new List<Turret>();
     Gun.Add(new Turret((tMap)));
     rand = new Random();
     mVelocity = velocity;
 }
Example #7
0
 public Enemy(Vector2 position, TextureMap map, TextureMap tMap, ENEMY_TYPE t)
     : base(position, map, ENTITY_TYPE.AI)
 {
     Type = t;
     Gun = new List<Turret>();
     Gun.Add(new Turret((tMap)));
     rand = new Random();
     mVelocity = Constants.DEFAULT_ENEMY_VELOCITY;
 }
Example #8
0
 public GameEntity(Vector2 position, Vector2 velocity, TextureMap map, ENTITY_TYPE type, int health = Constants.MAX_PLAYER_HEALTH)
 {
     mPosition = position;
     mVelocity = velocity;
     mMidPoint = new Vector2(mPosition.X + map.width / 2, mPosition.Y + map.height / 2);
     mTexture = map;
     mHealth = health;
     mType = type;
     mAlive = true;
 }
Example #9
0
 public GameEntity(Vector2 position, TextureMap map, ENTITY_TYPE type)
 {
     mPosition = position;
     mVelocity = Vector2.Zero;
     mMidPoint = new Vector2(mPosition.X + map.width / 2, mPosition.Y + map.height / 2);
     mTexture = map;
     mHealth = 50;
     mType = type;
     mAlive = true;
 }
Example #10
0
 public Boss(Vector2 position, Vector2 velocity, TextureMap map, TextureMap tMap)
     : base(position, velocity, map, tMap, ENEMY_TYPE.BOSS)
 {
     Health = Constants.BOSS_STARTING_HEALTH;
     turretPosList = new List<Vector2>();
     sideways_movement = false;
     Vector2 posTemp = MidPoint;
     turretPosList.Add(posTemp);
     posTemp = new Vector2(MidPoint.X - mTexture.width / 5, MidPoint.Y);
     turretPosList.Add(posTemp);
     posTemp = new Vector2(MidPoint.X + mTexture.width / 5, MidPoint.Y);
     turretPosList.Add(posTemp);
     posTemp = new Vector2(MidPoint.X - mTexture.width / 3f, MidPoint.Y + mTexture.height / 14.5f);
     turretPosList.Add(posTemp);
     posTemp = new Vector2(MidPoint.X + mTexture.width / 3f, MidPoint.Y + mTexture.height / 14.5f);
     turretPosList.Add(posTemp);
     for (int i = 0; i < 4; ++i)
     {
         Gun.Add(new Turret(tMap));
     }
 }
Example #11
0
 public Turret(TextureMap tMap)
 {
     TMap = tMap;
 }
Example #12
0
 public abstract void addBackground(TextureMap t);
Example #13
0
 public override void addBackground(TextureMap t)
 {
     Backgrounds.Add(t);
 }
Example #14
0
        /// <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);
            background = Content.Load<Texture2D>("background1");
            background2 = Content.Load<Texture2D>("background2");
            Constants.init(ref graphics, ref spriteBatch, Content);
            plrMap = new TextureMap(Content.Load<Texture2D>("playership1"), 1, 1);
            laserMap = new TextureMap(Content.Load<Texture2D>("laser1"), 1, 1);
            enemyMap = new TextureMap(Content.Load<Texture2D>("enemy1"), 1, 1);
            bossMap = new TextureMap(Content.Load<Texture2D>("boss1"), 1, 1);

            Constants.player = new Player(Constants.DEFAULT_POSITION, plrMap, laserMap);
            explosion = new AnimatedSprite(Content.Load<Texture2D>("explosion1"), 1, 10, 55);
            Constants.mAnimationManager.addAnimation(new Animation(explosion, new Vector2(200.0f, 200.0f)));

            bg2pos = new Vector2(0.0f, -800.0f);
            Constants.mMainGameScreen = new GameScreen(ref spriteBatch, ref Constants.player, enemyMap, laserMap, bossMap, "background1", "background2");
            Constants.mSplashScreen = new SplashScreen("splashscreen1", ref spriteBatch, "Press Space To Begin");
            Constants.mEndScreenLose = new SplashScreen("splashscreen3", ref spriteBatch, "Press Escape To Exit");
            Constants.mEndScreenWin = new SplashScreen("splashscreen2", ref spriteBatch, "Press Escape To Exit");

            Vector2 menuPos = new Vector2((graphics.PreferredBackBufferWidth / 2)-32.0f, (graphics.PreferredBackBufferHeight * 0.33f));
            List<Button> btns = new List<Button>();
            btns.Add(new Button(new TextureMap(Content.Load<Texture2D>("ButtonStart"), 1, 1),
               new Vector2(menuPos.X, menuPos.Y), this.startGame));
            btns.Add(new Button(new TextureMap(Content.Load<Texture2D>("ButtonQuit"), 1, 1),
               new Vector2(menuPos.X, menuPos.Y + 36), this.Exit));

            Constants.mMenuScreen = new MenuScreen(ref spriteBatch, btns);
            Constants.mScreenStack.push(Constants.mSplashScreen);

            mSoundMgr = new SoundManager();

            // TODO: use this.Content to load your game content here
        }
Example #15
0
 public Player(Vector2 position, TextureMap map, TextureMap tMap)
     : base(position, map, ENTITY_TYPE.PLAYER)
 {
     Gun = new Turret(tMap);
 }
Example #16
0
 public override void addBackground(TextureMap t)
 {
 }