Example #1
0
        public override void Load()
        {
            bump_sfx = Content.Get <Effect>("menu");

            size = Game.ScreenSize;

            background = new TiledSprite(Content.Get <Texture2D>("bg3"), size.W, size.H);
            background.SetScrollSpeed(0.02f, 0.02f);

            sprite = new Sprite(Content.Get <Texture2D>("particles"), 96, 64, 32, 32);

            tweenedSprite = new Sprite(Content.Get <Texture2D>("zazaka"));

            tweenedValue = new RangedValue(50, 300);

            tweener = new Tweener();

            tweener
            .Tween(0, tweenedValue, 50)
            .Easing(EasingFunctions.QuadraticInOut)
            .RepeatForever()
            .AutoReverse();


            sprite.SetColor(Color.Red);
            sprite.SetOrigin(0.5f, 0.5f);

            timer = new Timer();

            animated_sprite = new MultiframeSprite(
                TextureAtlas.FromGrid(
                    Content.Get <Texture2D>("spritesheet"), 4, 4
                    )
                );

            timer.Every(16, () => animated_sprite.SetColor(RandomEx.NextColor()));

            animated_sprite.SetFrameSpeed(5);

            animated_sprite
            .AddAnimation(
                "idle_up",
                0
                )
            .AddAnimation(
                "idle_horiz",

                4
                )
            .AddAnimation(
                "idle_down",
                8
                )
            .AddAnimation(
                "walk_up",
                0, 1, 2, 3
                )
            .AddAnimation(
                "walk_horiz",
                4, 5, 6, 7
                )
            .AddAnimation(
                "walk_down",
                8, 9, 10, 11
                )
            .SetAnimation("idle_horiz");


            _trail = new ParticleEmitter(
                new Sprite(Content.Get <Texture2D>("particles"), 0, 0, 32, 32),
                new ParticleEmitterProps
            {
                MaxParticles                = 500,
                Emission                    = 500,
                ImmediateFullEmission       = false,
                LifeTime                    = -1,
                Relative                    = true,
                ParticleLife                = new Range <float>(0.5f, 1.0f),
                InitialPositionDisplacement = new Range <Vector2>(new Vector2(-10, -10), new Vector2(10, 10)),
                Direction                   = 0,
                StartColor                  = Color.Cyan,
                EndColor                    = Color.Fuchsia,
                StartOpacity                = 1.0f,
                EndOpacity                  = 0.0f,
                StartScale                  = new Range <float>(1.0f, 2.0f),
                EndScale                    = 0.5f,
                Speed           = new Range <float>(20.0f, 100.0f),
                Spread          = 0.1f,
                Gravity         = 100.0f,
                SpinSpeed       = 10.0f,
                RadialAccel     = 20.0f,
                TangentialAccel = 30.0f
            });

            _explosion = new ParticleEmitter(
                new Sprite(Content.Get <Texture2D>("particles"), 0, 64, 32, 32),
                new ParticleEmitterProps
            {
                MaxParticles                = 1000,
                Emission                    = 200,
                ImmediateFullEmission       = true,
                LifeTime                    = 0.2f,
                Relative                    = false,
                ParticleLife                = new Range <float>(0.2f, 0.5f),
                InitialPositionDisplacement = new Range <Vector2>(new Vector2(-10, -10), new Vector2(10, 10)),
                Direction                   = 0,
                Spread          = Calc.TWO_PI,
                StartColor      = Color.Red,
                EndColor        = Color.Gray,
                StartOpacity    = 1.0f,
                EndOpacity      = 0.0f,
                StartScale      = 1.0f,
                EndScale        = 0.5f,
                Speed           = new Range <float>(100.0f, 150.0f),
                Gravity         = 500.0f,
                SpinSpeed       = 50.0f,
                RadialAccel     = 50.0f,
                TangentialAccel = 50.0f
            }
                );

            _trail.FireAt(particle_x, particle_y);
        }