Exemple #1
0
        private void SpawnParticles()
        {
            var tx = (int)MathHelper.Clamp(texture, 0, map.tiles.Count - 1);
            var T  = map.tiles[tx];

            var sz = (int)(map.tilesize / 2);
            var G  = map.game;
            var HB = GetHitbox();
            //var spd = 1.5f;
            var spd = 1;


            var C = new HTMLCanvasElement();

            C.Width  = sz;
            C.Height = sz;
            var g = Helper.GetContext(C);

            g.DrawImage(T, 0, 0, sz, sz, 0, 0, sz, sz);
            var P = new Particle(G, C.As <HTMLImageElement>());

            P.Hspeed = -spd;
            P.Vspeed = -spd;
            P.x      = HB.left;
            P.y      = HB.top;
            G.AddEntity(P);

            //
            C        = new HTMLCanvasElement();
            C.Width  = sz;
            C.Height = sz;
            g        = Helper.GetContext(C);

            g.DrawImage(T, sz, 0, sz, sz, 0, 0, sz, sz);
            P        = new Particle(G, C.As <HTMLImageElement>());
            P.Hspeed = spd;
            P.Vspeed = -spd;
            P.x      = HB.left + sz;
            P.y      = HB.top;
            G.AddEntity(P);

            //
            C        = new HTMLCanvasElement();
            C.Width  = sz;
            C.Height = sz;
            g        = Helper.GetContext(C);

            g.DrawImage(T, 0, sz, sz, sz, 0, 0, sz, sz);
            P        = new Particle(G, C.As <HTMLImageElement>());
            P.Hspeed = -spd;
            P.Vspeed = spd;
            P.x      = HB.left;
            P.y      = HB.top + sz;
            G.AddEntity(P);

            //
            C        = new HTMLCanvasElement();
            C.Width  = sz;
            C.Height = sz;
            g        = Helper.GetContext(C);

            g.DrawImage(T, sz, sz, sz, sz, 0, 0, sz, sz);
            P        = new Particle(G, C.As <HTMLImageElement>());
            P.Hspeed = spd;
            P.Vspeed = spd;
            P.x      = HB.left + sz;
            P.y      = HB.top + sz;
            G.AddEntity(P);
        }