divide scene

30 views
Skip to first unread message

Pongpipat Supalak

unread,
Apr 16, 2015, 10:28:47 AM4/16/15
to pl...@googlegroups.com
How I divide a scene to 8x8 for my chess game.
Give me for example pls.

Brigt Vik

unread,
Apr 16, 2015, 4:18:59 PM4/16/15
to pl...@googlegroups.com
Written directly into forum before bedtime, without spellcheck, looking up method names, compilation or anything of the sort. Caveat emptor.

class BoardCell
{
  private SurfaceImage mySurface;
 
private ImageLayer myLayer;

 
public BoardCell(float left, float top, float width, float height, GroupLayer parent)
 
{
   
this.left = left;
   
this.top = top;
   
this.width = width;
    this.height = height;
    mySurface = graphics().createSurfaceImage(width, height);
    myLayer = graphics().createImageLayer(mySurface);
    parent.add(myLayer);
    myLayer.setTranslation(left, top);
 
}

  public void setImage(Image image)
  {
    mySurface.surface().clear();
    mySurface.surface().drawImage(image, 0, 0, mySurface.surface().width,
mySurface.surface().height);
  }
}

class ChessBoard
{
  private BoardCell[][] cells;
  private GroupLayer boardLayer;

  public ChessBoard()
  {
    float cellSize = graphics().height() / 8f; //Assuming landscape orientation and square cells
    boardLayer = graphics().createGroupLayer();
    cells = new BoardCell[8][8];
    for(int y = 0; y < cells.length; y++)
    {
      for(int x = 0; x < cells[0].length; x++)
      {
        cells[y][x] = new BoardCell(x * cellSize, y * cellSize, cellSize, cellSize, boardLayer);
      }
    }
  }
}

Pongpipat Supalak

unread,
Apr 19, 2015, 3:21:29 AM4/19/15
to pl...@googlegroups.com

I have error on mySurface = graphics().createSurfaceImage(width, height);
เมื่อ วันศุกร์ที่ 17 เมษายน ค.ศ. 2015 3 นาฬิกา 18 นาที 59 วินาที UTC+7, Brigt Vik เขียนว่า:

Brigt Vik

unread,
Apr 19, 2015, 6:51:27 AM4/19/15
to pl...@googlegroups.com
You are terribly unspecific.

Pongpipat Supalak

unread,
Apr 19, 2015, 12:53:24 PM4/19/15
to pl...@googlegroups.com
Now I fix it to complete.
Thank you to code.
^_^

เมื่อ วันอาทิตย์ที่ 19 เมษายน ค.ศ. 2015 17 นาฬิกา 51 นาที 27 วินาที UTC+7, Brigt Vik เขียนว่า:
You are terribly unspecific.
Reply all
Reply to author
Forward
0 new messages