コード例 #1
0
ファイル: GameForm.cs プロジェクト: BodrovaMaria/Cs-prakt
        // Конструктор формы
        public GameForm()
        {
            // Настройка формы
            this.ClientSize      = new Size(500, 500);
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.MaximizeBox     = false;
            this.DoubleBuffered  = true;

            // Настройка PictureBox (Screen)
            this.screen.Width     = this.ClientSize.Width;
            this.screen.Height    = this.ClientSize.Height;
            this.screen.BackColor = Color.White;
            this.screen.Parent    = this;

            // Настройка виртуального экрана
            this.vScreen = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);

            // Настрйока контекста рисования виртуального экрана
            this.vGCtx = Graphics.FromImage(this.vScreen);

            // Настройка ввода пользователя
            this.input = new Game.GameInput();
            // Подписка на событие клавиатуры
            this.KeyDown += (object sender, KeyEventArgs e) => this.input.DispatchKeyDown(e.KeyValue);
            this.KeyUp   += (object sender, KeyEventArgs e) => this.input.DispatchKeyUp(e.KeyValue);

            // Инициализация объекта состояний игры
            this.state = new Game.GameState(this.vScreen, this.vGCtx, this.input);
            // Настройка игры
            this.game = new Game.Game(this.state);

            // Запуск игровых таймеров
            this.StartTimers();
        }
コード例 #2
0
 // Конструктор объекта состояний игры
 public GameState(Bitmap screen, Graphics gCtx, GameInput input)
 {
     this.screen = screen;
     this.gCtx   = gCtx;
     this.input  = input;
 }