Ejemplo n.º 1
0
 public Player()
 {
     shape = new DynamicShape(new Vec2F(), new Vec2F());
     taxiBoosterOffImageLeft =
         new Image(Path.Combine("Assets", "Images", "Taxi_Thrust_None.png"));
     taxiBoosterOffImageRight =
         new Image(Path.Combine("Assets", "Images", "Taxi_Thrust_None_Right.png"));
     taxiBoosterOnImageLeft =
         new ImageStride(80,
                         ImageStride.CreateStrides(2, Path.Combine("Assets", "Images", "Taxi_Thrust_Back.png")));
     taxiBoosterOnImageRight =
         new ImageStride(80,
                         ImageStride.CreateStrides(2, Path.Combine("Assets", "Images", "Taxi_Thrust_Back_Right.png")));
     taxiBoosterOnImageUp =
         new ImageStride(80,
                         ImageStride.CreateStrides(2, Path.Combine("Assets", "Images", "Taxi_Thrust_Bottom.png")));
     taxiBoosterOnImageUpRight =
         new ImageStride(80,
                         ImageStride.CreateStrides(2,
                                                   Path.Combine("Assets", "Images", "Taxi_Thrust_Bottom_Back_Right.png")));
     taxiBoosterOnImageUpLeft =
         new ImageStride(80,
                         ImageStride.CreateStrides(2, Path.Combine("Assets", "Images", "Taxi_Thrust_Bottom_Back.png")));
     Entity = new Entity(shape, taxiBoosterOffImageLeft);
     Entity.Shape.AsDynamicShape().ChangeDirection(new Vec2F(0.01f, 0.01f));
 }
Ejemplo n.º 2
0
        public void InitializeGameState()
        {
            //Player
            player = new Player();

            //Enemies
            squadronContainer = new List <ISquadron>();

            //Squadrons
            squad = new Squad();
            squad.CreateEnemies(ImageStride.CreateStrides(4,
                                                          Path.Combine("Assets", "Images", "BlueMonster.png")));

            boss = new Boss();
            boss.CreateEnemies(ImageStride.CreateStrides(4,
                                                         Path.Combine("Assets", "Images", "BlueMonster.png")));


            //Add to enemies
            squadronContainer.Add(squad);
            squadronContainer.Add(boss);
//            squadronContainer.Add(invasion);

            explosionStrides = ImageStride.CreateStrides(8,
                                                         Path.Combine("Assets", "Images", "Explosion.png"));

            explosions = new AnimationContainer(10);

            //Movement
            down = new Down();

            eventBus = GalagaBus.GetBus();
            eventBus.Subscribe(GameEventType.PlayerEvent, player);
        }
Ejemplo n.º 3
0
    public Game()
    {
        win       = new Window("galaga", 500, 500);
        gameTimer = new DIKUArcade.Timers.GameTimer(60, 60);
        player    = new Player(
            new DynamicShape(new Vec2F(0.45f, 0.1f), new Vec2F(0.1f, 0.1f)),
            new Image(Path.Combine("Assets", "Images", "Player.png")));

        eventBus = new GameEventBus <object>();
        eventBus.InitializeEventBus(new List <GameEventType>()
        {
            GameEventType.InputEvent,  // key press / key release
            GameEventType.WindowEvent, // messages to the window
        });

        win.RegisterEventBus(eventBus);
        eventBus.Subscribe(GameEventType.InputEvent, this);
        eventBus.Subscribe(GameEventType.WindowEvent, this);


        enemyStrides = ImageStride.CreateStrides(4,
                                                 Path.Combine("Assets", "Images", "BlueMonster.png"));
        enemies = new List <Enemy>();
        Enemy.addEnemies(new ImageStride(80, enemyStrides));

        PlayerShots = new List <PlayerShot>();

        score = new Score(new Vec2F(0.9f, 0.9f), new Vec2F(0.1f, 0.1f));
    }
Ejemplo n.º 4
0
        public void InitializeGameState()
        {
            backGroundImage = new Entity(
                new StationaryShape(new Vec2F(0.0f, 0.0f), new Vec2F(1.0f, 1.0f)),
                new Image(Path.Combine("Assets", "Images", "SpaceBackground.png")));

            player = new Player();

            enemies      = new EntityContainer <Enemy>();
            enemyStrides = ImageStride.CreateStrides(4,
                                                     Path.Combine("Assets", "Images", "BlueMonster.png"));

            var sqr = new Squadron2();

            sqr.CreateEnemies(enemyStrides);
            enemies          = sqr.Enemies;
            movementStrategy = new ZigZagDown();

            playerShots = new EntityContainer();
            shotStride  = new Image(Path.Combine("Assets", "Images", "BulletRed2.png"));

            explosionStrides = ImageStride.CreateStrides(8,
                                                         Path.Combine("Assets", "Images", "Explosion.png"));
            explosions = new AnimationContainer(4);
        }
