Click here to Skip to main content
12,450,605 members (49,373 online)
Click here to Skip to main content

Stats

16.4K views
467 downloads
17 bookmarked
Posted

Reversi for Windows Mobile

, 12 May 2009 CPOL
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)

Share

About the Author

Ziad Elmalki
United States United States
No Biography provided

You may also be interested in...

Pro
Pro
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160826.1 | Last Updated 13 May 2009
Article Copyright 2009 by Ziad Elmalki
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid