Click here to Skip to main content
15,882,055 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 27K   531   17  
The game Reversi for Windows Mobile using the Compact Framework.
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace GameExample.Reversi
{
    public struct Position
    {
        /// <summary>
        /// A position on the game board.  The first two bits represent the player, the last 6 bits
        /// are used by render to track the current frame.
        /// </summary>
        private readonly byte _data;

        /// <summary>
        /// Initializes a new instance of the <see cref="Position"/> struct.
        /// </summary>
        /// <param name="data">The data.</param>
        public Position(byte data)
        {
            _data = data;
        }
        public Position(Player player)
            : this((byte)player)
        {
        }
        public Position(Player player, byte renderData)
            : this((byte)((byte)player | ((byte)renderData << 2)))
        {
        }



        /// <summary>
        /// An empty position.
        /// </summary>
        /// <value>The empty.</value>
        public static Position Empty
        {
            get
            {
                return new Position();
            }
        }

        /// <summary>
        /// Gets the player.
        /// </summary>
        /// <value>The player.</value>
        public Player Player
        {
            get
            {
                return (Player)(_data & 0x3);
            }
        }

        /// <summary>
        /// Gets data used by render.
        /// </summary>
        /// <value>The render data.</value>
        public byte RenderData
        {
            get
            {
                return (byte)(_data >> 2);
            }
        }
    }

   
}

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