Click here to Skip to main content
15,894,343 members
Articles / Mobile Apps / Windows Mobile

Reversi for Windows Mobile

Rate me:
Please Sign up or sign in to vote.
4.86/5 (4 votes)
12 May 2009CPOL3 min read 27.1K   531   17  
The game Reversi for Windows Mobile using the Compact Framework.
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace GameExample.Reversi
{
    public class GameManager
    {
        /// <summary>
        /// The game host.
        /// </summary>
        private IGameHost _host;
        /// <summary>
        /// The default game options.
        /// </summary>
        private GameOptions _gameOptions = GameOptions.Default;
        /// <summary>
        /// The game render.
        /// </summary>
        private GameRender _gameRender;
        /// <summary>
        /// The current game.
        /// </summary>
        private Game _game;

        public GameManager(IGameHost host)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }
            _host = host;
            // Set the screen to the main menu.
            SetScreen(GameScreen.MainMenu);
        }

        /// <summary>
        /// Sets the screen.
        /// </summary>
        /// <param name="screen">The screen.</param>
        public void SetScreen(GameScreen screen)
        {
            _host.SetScreen(screen, this);
        }

        /// <summary>
        /// Starts a new game.
        /// </summary>
        /// <param name="control">The control.</param>
        public void StartGame(Control renderArea, Control statusArea)
        {
            _game = new Game(_gameOptions);
            _gameRender = new GameRender(this,_gameOptions, _game, renderArea, statusArea);
        }

        /// <summary>
        /// Quits the game.
        /// </summary>
        public void Quit()
        {
            _game = null;

            _gameRender.Dispose();
            _gameRender = null;

            SetScreen(GameScreen.MainMenu);
        }
        public bool Active
        {
            get
            {
                return _game != null;
            }
        }
        public void ResetSize()
        {
            _gameRender.ResetScreen();
        }

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions