Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainForm"/> class.
        /// </summary>
        public MainForm()
        {
            this.InitializeComponent();
            this.environment = new LevelOne();
            this.environment.Load();
            this.environment.RegisterAllKeys(this);

            this.engine = new Engine();
            this.engine.Load(this, null);
            this.engine.OnNewFrame += (o, e) => this.Tick(e);
            this.FormClosing += (o, e) => this.engine.Dispose();
            this.engine.Start();
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainForm"/> class.
        /// </summary>
        public MainForm()
        {
            this.InitializeComponent();
            this.environment = new LevelOne();
            this.environment.Load();
            this.environment.RegisterAllKeys(this);

            this.engine = new Engine();
            this.engine.Load(this, null);
            this.engine.OnNewFrame += (o, e) => this.Tick(e);
            this.FormClosing       += (o, e) => this.engine.Dispose();
            this.engine.Start();
        }
Beispiel #3
0
        /// <summary>
        /// The tick.
        /// </summary>
        /// <param name="e">
        /// The <see cref="FrameEventArgs"/> for <see cref="MainForm"/>
        /// </param>
        public void Tick(FrameEventArgs e)
        {
            using (var g = Graphics.FromImage(e.Frame))
            {
                this.environment.Update();
                if (this.environment.IsRunning == false)
                {
                    this.environment = new LevelOne();
                    this.environment.Load();
                    this.environment.RegisterAllKeys(this);
                }
                this.environment.Render(g);
                g.Flush();
            }

            canvas.Image = e.Frame;
        }