Ejemplo n.º 5
0
        public GameRunning()
        {
            isGameOver = false;

            player = new Player(new DynamicShape(new Vec2F(0.45f, 0.1f), new Vec2F(0.1f, 0.1f)),
                                new Image(Path.Combine("Assets", "Images", "Player.png")));
            score        = new Score(new Vec2F(0.02f, 0.7f), new Vec2F(0.3f, 0.3f));
            enemyStrides = ImageStride.CreateStrides(4,
                                                     Path.Combine("Assets", "Images", "BlueMonster.png"));
            squiggleSquadron = new SquiggleSquadron(6);
            AddEnemies();

            noMove     = new NoMove();
            down       = new Down();
            zigZagDown = new ZigZagDown();

            playerShots = new List <PlayerShot>();
            // Preloads the bullet image
            bullet           = new Image(Path.Combine("Assets", "Images", "BulletRed2.png"));
            explosionStrides = ImageStride.CreateStrides(8, Path.Combine("Assets", "Images", "Explosion.png"));
            // Here the constructor is given the argument 6 since that is the total amount of enemies.
            explosions = new AnimationContainer(6);
            //backGroundImage = new Entity(new StationaryShape(new Vec2F(0.2f, 0.2f), new Vec2F(0.5f, 0.5f)), new Image("Assets/Images/TitleImage.png"));
            GalagaBus.GetBus().Subscribe(GameEventType.MovementEvent, player);
        }
Ejemplo n.º 6
0
 public Game()
 {
     win          = new Window("test", 500, 500);
     score        = new Score(new Vec2F(0.0f, 0.0f), new Vec2F(0.2f, 0.2f));
     gameTimer    = new GameTimer(60, 60);
     enemyStrides = ImageStride.CreateStrides(4,
                                              Path.Combine("Assets", "Images", "BlueMonster.png"));
     enemies = new List <Enemy>();
     player  = new Player(this,
                          new DynamicShape(new Vec2F(0.45f, 0.1f), new Vec2F(0.1f, 0.1f)),
                          new Image(Path.Combine("Assets", "Images", "Player.png")));
     moveDown          = new MoveDown();
     noMove            = new NoMove();
     zigZagDown        = new ZigZagDown();
     createEnemiesLine = new CreateEnemiesLine(this, enemies);
     createEnemiesLine.CreateEnemies(enemyStrides);
     shotImages  = new Image(Path.Combine("Assets", "Images", "BulletRed2.png"));
     playerShots = new List <PlayerShot>();
     eventBus    = new GameEventBus <object>();
     eventBus.InitializeEventBus(new List <GameEventType>()
     {
         GameEventType.InputEvent,
         GameEventType.WindowEvent,
         GameEventType.PlayerEvent
     });
     win.RegisterEventBus(eventBus);
     eventBus.Subscribe(GameEventType.InputEvent, this);
     eventBus.Subscribe(GameEventType.WindowEvent, this);
     eventBus.Subscribe(GameEventType.PlayerEvent, player);
     explosionStrides = ImageStride.CreateStrides(8,
                                                  Path.Combine("Assets", "Images", "Explosion.png"));
     explosions = new AnimationContainer(20);
 }
Ejemplo n.º 7
0
        public Game()
        {
            gameTimer    = new GameTimer(60, 60);
            win          = new Window("Galaca", 500, AspectRatio.R1X1);
            backGround   = new Image(Path.Combine("Assets", "Images", "SpaceBackground.png"));
            player       = new Player();
            enemies      = new EntityContainer();
            enemyStrides = ImageStride.CreateStrides(4,
                                                     Path.Combine("Assets", "Images", "BlueMonster.png"));
            AddEnemies();
            playerShots = new EntityContainer();
            shotStride  = new Image(Path.Combine("Assets", "Images", "BulletRed2.png"));

            explosionStrides = ImageStride.CreateStrides(8,
                                                         Path.Combine("Assets", "Images", "Explosion.png"));
            explosions = new AnimationContainer(4);

            eventBus = new GameEventBus <object>();
            eventBus.InitializeEventBus(new List <GameEventType>()
            {
                GameEventType.InputEvent,
                GameEventType.WindowEvent,
                GameEventType.PlayerEvent
            });

            win.RegisterEventBus(eventBus);
            eventBus.Subscribe(GameEventType.InputEvent, this);
            eventBus.Subscribe(GameEventType.WindowEvent, this);
        }
