Esempio n. 1
0
        public Player(Camera Camera)
        {
            Camera.ResetZoom();

            Animation = new SimpleAnimation(new AnimationFrame(this, "block", 0, 0, GameConstants.BlockSize, GameConstants.BlockSize * 2));

            var flagGrounded = new FlagAsGrounded(this);

            Collider = new Collider(this)
            {
                Width            = GameConstants.BlockSize - 2,
                Height           = (GameConstants.BlockSize * 2) - 2,
                OffsetX          = 1,
                OffsetY          = 1,
                Collision        = new CollisionHandlerAggregation(flagGrounded, new BlockCollisionHandler()),
                BeforeCollisions = flagGrounded
            };

            var input = new GameInput();

            Update = new UpdateAggregation(
                new UpdateInput(input)
                , CreateUpdatesByState(input)
                , new CameraFollowsObjectAround(this, Camera)
                );
        }
Esempio n. 2
0
        public MouseCursor(World world, MouseInput mouse)
        {
            var collisionKeeper = new CollisionsKeeper();

            Collider = new Collider(this)
            {
                OffsetX          = 1,
                OffsetY          = 1,
                Width            = 1,
                Height           = 1,
                Collision        = collisionKeeper,
                BeforeCollisions = collisionKeeper
            };

            Update = new UpdateAggregation(
                new AddBlockOnMouseClick(this, mouse, collisionKeeper, world),
                new RemoveBlockOnMouseClick(this, mouse, collisionKeeper, world),
                new MoveMouseCursorToNearbyCell(mouse, this)
                );

            Animation = new SimpleAnimation(
                new AnimationFrame(
                    this,
                    "block",
                    0,
                    0,
                    GameConstants.BlockSize,
                    GameConstants.BlockSize));
        }