Reply to thread

During the last days I have been working on a small plugin that allows you to play the game 'connect four' (try to place four disks of your color on a horizontal, diagonal or vertical row). I have a first version ready (that allows to play human versus human and human versus pc opponent)


A small screenshot



I have however some problems.


-the board and the buttons to select the columns are created during initialization. The board consists of a twodimensional array of GUIImages. On my development machine  it shows correctly, but on my other pc (with release 0.1.3.0) the board is not shown. The buttons on top are created identically and are shown on both machines


The code to create the board and buttons is :



[code]

for (int i=0;i<game.Width;i++)    {

    for(int j=0;j<game.Height;j++)

                    {

                        xpos=xoffset+i*xdistance;//set correct positions

    ypos=yoffset+j*ydistance;

                        GUIImage imagetest= new GUIImage(GetID,40, xpos,ypos, 64, 64,boardbg, 0);

                        imagetest.AllocResources();

    imageboard[i,j]=imagetest;

    GUIControl aaa=(GUIControl)imagetest    ;   

    Add(ref aaa);

        }

}



and



for (int i=0;i<game.Width;i++)

    {

GUIButtonControl test=new GUIButtonControl(GetID,200+i,xoffset+i*xdistance,yoffset,60,40,"menu_list_focus.png","menu_list_nofocus.png");       

test.AllocResources();

GUIControl bbb=(GUIControl)test;

Add(ref bbb);

    }


               

[/code]



The above code is called from the following

[code]


public override bool OnMessage(GUIMessage message)    {

switch ( message.Message )

{

case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT           

base.OnMessage(message);

               

    CreateBoard();

CreateColumnButtons();

 break;

[/code]


Is this the correct way to create the board and visualize it? Why is it not shown on my second pc? Remember that I am  quite new to mediaportal,c# and OO-programming, so please provide detailed descriptions.


Kind Regards


Top Bottom