Game Maker's Garage Forum

Game Creation => HTML5/Javascript => Topic started by: Gan on January 26, 2012, 10:54:47 PM

Title: Making a fancy 2D array in HTML5 GM!
Post by: Gan on January 26, 2012, 10:54:47 PM
Code: [Select]
//Create the 2D array
var myArray = [
[1,0,0,0,0,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0,0,0,0],
[1,0,0,0,0,1,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0,0,0,0]]

//Draws the number 1
DrawString(myArray[5][5],50,50)
Title: Re: Making a fancy 2D array in HTML5 GM!
Post by: Connors on January 26, 2012, 11:01:30 PM
Heeeey it works on multiple lines thanks!
Title: Re: Making a fancy 2D array in HTML5 GM!
Post by: Gan on January 26, 2012, 11:27:40 PM
Updated! Now the X and Y don't need flipped.

Edit: I lied. X and Y are still backwards. You just gotta do an array flip to fix it.