POLALA.COM
welcome to my space
X
Search:  
Web Design | Video Games | RVs | Religion | Management | Supplements and Vitamins | Software | Basketball | Related articles
Welcome to:polala.com
NAVIGATION: Home >>
2D Array for a game board
Published by: admin 2010-03-18

  • Hi,

    I'm currently in the early stage of making a small game of the type "if you align 3 identical beads vertically or horizontally they disapear and get replaced by new ones".

    I'm at the pont of filling my 2D Array, to me, my code makes sense and should work, but for some reason the output is really odd.

    The main porblem is that my in my 2D array gameBoard[i][j] for some reason the adresses past 1 in the i column do not get defined even tho I'm pretty sure I'm defining them correctly.

    If you're wondering about the ifs and the continues, when I fill my board, I dont want any identical pieces 3 times in a row so a valid combination is not already on the board when the user first starts the game.

    Anyways look at the trace of this code, its really odd.


    var boardSize:Number = 8;
    Inside F#: "Game of Life" Challenge::
    game board is just 2D array of bools let mutable cells = Array2.create MAXX MAXY false let NumNeighbors(x,y) = let At(x,y) =
    http://lorgonblog.spaces.live.com/blog/cns!701679AD17B6D310!261.entry
    HOME
    var gameBoard:Array = new Array(new Array(boardSize), new Array(boardSize));
    //
    //
    //Fills the board using the number of different types of beads
    fillBoard = function (types:Number) {
    for (var i = 0; i for (var j = 0; j //Make sure the initial filling wont put combinations on the initial layout
    while (true) {
    var randomType = Math.floor(Math.random()*types)+1;
    if (i>=2 && (gameBoard[i-2][j] == gameBoard[i-1][j] == randomType)) {
    continue;
    }
    if (i>=1 && i<=(boardSize-2) && (gameBoard[i-1][j] == randomType == gameBoard[i+1][j])) {
    continue;
    }
    if (i<=boardSize-3 && (randomType == gameBoard[i+1][j] == gameBoard[i+2][j])) {
    continue;
    }
    if (j>=2 && (gameBoard[i][j-2] == gameBoard[i][j-1] == randomType)) {
    Conway's Game of Life - Wikipedia, the free encyclopedia::
    Sep 16, 2008 They represented Life patterns as two-dimensional arrays in computer A sample of a 48-step oscillator from a 2D hexagonal Game of Life (rule 34/2).
    http://en.wikipedia.org/wiki/Conways_Game_of_Life
    HOME
    continue;
    }
    if (j>=1 && j<=(boardSize-2) && (gameBoard[i][j-1] == randomType == gameBoard[i][j+1])) {
    continue;
    }
    if (j<=boardSize-3 && (randomType == gameBoard[i][j+1] == gameBoard[i][j+2])) {
    continue;
    } else {
    gameBoard[i][j] = randomType;
    Microsoft PowerPoint - games_ccsc06.ppt::
    File Format: PDF/Adobe Acrobat - View as HTMLGame Characteristics. :. •. Abstract. •. Board. •. No Hidden Information. •. Deterministic. •. 1 or 2 Players. •. 1D or 2D or 3D Arrays
    http://www.ccsc.org/northwest/2006/ppt/orr_games_ccsc06.pdf
    HOME
    2d array and random numbers - C++ Forums::
    6 posts - 3 authors - Last post: Nov 17 function to start a new game. i have to generate 10 bombs (represented by -1 ) randomly into my 2d array, how do i check for duplicates,
    http://www.cplusplus.com/forum/beginner/5369/
    HOME
    trace("i-> "+i+" , j-> "+j+" ==== "+gameBoard[i][j]+" and the random number that was assigned is: "+randomType);
    break;
    }
    }
    //End of while
    }
    }
    trace(gameBoard[0][0]+" "+gameBoard[0][1]+" "+gameBoard[0][2]+" "+gameBoard[0][3]+" "+gameBoard[0][4]+" "+gameBoard[0][5]+" "+gameBoard[0][6]+" "+gameBoard[0][7]);
    trace(gameBoard[1][0]+" "+gameBoard[1][1]+" "+gameBoard[1][2]+" "+gameBoard[1][3]+" "+gameBoard[1][4]+" "+gameBoard[1][5]+" "+gameBoard[1][6]+" "+gameBoard[1][7]);
    trace(gameBoard[2][0]+" "+gameBoard[2][1]+" "+gameBoard[2][2]+" "+gameBoard[2][3]+" "+gameBoard[2][4]+" "+gameBoard[2][5]+" "+gameBoard[2][6]+" "+gameBoard[2][7]);
    trace(gameBoard[3][0]+" "+gameBoard[3][1]+" "+gameBoard[3][2]+" "+gameBoard[3][3]+" "+gameBoard[3][4]+" "+gameBoard[3][5]+" "+gameBoard[3][6]+" "+gameBoard[3][7]);
    trace(gameBoard[4][0]+" "+gameBoard[4][1]+" "+gameBoard[4][2]+" "+gameBoard[4][3]+" "+gameBoard[4][4]+" "+gameBoard[4][5]+" "+gameBoard[4][6]+" "+gameBoard[4][7]);
    trace(gameBoard[5][0]+" "+gameBoard[5][1]+" "+gameBoard[5][2]+" "+gameBoard[5][3]+" "+gameBoard[5][4]+" "+gameBoard[5][5]+" "+gameBoard[5][6]+" "+gameBoard[5][7]);
    trace(gameBoard[6][0]+" "+gameBoard[6][1]+" "+gameBoard[6][2]+" "+gameBoard[6][3]+" "+gameBoard[6][4]+" "+gameBoard[6][5]+" "+gameBoard[6][6]+" "+gameBoard[6][7]);
    trace(gameBoard[7][0]+" "+gameBoard[7][1]+" "+gameBoard[7][2]+" "+gameBoard[7][3]+" "+gameBoard[7][4]+" "+gameBoard[7][5]+" "+gameBoard[7][6]+" "+gameBoard[7][7]);
    };
    //executes the board filling
    fillBoard(6);

    the big trace at the end is onl so I can have a clear representation of the board in my output to verify if my code is working properly Ie :

    2 3 4 6 3 6
    1 2 1 5 5 4
    4 4 3 2 1 3
    1 2 1 2 5 4
    5 4 3 5 1 3

    (just thought I could do this huge trace with a forloop, but I dont feel like rewrting it right now)

    If you see anything please share some advice

    Thanks !


  • Got it,
    A way that works to declare 2d arrays that work :


    var gameBoard=new Array(boardSize);
    for(var i=0;i gameBoard[i] = new Array(boardSize);
    }


  • And what do you mean by the end of the map Bomb ?


  • set up some more traces, especially while defining the variables you could trace the i,k variables like this

    trace("i->"+i+" "+"k->"+k)

    and make sure your defining the end of the map


  • I am going to look this over, I should probably have an answer tommorow.....


  • you send the main tiles at the end of the map werent loading right? so i just ment that you should add some more traces and make sure that you are adding the tiles to the end of the map


  • thanks shifty, I'm still looking into it myself, but it seems like I'm doing everything by the book according to the macromedia help files...

    If you find anything please tell





  • Where's The Advantage In Windows Genuine Advantage?
    Stocks Bounce After S&P Joins Bear Market

    PRINT Add to favorites
  • costs to operate boiler versus forced air heat
  • horchow dinnerware find it cheaper
  • houses in san diego ca
  • how to build a suspension bridge for a residential treehouse
  • washing machines dryers
  • star trek armada 2 pc game
  • consumer reviews of residential vinyl fencing and fence contractors w dc area
  • voting machine rigging
  • oriental lamp in angel eyes
  • tba
  • general billing statements received in the mail
  • computer locking up
  • dial up isp with accelerated data transfer allvantage
  • kitchen appliance sales
  •  
  • removing moths from kitchen
  • w98 xp printing problem
  • stomach tummy gurgling causes
  • using metallic alumimum paint in pantry
  • bomb spotter mail box
  • doves on the roof
  • inf problems
  • getting weird error
  • wamsutta elite sa comforter
  • keyboard remapping adding international symbols
  • routine computer maintenance
  • epidemiological heart studies
  • need help deciding a computer career or maybe i should just forget all about it
  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about 2D Array for a game board , Please add it free.

    About us -Site map -Advertisement -Jion us -Contact usExchange linksSponsor us
    Copyright© 2008 polala.com All Rights Reserved
    Site made&Support support@polala.com    E-mail: web@polala.com