Ejemplo n.º 1
0
        static void Main()
        {
            EditorForm f = new EditorForm();

            f.Show();

            double t  = 0;
            double dt = 0.01666667; // 60 phisics updates in second

            double currentTime = Time.GetCurrentTime();
            double accumulator = 0;

            double newTime;
            double frameTime;

            double prevTime;

            bool isRun = true;

            f.FormClosed += delegate { isRun = false; };

            while (isRun)
            {
                prevTime = currentTime;

                newTime = Time.GetCurrentTime();

                frameTime = newTime - currentTime;

                if (frameTime > 0.25)
                {
                    frameTime = 0.25;
                }

                Time.UpdateDelta(frameTime);

                currentTime = newTime;

                accumulator += frameTime;

                while (accumulator >= dt)
                {
                    accumulator -= dt;
                    t           += dt;
                }

                f.CGUpdate();
                f.Refresh();

                Application.DoEvents();
            }
        }
Ejemplo n.º 2
0
        public static void FillLoyOutPanel(FlowLayoutPanel _panel, EditorForm _editorForm)
        {
            _panel.AutoScroll = true;

            editorForm = _editorForm;

            for (int i = 0; i < GameObjects.Count; i++)
            {
                Button b = new Button();
                b.Name                  = GameObjects[i].m_Name;
                b.BackgroundImage       = GameObjects[i].m_Sprite.m_Image;
                b.Size                  = new System.Drawing.Size(32, 32);
                b.BackgroundImageLayout = ImageLayout.Center;

                b.Click += editorForm.B_Click;

                _panel.Controls.Add(b);
            }
        }
Ejemplo n.º 3
0
        public Game(Scene _scene, EditorForm _parrent)
        {
            scene = new Scene(_scene.GetName());

            gameForm = new GameForm();

            gameForm.SetScene(scene);

            parrent = _parrent;

            gameForm.FormClosing += Form1_FormClosing;

            for (int i = 0; i < scene.GameObjects.Count; i++)
            {
                if (scene.GameObjects[i].gameObjectType == GameObjectType.PLAYER)
                {
                    cameraPivot = scene.GameObjects[i];
                }
            }

            Enemy  e;
            Player p = (Player)cameraPivot;

            for (int i = 0; i < scene.GameObjects.Count; i++)
            {
                if (scene.GameObjects[i].gameObjectType == GameObjectType.ENEMY)
                {
                    e = (Enemy)scene.GameObjects[i];

                    e.SetPlayer(p);
                }
            }

            gameCamera = new Camera(cameraPivot, gameForm);

            gameForm.SetCamera(gameCamera);

            isPlaying = false;

            collisionMeneger = new CollisionMeneger(scene);
        }
Ejemplo n.º 4
0
 public void SetForm(EditorForm _form)
 {
     parrent = _form;
 }