public static readonly int gameSpeed = 50;//(int)LevelSpeed.Normal;
 static void Main(string[] args)
 {   
     Renderer renderer = new Renderer(30, 30);
     Input movement = new Input();
     Engine engine = new Engine(renderer, gameSpeed, movement);
     
     Intialize(engine);
     Events(engine, movement);
     
     engine.Run();
 }
        public static void Events(Engine engine, Input movement)
        {
            movement.OnLeftArrowPress += (sender, eventInfo) =>
            {
                engine.MoveLeft();
            };

            movement.OnRightArrowPress += (sender, eventInfo) =>
            {
                engine.MoveRight();
            };

            movement.OnSpacebarPress += (sender, eventInfo) =>
            {
                engine.ExchangeFallingItemBlocksColors();
            };
        }
Ejemplo n.º 3
0
        public Engine(Renderer renderer, int gameSpeed, Input movement)
        {
            this.Renderer = renderer;
            this.movement = movement;

            this.fallenObjectsContainerMatrix = new GameObject[this.Renderer.GridMatrix.GetLength(0), this.Renderer.GridMatrix.GetLength(1)];
            this.staticObjects = new List<GameObject>();
            this.movableObjects = new List<GameObject>();
            this.allObjects = new List<GameObject>();
            this.infoObjects = new List<GameObject>();
            this.gameSpeed = gameSpeed;

            //Adding falling blocks structure
            this.fallingBlocksWrapper = new FallingBlocksWrapper(new Coordinates(6, (this.Renderer.GridMatrix.GetLength(1) / 2) - 1), new Coordinates(1, 0));
            
            foreach (var fallingBlock in this.fallingBlocksWrapper)
            {
                this.AddObject(fallingBlock);
            }
        }