Ejemplo n.º 8
0
        public Player()
        {
            shape = new DynamicShape(new Vec2F(), new Vec2F());

            taxiBoosterOffImageLeft =
                new Image(Path.Combine("Assets", "Images", "Taxi_Thrust_None.png"));
            taxiBoosterOffImageRight =
                new Image(Path.Combine("Assets", "Images", "Taxi_Thrust_None_Right.png"));

            taxiBoosterOnLeft = new ImageStride(10, ImageStride.CreateStrides(
                                                    2, Path.Combine("Assets", "Images", "Taxi_Thrust_Back.png")));
            taxiBoosterOnRight = new ImageStride(10, ImageStride.CreateStrides(
                                                     2, Path.Combine("Assets", "Images", "Taxi_Thrust_Back_Right.png")));
            taxiBoosterOnBottomBackLeft = new ImageStride(10, ImageStride.CreateStrides(
                                                              2, Path.Combine("Assets", "Images", "Taxi_Thrust_Bottom_Back.png")));
            taxiBoosterOnBottomBackRight = new ImageStride(10, ImageStride.CreateStrides(
                                                               2, Path.Combine("Assets", "Images", "Taxi_Thrust_Bottom_Back_Right.png")));
            taxiBoosterOnBottomLeft = new ImageStride(10, ImageStride.CreateStrides(
                                                          2, Path.Combine("Assets", "Images", "Taxi_Thrust_Bottom.png")));
            taxiBoosterOnBottomRight = new ImageStride(10, ImageStride.CreateStrides(
                                                           2, Path.Combine("Assets", "Images", "Taxi_Thrust_Bottom_Right.png")));

            BottomBoosterActive      = false;
            LeftOrRightBoosterActive = false;

            physics = new Physics(40);

            Entity = new Entity(shape, taxiBoosterOffImageLeft);
        }
