I know this is slightly off-topic but why did you choose crafty over the other game engine that are out there?
I am trying to build a small, online card game with NodeJS. Having C# and javascript experience, I am having way more trouble than I expected.Using node-static, I set up an http server (server.js) that successfully serves client.html and any requested assets.I am starting to build the basics of the card game using the CraftyJS library in client.js (running on the client.html page).Using Socket.io, I can successfully send information from server.js to my client.js file.My next step was to generate an array of cards in server.js, splice one out randomly, and send it to client.js. My hope was:var deck = new Array();deck.push(new Array("card1 info", "more info"));deck.push(new Array("card 2 info", "more info"));deck.push(new Array("card 3 info", "more info"));function drawCard(){return deck.splice(1,1);}I've spent the whole day reading, but I can't find a clear concise answer.
Question 1: Why doesn't this work? The V8 compiler sees arrays as string values? This is not the javascript I know, is there a tutorial for this new way of dealing with arrays?
After more reading, I got it working a this way:var deck = [];deck[0] = {info:"test", moreInfo:"test"};deck[1] = {info:"test", moreInfo:"test"};
deck[2] = {info:"test", moreInfo:"test"};However:console.log(deck[0]) yields {info: 'test', moreInfo:'test'}console.log(deck.splice(0,1)) yields [{info: 'test', moreInfo:'test'}]Question 2: Why does splice return the square brackets, but calling the value directly does not?