Jump to content

Search the Community

Showing results for tags '2d array'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 1 result

  1. Some snippets from code: (stripped out stuff to see where issue is unrelated to issue) Shows how I am declaring, assigning and calling the arrays.. I am thinking the problem is the declaring of the array. I believe all my values in the 2nd dimension of the array is ALL referencing the same value. Declaring is first few lines posted below. var Board = function(){//varsvar board = []; //tried var board = new Array(8,8); for(var i = 0; i < 9; i++){board[i] = [];} //load board information from datathis.loadBoard = function(data){//stripped vars player and playerID //do something with k or data... $.each( data, function( key, val ) {$.each( val, function( kk, vv ) { //if no player yet, set as player 1if(playerID == 0){player = key;playerID = 1;}else if(player != key)//set as player 2{player = key;playerID = 2;} //Log is Correct, shows each x, y pass different value console.log("setting: x: " + vv.x + " y: " + vv.y + " result: " + vv.piece);board[vv.x, vv.y] = new Piece(vv.piece, playerID);});}); } this.renderPieces = function(){//2 for loops to cycle threw 2d array stripped, if( typeof board[x, y] != "undefined") //neglected{console.log("x: " + x + " y: " + y + " result: ");board[x, y].renderPiece( ((x*80)+35), ((y*80)+35) ); //renders same piece}}} var Piece = function(piece_, color_){//varsvar color = color_;var piece = piece_; var pieces = new Image();pieces.src = "resources/pieces.png"; this.renderPiece = function(x, y){ var x_offset = 0;var y_offset = 0; //greenif(this.color = 2){y_offset = 71;} switch(piece){case "a": x_offset = 340;break;case "b": x_offset = 68;break;case "c":x_offset = 136;break;case "d":x_offset = 204;break;case "e":x_offset = 272;break;} context.drawImage(pieces, x_offset, y_offset, 71, 68, x, y, 71, 68); } this.getColor = function(){return color;} this.getPiece = function(){return piece;} Edit: thats a little upsetting. I forgot to close the code tag and my post lost all formatting of code.. And I had to click indent over and over for nice formatting since the formatting didnt keep when copying out of my editor..
×
×
  • Create New...