示例#1
0
        static void Main(string[] args)
        {
            var game = new ShellGame(600, 600);

            Game.LogShouldPrintTime  = true;
            Game.LogShouldPrintLevel = false;

            Particle.Emitter mouseEmitter = null;
            //Particle.Emitter regionEmitter = null;

            game.StartHandler += () =>
            {
                mouseEmitter = new Particle.Emitter(0, 0, new TestRectangleParticleSystem(), new RectangleRegion(new Rectangle(-10, -10, 20, 20)));
                mouseEmitter.AddToGroup();

                //regionEmitter = new Particle.Emitter(0, -300, new TestCircleParticleSystem(), new RectangleRegion(new Rectangle(-300, -320, 600, 10)));
                //regionEmitter.AddToGroup();
            };

            game.UpdateHandler += () =>
            {
                //mouseEmitter.X = Input.Mouse.X;
                //mouseEmitter.Y = Input.Mouse.Y;
                //if(Input.LeftMouseDown)
                mouseEmitter.Emit(50);

                //regionEmitter.Emit(15);
            };

            game.RenderHandler += () =>
            {
            };

            game.Run();
        }
示例#2
0
        public static void Run()
        {
            var game = new ShellGame(1280, 960);

            quadtree = new QuadTree <Swarmer>(-Game.Width / 2, -Game.Height / 2, Game.Width, Game.Height, 2, 20);


            game.StartHandler += () =>
            {
                100.Repetitions(() => new Swarmer(Game.RandomX(), Game.RandomY(), Color4.Blue).AddToGroup());
            };

            game.UpdateHandler += () =>
            {
                quadtree.Reset();
                var objs = Game.Group.GetActorsOfType <Swarmer>();
                foreach (var obj in objs)
                {
                    quadtree.Insert(obj);
                }
            };

            game.RenderHandler += () =>
            {
                foreach (var r in quadtree.GetRectangles())
                {
                    Engine.Debug.Draw.Rectangle(r, 0, 0, Color4.Green, false);
                }

                (float X, float Y)start  = (-50, -50);
                (float X, float Y)target = (Input.Mouse.X, Input.Mouse.Y);
                var elbow = Basics.Utils.SingleJoint(start.X, start.Y, target.X, target.Y, 250, 200, false);
                if (elbow.HasValue)
                {
                    Engine.Debug.Draw.Line(start.X, start.Y, elbow.Value.X, elbow.Value.Y, Color4.Red);
                    Engine.Debug.Draw.Line(target.X, target.Y, elbow.Value.X, elbow.Value.Y, Color4.Orange);
                }
                Engine.Debug.Draw.Line(start.X, start.Y, target.X, target.Y, Color4.Green);
                Engine.Debug.Draw.Rectangle(new Rectangle(-8, -8, 16, 16), start.X, start.Y, Color4.Blue);
                Engine.Debug.Draw.Rectangle(new Rectangle(-8, -8, 16, 16), target.X, target.Y, Color4.Yellow);
            };

            game.Run();
        }