Ejemplo n.º 9
0
        public void InitializeGameState()
        {
            stateMachine = new StateMachine();
            player       = new Player(this,
                                      shape: new DynamicShape(new Vec2F(0.45f, 0.1f), new Vec2F(0.1f, 0.1f)),
                                      image: new Image(Path.Combine("Assets", "Images", "Player.png")));

            GalagaBus.GetBus().InitializeEventBus(new List <GameEventType>()
            {
                GameEventType.PlayerEvent
            });

            GalagaBus.GetBus().Subscribe(GameEventType.PlayerEvent, player);

            enemyStrides =
                ImageStride.CreateStrides(4, Path.Combine("Assets", "Images", "BlueMonster.png"));
            enemies = new EntityContainer <Enemy>();

            PlayerShot  = new Image(Path.Combine("Assets", "Images", "BlueMonster.png"));
            playerShots = new EntityContainer <PlayerShot>();

            explosionStrides = ImageStride.CreateStrides(8,
                                                         Path.Combine("Assets", "Images", "Explosion.png"));
            explosions = new AnimationContainer(40);

            score = new Score(new Vec2F(0.43f, -0.12f), new Vec2F(0.2f, 0.2f));

            v_Formation = new V_Formation();
            v_Formation.CreateEnemies(enemyStrides);
            enemies = v_Formation.Enemies;

            down       = new Down();
            zigzagdown = new ZigZagDown();
            noMove     = new NoMove();
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Constructor for Game class
        /// </summary>
        public Game()
        {
            win       = new Window("Galaga", 500, 500);
            gameTimer = new GameTimer(60, 60);

            player = new Player(this,
                                new DynamicShape(new Vec2F(0.45f, 0.1f), new Vec2F(0.1f, 0.1f)),
                                new Image(Path.Combine("Assets", "Images", "Player.png")));

            eventBus = new GameEventBus <object>();
            eventBus.InitializeEventBus(new List <GameEventType> {
                GameEventType.InputEvent, // key press / key release
                GameEventType.WindowEvent // messages to the window
            });
            win.RegisterEventBus(eventBus);
            eventBus.Subscribe(GameEventType.InputEvent, this);
            eventBus.Subscribe(GameEventType.WindowEvent, this);

            enemyStrides = ImageStride.CreateStrides(4,
                                                     Path.Combine("Assets", "Images", "BlueMonster.png"));
            enemies = new List <Enemy>();

            playerShots     = new List <PlayerShot>();
            playerShotImage = new Image(
                Path.Combine("Assets", "Images", "BulletRed2.png"));

            explosionStrides = ImageStride.CreateStrides(8,
                                                         Path.Combine("Assets", "Images", "Explosion.png"));
            explosions = new AnimationContainer(4);

            score = new Score(new Vec2F(0.01f, -0.25f), new Vec2F(0.3f, 0.3f));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Parameters and methods the passenger needs to be created
        /// </summary>
        /// <param name="name">Name of passenger</param>
        /// <param name="timeBeforeSpawning">Spawn timer</param>
        /// <param name="platformSpawn">Which platform to spawn on</param>
        /// <param name="platformRelease">Which platform to be dropped off at</param>
        /// <param name="timeBeforeRelease">Time before release</param>
        /// <param name="cash">Points given</param>
        /// <param name="thePlatform">The platform to be dropped at</param>
        /// <param name="spawnLevel">In which level to spawn</param>
        public Passenger(
            string name, int timeBeforeSpawning, char platformSpawn, string platformRelease, int timeBeforeRelease,
            int cash, List <Dictionary <char, List <Entity> > > thePlatform, int spawnLevel)
        {
            shape      = new DynamicShape(new Vec2F(), new Vec2F());
            imageWalk  = new ImageStride(80, ImageStride.CreateStrides(2, Path.Combine("Assets", "Images", "CustomerWalkLeft.png")));
            _passenger = new Entity(shape, imageWalk);
            this.name  = name;
            this.timeBeforeSpawning = timeBeforeSpawning;
            this.platformSpawn      = platformSpawn;
            this.platformRelease    = platformRelease;
            this.timeBeforeRelease  = timeBeforeRelease;
            this.cash       = cash;
            _thePlatform    = thePlatform;
            this.spawnLevel = spawnLevel;


            if (platformRelease.Length > 1)
            {
                SetOffLevel = spawnLevel + 1;
            }
            else
            {
                SetOffLevel = spawnLevel;
            }


            shape.Direction.X = 0.00045f;
        }
Ejemplo n.º 12
0
        public Player()
        {
            Shape = new DynamicShape(new Vec2F(), new Vec2F(0.06F, 0.06F));


            thrusterOffImageLeft  = new Image(Utils.GetImageFilePath("Taxi_Thrust_None.png"));
            thrusterOffImageRight = new Image(Utils.GetImageFilePath("Taxi_Thrust_None_Right.png"));

            thrusterOnImageBackLeft = new ImageStride(1000,
                                                      ImageStride.CreateStrides(2,
                                                                                Utils.GetImageFilePath("Taxi_Thrust_Back.png")));
            thrusterOnImageBackRight = new ImageStride(1000,
                                                       ImageStride.CreateStrides(2,
                                                                                 Utils.GetImageFilePath("Taxi_Thrust_Back_Right.png")));

            thrusterOnImageBottomLeft = new ImageStride(1000,
                                                        ImageStride.CreateStrides(2,
                                                                                  Utils.GetImageFilePath("Taxi_Thrust_Bottom.png")));
            thrusterOnImageBottomRight = new ImageStride(1000,
                                                         ImageStride.CreateStrides(2,
                                                                                   Utils.GetImageFilePath("Taxi_Thrust_Bottom_Right.png")));

            thrusterOnImageBottomBackLeft = new ImageStride(1000,
                                                            ImageStride.CreateStrides(2,
                                                                                      Utils.GetImageFilePath("Taxi_Thrust_Bottom_Back.png")));
            thrusterOnImageBottomBackRight = new ImageStride(1000,
                                                             ImageStride.CreateStrides(2,
                                                                                       Utils.GetImageFilePath("Taxi_Thrust_Bottom_Back_Right.png")));

            Entity = new Entity(Shape, thrusterOffImageLeft);
            EventBus.GetBus().Subscribe(GameEventType.PlayerEvent, this);
        }
Ejemplo n.º 13
0
        public GameRunning()
        {
            backgroundImage = new Image(Path.Combine("Assets", "Images", "SpaceBackground.png"));
            player          = new Player(new Vec2F(0.45f, 0.1f), new Vec2F(0.1f, 0.1f));

            enemeySquadrons = new List <ISquadron>()
            {
                new BlueSquadron(),
                new GreenSquadron(),
                new RedSquadron()
            };
            greenEnemy = ImageStride.CreateStrides(2,
                                                   Path.Combine("Assets", "Images", "GreenMonster.png"));
            blueEnemy = ImageStride.CreateStrides(4,
                                                  Path.Combine("Assets", "Images", "BlueMonster.png"));
            redEnemy = ImageStride.CreateStrides(2,
                                                 Path.Combine("Assets", "Images", "RedMonster.png"));
            enemyTypes = new List <List <Image> >()
            {
                blueEnemy, greenEnemy, redEnemy
            };
            zigZagDown       = new ZigZagDown();
            explosionStrides = ImageStride.CreateStrides(8,
                                                         Path.Combine("Assets", "Images", "Explosion.png"));
            explosions  = new AnimationContainer(80);
            projectiles = new EntityContainer();
            laserImage  = new Image(Path.Combine("Assets", "Images", "BulletRed2.png"));

            for (int i = 0; i < enemeySquadrons.Count; i++)
            {
                enemeySquadrons[i].CreateEnemies(enemyTypes[i]);
            }
        }
Ejemplo n.º 14
0
        public Game()
        {
            win = new Window("Galaga", 500, AspectRatio.R16X9);


            //Player
            player = new Player();


            //Enemies
            squadronContainer = new List <ISquadron>();

            //Squadrons
            squad = new Squad();
            squad.CreateEnemies(ImageStride.CreateStrides(4,
                                                          Path.Combine("Assets", "Images", "BlueMonster.png")));

            boss = new Boss();
            boss.CreateEnemies(ImageStride.CreateStrides(4,
                                                         Path.Combine("Assets", "Images", "BlueMonster.png")));

//            invasion = new Invasion();
//            invasion.CreateEnemies(ImageStride.CreateStrides(4,
//                Path.Combine("Assets", "Images", "BlueMonster.png")));


            //Add to enemies
            squadronContainer.Add(squad);
            squadronContainer.Add(boss);
//            squadronContainer.Add(invasion);


            //Explosiom
            explosionStrides = ImageStride.CreateStrides(8,
                                                         Path.Combine("Assets", "Images", "Explosion.png"));

            explosions = new AnimationContainer(10);

            //Movement
            down = new Down();

            //Eventbus
            eventBus = new GameEventBus <object>();
            eventBus.InitializeEventBus(new List <GameEventType>()
            {
                GameEventType.InputEvent,  // key press / key release
                GameEventType.WindowEvent, // messages to the window
                GameEventType.PlayerEvent  // commands issued to the player object,
            });                            // e.g. move, destroy, receive health, etc.
            win.RegisterEventBus(eventBus);
            eventBus.Subscribe(GameEventType.InputEvent, this);
            eventBus.Subscribe(GameEventType.WindowEvent, this);
            eventBus.Subscribe(GameEventType.PlayerEvent, player);


            //Gametimer
            gameTimer = new GameTimer(60, 60);
        }
Ejemplo n.º 15
0
    public PlayerShot(DynamicShape shape, IBaseImage image) : base(shape, image)
    {
        Entity = new Entity(shape, image);
        Entity.Shape.AsDynamicShape().Direction = new Vec2F(0.0f, 0.01f);

        explosionStrides = ImageStride.CreateStrides(8,
                                                     Path.Combine("Assets", "Images", "Explosion.png"));
        explosions = new AnimationContainer(8);
    }
Ejemplo n.º 16
0
        /// <summary>
        /// If collision happens with obstacle or hits the platform to hard
        /// explosion happends.
        /// </summary>
        /// <param name="player">Player</param>
        public static void CreateExplosion(Entities.Player.Player player)
        {
            ObstacleCollision.explsionShape = new StationaryShape(new Vec2F(player.GetsShape().Position.X, player.GetsShape().Position.Y),
                                                                  new Vec2F(player.GetsShape().Extent.X, player.GetsShape().Extent.Y));
            ObstacleCollision.explosionStrides = ImageStride.CreateStrides(8,
                                                                           Path.Combine("Assets", "Images", "Explosion.png"));

            ObstacleCollision.EXPLOSION.AddAnimation(ObstacleCollision.explsionShape, 500,
                                                     new ImageStride(500 / 8, ObstacleCollision.explosionStrides));
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Returns an IBaseImage for the customer class to use.
        /// </summary>
        /// <returns>IBaseImage of customer</returns>
        private IBaseImage[] MakeCustomerStrides()
        {
            var images = new IBaseImage[2];

            images[0] = new ImageStride(80, ImageStride.CreateStrides(2,
                                                                      Path.Combine("Assets", "Images", "CustomerWalkLeft.png")));
            images[1] = new ImageStride(80, ImageStride.CreateStrides(2,
                                                                      Path.Combine("Assets", "Images", "CustomerWalkRight.png")));
            return(images);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Translates the ASCII map with a set of keys.
        /// </summary>
        private void AsciiToLevel(IEnumerable <string> text,
                                  Dictionary <char, Platform> platformKeys, Dictionary <char, Image> keyLegend)
        {
            // map is 23 x 40, calculate size of each levelSprite
            float height = 1f / 23f;
            float width  = 1f / 40f;

            // translate from ascii to game level, each char represents an entity
            var textArr = text.ToArray();

            for (int i = 0; i < 23; i++)
            {
                for (int j = 0; j < 40; j++)
                {
                    char _char = textArr[22 - i][j];

                    // ^ is the ascii symbol for the exit
                    if (_char == '^')
                    {
                        var exitStrides = ImageStride.CreateStrides(4,
                                                                    Path.Combine("Assets", "Images", "aspargus-passage.png"));
                        var shape = new StationaryShape(
                            new Vec2F(width * j, i * height), new Vec2F(width, height));
                        var e = new Exit();
                        e.PropSprites.AddStationaryEntity(
                            shape, new ImageStride(30, exitStrides));
                        Props.Add(e);
                        // > is the ascii symbol for the player, set player position
                    }
                    else if (_char == '>')
                    {
                        Player.Entity.Shape.Position =
                            new Vec2F(width * j - width, i * height - height / 2);
                    }
                    else if (_char != ' ')
                    {
                        // add the char as an Entity to the appropriate container
                        EntityContainer container;
                        if (platformKeys.ContainsKey(_char))
                        {
                            container = platformKeys[_char].PropSprites;
                        }
                        else
                        {
                            container = LevelSprites;
                        }
                        container.AddStationaryEntity(
                            new StationaryShape(
                                new Vec2F(width * j, i * height),
                                new Vec2F(width, height)),
                            keyLegend[_char]);
                    }
                }
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Decide which image to use for the player. Depending on which key that the user
        /// are pressing.
        /// </summary>
        /// <param name="value">integer that changes depending on which input it gets from the
        /// player class</param>
        /// <returns></returns>
        public static IBaseImage ImageDecider(int value)
        {
            switch (value)
            {
            case -2:
                PlayerImage.taxiImage = new ImageStride(80,
                                                        ImageStride.CreateStrides(2,
                                                                                  Path.Combine("Assets", "Images", "Taxi_Thrust_Back_Right.png")));
                break;

            case -1:
                PlayerImage.taxiImage =
                    new Image(Path.Combine("Assets", "Images", "Taxi_Thrust_None_Right.png"));
                break;

            case 1:
                PlayerImage.taxiImage = new Image(Path.Combine("Assets", "Images", "Taxi_Thrust_None.png"));
                break;

            case 2:
                PlayerImage.taxiImage = new ImageStride(80,
                                                        ImageStride.CreateStrides(2,
                                                                                  Path.Combine("Assets", "Images", "Taxi_Thrust_Back.png")));
                break;

            case 8:
                PlayerImage.taxiImage = new ImageStride(80,
                                                        ImageStride.CreateStrides(2,
                                                                                  Path.Combine("Assets", "Images", "Taxi_Thrust_Bottom_Back_Right.png")));
                break;

            case 9:
                PlayerImage.taxiImage = new ImageStride(80,
                                                        ImageStride.CreateStrides(2,
                                                                                  Path.Combine("Assets", "Images", "Taxi_Thrust_Bottom_Right.png")));
                break;

            case 11:
                PlayerImage.taxiImage = new ImageStride(80,
                                                        ImageStride.CreateStrides(2,
                                                                                  Path.Combine("Assets", "Images", "Taxi_Thrust_Bottom.png")));
                break;

            case 12:
                PlayerImage.taxiImage = new ImageStride(80,
                                                        ImageStride.CreateStrides(2,
                                                                                  Path.Combine("Assets", "Images", "Taxi_Thrust_Bottom_Back.png")));
                break;

            default:
                PlayerImage.taxiImage = new Image(Path.Combine("Assets", "Images", "Taxi_Thrust_None.png"));
                break;
            }
            return(PlayerImage.taxiImage);
        }
Ejemplo n.º 20
0
        public void RenderPlayer()
        {
            // Thruster checking.
            switch (_thrusterOrientation)
            {
            case Orientation.Left:
                Entity.Image = _taxiBoosterOnImageLeft;
                break;

            case Orientation.Right:
                Entity.Image = _taxiBoosterOnImageRight;
                break;

            case Orientation.Up:
                switch (_taxiOrientation)
                {
                case Orientation.Left:
                    Entity.Image = _taxiBoosterOnImageBottomLeft;
                    break;

                case Orientation.Right:
                    Entity.Image = _taxiBoosterOnImageBottomRight;
                    break;
                }
                break;

            case Orientation.UpLeft:
                Entity.Image = _taxiBoosterOnImageBottomAndLeft;
                break;

            case Orientation.UpRight:
                Entity.Image = _taxiBoosterOnImageBottomAndRight;
                break;

            case Orientation.None:
                // no thrusters active.
                Entity.Image = _taxiOrientation == Orientation.Left
                    ? _taxiBoosterOffImageLeft
                    : _taxiBoosterOffImageRight;
                break;
            }
            // check if the taxi has collided
            switch (IsExploding)
            {
            case true:
                // render the explosion at the taxies location.
                var explosion = new ImageStride(120 / 8, explosionStrides);
                explosion.Render(shape);
                break;

            default:
                Entity.RenderEntity();
                break;
            }
        }
Ejemplo n.º 21
0
        public static void MainFunction()
        {
            var win = new Window("hej", 500, AspectRatio.R1X1);

            win.SetClearColor(System.Drawing.Color.Brown);

            var images = ImageStride.CreateStrides(4, "BlueMonster.png");

            var entities = new EntityContainer(10);

            for (int i = 0; i < 10; i++)
            {
                var shape = new DynamicShape(new Vec2F(i * 0.1f, 0.9f), new Vec2F(0.1f, 0.1f));
                entities.AddDynamicEntity(shape, new ImageStride(80, images[0], images[1], images[2], images[3]));
            }

            win.AddKeyPressEventHandler(delegate(KeyboardKeyEventArgs keyArgs) {
                if (keyArgs.Key == Key.Left)
                {
                    entities.Iterate(delegate(Entity entity) {
                        entity.Shape.MoveX(-0.05f);
                    });
                }
                if (keyArgs.Key == Key.Right)
                {
                    entities.Iterate(delegate(Entity entity) {
                        entity.Shape.MoveX(0.05f);
                    });
                }
                if (keyArgs.Key == Key.Up)
                {
                    entities.Iterate(delegate(Entity entity) {
                        entity.Shape.MoveY(0.05f);
                    });
                }
                if (keyArgs.Key == Key.Down)
                {
                    entities.Iterate(delegate(Entity entity) {
                        entity.Shape.MoveY(-0.05f);
                    });
                }
            });

            while (win.IsRunning())
            {
                win.PollEvents();
                win.Clear();

                entities.RenderEntities();

                win.SwapBuffers();
            }
            Console.WriteLine("window closed now");
        }
Ejemplo n.º 22
0
        public void CreateEnemies(List <Image> enemyStrides)
        {
            List <Vec2F> positionList = PositionList();

            for (int i = 0; i < positionList.Count; i++)
            {
                enemystride = new ImageStride(60, enemyStrides);
                Vec2F position = positionList[i];
                Enemies.AddDynamicEntity(new Enemy(new StationaryShape(position, Invasion.size), enemystride));
            }
        }
Ejemplo n.º 23
0
        public void CreateEnemies(List <Image> enemyStrides)
        {
            Vec2F       sizeVec     = new Vec2F(0.1f, 0.1f);
            ImageStride imageStride = new ImageStride(80, enemyStrides);

            for (int i = 0; i < MaxEnemies; i++)
            {
                Enemies.AddDynamicEntity(new Enemy(
                                             new DynamicShape(new Vec2F(((i + 1.0f) / 4.0f) - 0.175f, 0.8f), sizeVec),
                                             imageStride));
            }
        }
Ejemplo n.º 24
0
        public void InitializeGameState()
        {
            player = new Player();
            player.SetPosition(ChoseLevel.GetInstance().posX, ChoseLevel.GetInstance().posY);
            player.SetExtent(ChoseLevel.GetInstance().extX, ChoseLevel.GetInstance().extY);
            SpaceTaxiBus.GetBus().Subscribe(GameEventType.PlayerEvent, player);
            SpaceTaxiBus.GetBus().Subscribe(GameEventType.PlayerEvent, player);
            CreateLevel(ChoseLevel.GetInstance().filename);
            explosionStrides = ImageStride.CreateStrides(8,
                                                         Path.Combine("Assets", "Images", "Explosion.png"));
            explosions = new AnimationContainer(5);

            currentVelocity = new Vec2F(0f, 0f);
        }
Ejemplo n.º 25
0
        public Collision(string activelevel)
        {
            Activeplatforms = new Parser(CollisionPlatforms.GetPlatform(activelevel));
            Activeplatforms.CreateEntityList();
            explosionStrides = ImageStride.CreateStrides(8,
                                                         Path.Combine("Assets", "Images", "Explosion.png"));
            explosions      = new AnimationContainer(500);
            explosionLength = 500;

            GameOver = new Text("Game's Over", new Vec2F(0.42f, 0.5f),
                                new Vec2F(0.3f, 0.3f));
            GameOver.SetText("Game's Over\nPress Space");
            GameOver.SetColor(new Vec3I(0, 255, 0));
        }
Ejemplo n.º 26
0
 public void InitializeGameState()
 {
     player = new Player(game,
                         new DynamicShape(new Vec2F(0.45f, 0.1f), new Vec2F(0.1f, 0.1f)),
                         new Image(Path.Combine("Assets", "Images", "Player.png")));
     enemyStrides = ImageStride.CreateStrides(4,
                                              Path.Combine("Assets", "Images", "BlueMonster.png"));
     enemies          = new List <Enemy>();
     score            = new Score(new Vec2F(0.0f, 0.0f), new Vec2F(0.2f, 0.2f));
     explosionStrides = ImageStride.CreateStrides(8,
                                                  Path.Combine("Assets", "Images", "Explosion.png"));
     explosions = new AnimationContainer(20);
     CreateEnemies(enemyStrides);
     GalagaBus.GetBus().Subscribe(GameEventType.PlayerEvent, player);
 }
Ejemplo n.º 27
0
        public LevelAbstract()
        {
            backGroundImage = new Entity(
                new StationaryShape(new Vec2F(0, 0), new Vec2F(1, 1)),
                new Image(Path.Combine("Assets", "Images", "SpaceBackground.png")));

            // Player
            player = new Player(
                new DynamicShape(
                    new Vec2F(0.45f, 0.1f),
                    new Vec2F(0.1f, 0.1f))
                );

            // Explosions
            explosionStrides =
                ImageStride.CreateStrides(8, Path.Combine("Assets", "Images", "Explosion.png"));
            explosions = new AnimationContainer(8);
        }
Ejemplo n.º 28
0
        public GameRunning()
        {
            paintBoard = new PaintBoard("short-n-sweet.txt");

            player = new Player();
            player.SetPosition(0.45f, 0.6f);
            player.SetExtent(0.1f, 0.1f);
            playerList.Add(player);

            backGroundImage = new Entity(
                new StationaryShape(new Vec2F(0.0f, 0.0f), new Vec2F(1.0f, 1.0f)),
                new Image(Path.Combine("Assets", "Images", "SpaceBackground.png"))
                );

            explosionStrides =
                ImageStride.CreateStrides(8, Path.Combine("Assets", "Images", "Explosion.png"));
            explosion = new AnimationContainer(8);
        }
Ejemplo n.º 29
0
        public static void MainFunction()
        {
            var win = new Window("TestAnimationContainer", 500, AspectRatio.R1X1);

            var container = new AnimationContainer(4);
            var strides   = ImageStride.CreateStrides(4, "PuffOfSmoke.png");

            win.AddKeyPressEventHandler(delegate(KeyboardKeyEventArgs keyArgs) {
                switch (keyArgs.Key)
                {
                case Key.Escape:
                    win.CloseWindow();
                    break;

                case Key.Number1:
                    container.AddAnimation(new StationaryShape(0.0f, 0.0f, 0.5f, 0.5f), 1000,
                                           new ImageStride(80, strides));
                    break;

                case Key.Number2:
                    container.AddAnimation(new StationaryShape(0.5f, 0.0f, 0.5f, 0.5f), 1000,
                                           new ImageStride(80, strides));
                    break;

                case Key.Number3:
                    container.AddAnimation(new StationaryShape(0.0f, 0.5f, 0.5f, 0.5f), 1000,
                                           new ImageStride(80, strides));
                    break;

                case Key.Number4:
                    container.AddAnimation(new StationaryShape(0.5f, 0.5f, 0.5f, 0.5f), 1000,
                                           new ImageStride(80, strides));
                    break;
                }
            });

            while (win.IsRunning())
            {
                win.PollEvents();
                win.Clear();
                container.RenderAnimations();
                win.SwapBuffers();
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Returns an array of IBaseImage objects of the player representing all possible movements
        /// of the player
        /// </summary>
        /// <returns>IBaseImage array</returns>
        private IBaseImage[,] MakePlayerStrides()
        {
            var images = new IBaseImage[2, 4];

            images[0, 0] = new Image(Path.Combine("Assets", "Images", "Taxi_Thrust_None.png"));
            images[1, 0] = new Image(Path.Combine("Assets", "Images", "Taxi_Thrust_None_Right.png"));
            images[0, 1] = new ImageStride(80, ImageStride.CreateStrides(2,
                                                                         Path.Combine("Assets", "Images", "Taxi_Thrust_Back.png")));
            images[0, 2] = new ImageStride(80, ImageStride.CreateStrides(2,
                                                                         Path.Combine("Assets", "Images", "Taxi_Thrust_Bottom_Back.png")));
            images[0, 3] = new ImageStride(80, ImageStride.CreateStrides(2,
                                                                         Path.Combine("Assets", "Images", "Taxi_Thrust_Bottom.png")));
            images[1, 1] = new ImageStride(80, ImageStride.CreateStrides(2,
                                                                         Path.Combine("Assets", "Images", "Taxi_Thrust_Back_Right.png")));
            images[1, 2] = new ImageStride(80, ImageStride.CreateStrides(2,
                                                                         Path.Combine("Assets", "Images", "Taxi_Thrust_Bottom_Back_Right.png")));
            images[1, 3] = new ImageStride(80, ImageStride.CreateStrides(2,
                                                                         Path.Combine("Assets", "Images", "Taxi_Thrust_Bottom_Right.png")));
            return(images);
        }