예제 #1
0
        public StarWarrier()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            graphics.PreferredBackBufferWidth  = Constantes.SCREEN_WIDTH;
            graphics.PreferredBackBufferHeight = Constantes.SCREEN_HEIGHT;
            graphics.PreferMultiSampling       = false;
            graphics.IsFullScreen = true;

            for (int i = 0; i < Constantes.SHOT_COUNT; i++)
            {
                player_laser_x.Add(Constantes.DEFAULT_POSITION);
                player_laser_y.Add(Constantes.DEFAULT_POSITION);
            }

            enemy_laser_x = Constantes.DEFAULT_POSITION;
            enemy_laser_y = Constantes.DEFAULT_POSITION;


            gameover_x = (Constantes.SCREEN_WIDTH - Constantes.GAMEOVER_WIDTH) / 2;
            gameover_y = (Constantes.SCREEN_HEIGHT - Constantes.GAMEOVER_HEIGHT) / 2;

            // Inicializa a posição dos objetos de forma randômica
            SetMeteorBigPosition();
            SetMeteorSmallPosition();
            SetEnemyUfoPosition();
            SetEnemyShipPosition();

            player = new Player(this);

            for (int i = 0; i < Constantes.SHOT_COUNT; i++)
            {
                shots.Add(new RedLaser(this, new Vector2(player_laser_x[i], player_laser_y[i])));
            }

            enemyLaser  = new GreenLaser(this, new Vector2(enemy_laser_x, enemy_laser_y));
            meteorBig   = new MeteorBig(this, new Vector2(meteor_big_x, meteor_big_y));
            meteorSmall = new MeteorSmall(this, new Vector2(meteor_small_x, meteor_small_y));
            enemyUfo    = new EnemyUfo(this, new Vector2(enemy_ufo_x, enemy_ufo_y));
            enemyShip   = new EnemyShip(this, new Vector2(enemy_ship_x, enemy_ship_y));
            gameOver    = new GameOver(this, new Vector2(gameover_x, gameover_y));

            // Referência pra movimentação da tela
            y = 0;

            // Velocidade da tela
            starSpeed = 15;

            // Cria um timer para o enemyUFO
            // O evento é executado a cada 12 segundos
            enemyUfoTimer = new Timer(12 * 1000);
            enemyUfoTimer.Start();
            enemyUfoTimer.Elapsed += new ElapsedEventHandler(OnEnemyUfoTimer);

            enemy_increment = true;

            game_over = false;
        }
        public StarWarrier()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            graphics.PreferredBackBufferWidth  = Constantes.SCREEN_WIDTH;
            graphics.PreferredBackBufferHeight = Constantes.SCREEN_HEIGHT;
            graphics.PreferMultiSampling       = false;
            graphics.IsFullScreen = true;

            player_laser_x = -50;
            player_laser_y = -50;

            enemy_laser_x = -50;
            enemy_laser_y = -50;


            SetMeteorBigPosition();
            SetMeteorSmallPosition();
            SetEnemyUfoPosition();
            SetEnemyShipPosition();

            player      = new Player(this);
            playerLaser = new RedLaser(this, new Vector2(player_laser_x, player_laser_y));
            enemyLaser  = new GreenLaser(this, new Vector2(enemy_laser_x, enemy_laser_y));
            meteorBig   = new MeteorBig(this, new Vector2(meteor_big_x, meteor_big_y));
            meteorSmall = new MeteorSmall(this, new Vector2(meteor_small_x, meteor_small_y));
            enemyUfo    = new EnemyUfo(this, new Vector2(enemy_ufo_x, enemy_ufo_y));
            enemyShip   = new EnemyShip(this, new Vector2(enemy_ship_x, enemy_ship_y));

            y = 0;

            starSpeed = 15;

            enemyUfoTimer = new Timer(12 * 1000);
            enemyUfoTimer.Start();
            enemyUfoTimer.Elapsed += new ElapsedEventHandler(OnEnemyUfoTimer);

            enemy_increment = true;

            game_over = false;
        }