Search:

Type: Posts; User: Norm

Search: Search took 0.11 seconds.

  1. Replies
    18
    Views
    1,483

    [SOLVED] Re: Tic Tac Toe - Checking for a winner

    if (row == 1) {
    row = 0;
    }
    How about: row = row - 1

    If you can read Javascript, here's one way to do it:
    http://normsstuff.zxq.net/Games/TicTacToe.html#top
  2. Replies
    18
    Views
    1,483

    [SOLVED] Re: Tic Tac Toe - Checking for a winner

    Define a 2 dim array: theField and fill it with ImageView objects.
    It replaces the 9 variables like this: row1_field1_img

    You may have to change the indexes to be 0 based: 0-2 vs 1-3
  3. Replies
    18
    Views
    1,483

    [SOLVED] Re: Tic Tac Toe - Checking for a winner

    int[][] gameboard = new int[3][3]; // define 2 dim gameboard array
  4. Replies
    18
    Views
    1,483

    [SOLVED] Re: Tic Tac Toe - Checking for a winner

    Look at something like this:


    if(gameboard[row][field] == 0) {
    theField[row][field].setImageDrawable(GetPlayer());
    gameboard[row][field] = curPlayer;
    changePlayer();
    }
  5. Replies
    18
    Views
    1,483

    [SOLVED] Re: Tic Tac Toe - Checking for a winner

    I don't think you are using the array like an array. The code is using the array's slots like 9 different variables with the same name and a unique suffix like: [5]

    Try using a 2 dim array that...
  6. Replies
    18
    Views
    1,483

    [SOLVED] Re: Tic Tac Toe - Checking for a winner

    Or use an array of Field objects:

    Field[] theSquares = new Field[9];
    Then assign each slot with a Field object;

    Or define the array with existing the existing Field objects:

    Field[]...
  7. Replies
    18
    Views
    1,483

    [SOLVED] Re: Tic Tac Toe - Checking for a winner

    Here is the tutorial for arrays:
    Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics)

    I suggest you put the current code aside for now and write a simple program with...
  8. Replies
    18
    Views
    1,483

    [SOLVED] Re: Tic Tac Toe - Checking for a winner

    Can you explain where the problem is?
    Defining an array
    assigning values to the slots in an array
    referencing the contents of a slot in an array
  9. Replies
    18
    Views
    1,483

    [SOLVED] Re: Tic Tac Toe - Checking for a winner

    Can you use an array for the board instead of 9 different variables? The array can hold references to the Field objects. That will reduce the number of if tests needed.
Results 1 to 9 of 9