我的代码的问题 [英] problem of my code

查看:91
本文介绍了我的代码的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,我写了一些代码来下棋游戏中的国王.您能告诉我国王不动的这段代码的问题在哪里吗?谢谢.

 如果(pictureBox34.Image == Chess9.Properties.Resources.siyahsah2))
{
    F();
} 


 公共  void  picarray()
{
    pic [ 0  4 ] = pictureBox34;
} 


 公共  void  f()
{
     int  x =  3 ;
    模式=保持;
     int  y =  3 ;
     for ( int  i =  1 ; i <  x; i ++)
    {
         for ( int  j =  1 ; j <  y; j ++)
        {
            pic [i,j] = pic [i +  1 ,j +  1 ];
            pic [i,j] = pic [i- 1 ,j- 1 ];
        }
    pic [i,j] .Image = Image.FromFile(" );
} 

解决方案

您不应该使用单个PictureBox来执行此操作.所有的木板和骑士都应该在Panel控件的Paint事件中渲染.您之前在此发布的前两个问题中.您所需要做的就是阅读答案,并遵循并阅读提供的有关如何自己呈现此内容的链接.


Hi friends, I wrote some code to move the king in chess game; can you tell me where is the problem of this code that king doesn''t move? Thanks.

if (pictureBox34.Image ==  chess9.Properties.Resources.siyahsah2))
{
    f();
}


public void picarray()
{
    pic[0, 4] = pictureBox34;
}


public void f()
{
    int x = 3;
    mode = hold;
    int y = 3;
    for (int i = 1; i < x; i++)
    {
        for (int j = 1; j < y; j++)
        {
            pic[i, j] = pic[i + 1, j + 1];
            pic[i, j] = pic[i - 1, j - 1];
        }
    pic[i, j].Image = Image.FromFile("pic/siyahsah2.jpg");
}

解决方案

You shouldn''t be using a single PictureBox to do this. All of the board and the knight should be rendered in the Paint event of a Panel control.


I don''t have to explain this any further - it''s already been explained to you before in the first two questions you posted about this. All you have to do is read the answers and follow and read the links that were provided on how to render this yourself.


这篇关于我的代码的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