仅使用Windows窗体应用程序的C#游戏

仅使用Windows窗体应用程序的C#游戏,c#,winforms,C#,Winforms,我想开发一款棋盘游戏。我可以仅使用Windows窗体应用程序创建它吗?我不想使用XNA。如果可以使用windows窗体应用程序创建,如何将其转换为可执行文件。我不想将其作为控制台应用程序运行。我想把它创造成一个游戏 /* It is a board game. 15 14 13 12 11 10 9 16 28 29 30 31 32 8 17 27 42 43

我想开发一款棋盘游戏。我可以仅使用Windows窗体应用程序创建它吗?我不想使用XNA。如果可以使用windows窗体应用程序创建,如何将其转换为可执行文件。我不想将其作为控制台应用程序运行。我想把它创造成一个游戏

/*
It is a board game.
        15   14    13    12     11    10    9
        16   28    29    30     31    32    8
        17   27    42    43     44    33    7
        18   26    41    48     45    34    6  
        19   25    40    47     46    35    5
        20   24    39    38     37    36    4
        21   22    23     0      1     2    3

 It is my board structure . Player one starts at square 0 . If he puts one , he will   
 get into the game . Then he can move his coin up to 23.He can get into 24 , if he 
 already cut the other player coins . Cut in the sense , player 0 places his coin on a 
 square that contains another player coins.Then he can move his coin from 24 to 48 .    
 when the coin reaches 48 , it will be completed . If player 0 completes his 6 coins 
 first , he will be the winner .   
*/
namespace ConsoleApplication1
{
class Program
{
    public static int playerCount;
    public static int totalSquares = 49;
    public static int totalCoins = 6;
    public static bool errorFlag = false;
    public static bool flagrepeat = false;
    public static bool winner=false;

    static void Main()
    {
        if (ErrorTypes.errors==null)
        {
            ErrorTypes.addMessage();
        }
        getPlayers(); // To get the number of players

        startGame();// It will get the name of the player and 
        // will thorw exception if anything goes wrong and will
        // call the main function again.

    }  
/*
* If a coin reaches center square , then it completes
* A player wins if he completes all the six coins
*/
    public static void setWinner(player[] obj) 
    {
        for (int k = 0; k < Program.playerCount; k++)
        {
            if (obj[k].completedcoins == 6)
            {
                Console.WriteLine("Winner is player " + (k + 1));
                winner = true;
                break;
            }
        }
    }
    public static void play(player[] obj)
    {
        bool rollrepeat; // If a player puts one or five or six , he will get another          chance.
        board boards = new board(); // It contains 49 squares
        List<int> rollstore = new List<int>(10); // To store the rolls of a single  player. 
    // Eg is [6,5,6,2] . Coz no repeat for 2. so his turn ends . Now he has to move the   coin by selecting coin and //rollindex.
        List<int> temprollstore = new List<int>(10);
        int roll;
        bool final = false;
        int i = 0;
        Random rn = new Random(); // To generate roll
        bool flag = false, tempflag = false;

        int[] pos;
        while (true)
        {
            if (!gameover())
            {
                setWinner(obj);
                if (final == false)
                {
                    i = 0;
                    while (i < Program.playerCount)
                    {
    /*
    * to reset the flags so that another player can use it
    */
                        if (flag == true || flagrepeat == true)
                        {
                            flagrepeat = false;
                            flag = false;
                        }
    /*
    * 
    */
                        while (true)
                        {                  
            // This part of the does the job of storing the rolls and call the move   function
    // when the roll ends
          }        
                    }
                    print(obj);
                    Console.WriteLine("\n\nPress a Key To Go Next Round ");
                    Console.ReadKey();
                }
                else
                {
                    break;
                }
            }
        }
    }
/*
这是一种棋盘游戏。
15   14    13    12     11    10    9
16   28    29    30     31    32    8
17   27    42    43     44    33    7
18   26    41    48     45    34    6  
19   25    40    47     46    35    5
20   24    39    38     37    36    4
21   22    23     0      1     2    3
这是我的董事会结构。玩家一从0开始。如果他放一个,他会的
进入游戏。然后他可以把硬币移动到23,如果他愿意,他可以进入24
已经切下了其他玩家的硬币。从某种意义上说,玩家0将他的硬币放在
包含其他玩家硬币的正方形。然后他可以将他的硬币从24移动到48。
当硬币达到48,它将完成。如果玩家0完成了他的6枚硬币
首先,他将是赢家。
*/
命名空间控制台应用程序1
{
班级计划
{
公共静态整数播放计数;
公共静态整数totalSquares=49;
公共静态整数总计=6;
公共静态bool errorFlag=false;
公共静态布尔flagrepeat=false;
公共静态bool winner=false;
静态void Main()
{
if(ErrorTypes.errors==null)
{
ErrorTypes.addMessage();
}
getPlayers();//获取玩家数量
startName();//它将获得玩家的名称和
//如果出现任何问题,thorw会例外吗
//再次调用main函数。
}  
/*
*如果一枚硬币到达中心广场,那么它就完成了
*如果玩家完成所有六枚硬币,他将获胜
*/
公共静态无效设置赢家(玩家[]对象)
{
for(int k=0;k

请给我建议一种创建图板并将硬币放在正方形上的方法。

可以。只需选择File New Project Visual C或Visual Basic Forms应用程序

然后,当您完成编码后,只需编译为release(选择VisualStudio顶部栏上的release,将其调试为默认值并编译),您的.exe文件将位于(项目文件夹)/bin/release中


使用此文件,您不需要visual studio立即运行。

您可以通过选择

文件新项目Visual C#或Visual Basic-Windows窗体应用程序

在那里,您可以根据自己的喜好开发游戏

默认情况下,visual studio在
[项目路径]\Bin\Debug
[项目路径]\Bin\Release
中创建项目的输出文件,具体取决于您在中遵循的生成配置。这可以从项目的属性更改

在这些文件夹中,有
.exe
文件以及它需要正确执行的其他文件、资源或dll

在那里,您可以双击运行
.exe
,无需visual studio

您可以从中了解有关visual studio输出文件的更多信息


希望这对您有所帮助

您可以创建一个
Windows窗体应用程序
。它的内容由您决定。这将创建一个
exe
文件,您可以使用该文件启动您application@Omribitan我不想通过Microsoft Visual Studio(F5)执行它。而不是我想双击一个文件,它应该作为游戏运行。如果我的问题很傻,很抱歉。我无法理解。默认情况下,当您从visual studio编译windows窗体应用程序时,它会在[Solution folder]中创建
.exe
文件\bin\debug或release,具体取决于您的构建配置。您可以访问此文件夹并双击运行
.exe
。谢谢Emre Acar和Omribitan。我还有一个疑问。我的游戏包含49个方块[7乘7矩阵]。它是