RE: [Flashcoders] FW: Domino Game
Thanks Danny, I'll have to do some work and see how I get on. Cheers again. t -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Danny Kodicek Sent: 30 December 2005 11:40 To: Flashcoders mailing list Subject: Re: [Flashcoders] FW: Domino Game > I'm specifically after how to approach 'dealing' the dominos (taking > the 28 original dominos and randomly assigning them to either of two > players) That's easy enough. Take a list of dominos (probably a list of two-element arrays like [0,0]) and randomise it. Here's a simple randomise function (NB: it destroys the original list): function randomise(tArray:Array) { var tRet:Array = new Array() while (tArray.length>0) { var r:Number=Math.floor(Math.random()*tArray.length) tRet.push(tArray[r]) tArray.splice(0,1) } return tRet } (Warning: email code may be flawed...) and how to approach the 'logic' of game moves (how to decide > whether someone can move a particular domino onto the board or not. I would keep hold of a variable for each of the two ends of the chain (assuming you're not allowing side-branching). When they want to add a domino, just check if either of its elements matches either of these numbers; if so, it can be added. You'll find the most tricky bit of logic will be fitting the dominoes into the space. To keep it simple, I'd arrange them in a loop around the outside of the game area. Make sure the 28 dominoes will fit in the space, then just build in either direction from the starting point. Guaranteed success :) HTH Danny ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] FW: Domino Game
I'm specifically after how to approach 'dealing' the dominos (taking the 28 original dominos and randomly assigning them to either of two players) That's easy enough. Take a list of dominos (probably a list of two-element arrays like [0,0]) and randomise it. Here's a simple randomise function (NB: it destroys the original list): function randomise(tArray:Array) { var tRet:Array = new Array() while (tArray.length>0) { var r:Number=Math.floor(Math.random()*tArray.length) tRet.push(tArray[r]) tArray.splice(0,1) } return tRet } (Warning: email code may be flawed...) and how to approach the 'logic' of game moves (how to decide whether someone can move a particular domino onto the board or not. I would keep hold of a variable for each of the two ends of the chain (assuming you're not allowing side-branching). When they want to add a domino, just check if either of its elements matches either of these numbers; if so, it can be added. You'll find the most tricky bit of logic will be fitting the dominoes into the space. To keep it simple, I'd arrange them in a loop around the outside of the game area. Make sure the 28 dominoes will fit in the space, then just build in either direction from the starting point. Guaranteed success :) HTH Danny ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] FW: Domino Game
Hi List I'm trying to create a dominos game and I'm having trouble - anyone seen anything similar in flash or any pointers for how to approach this (no, I'm not being paid for this - it's a personal project so you're not doing any work for me!) or just advice or hints on how to get started - I'm specifically after how to approach 'dealing' the dominos (taking the 28 original dominos and randomly assigning them to either of two players) and how to approach the 'logic' of game moves (how to decide whether someone can move a particular domino onto the board or not. Thanks in advance for any pearls of wisdom, no matter how small, oh, and happy new year to everyone. Trevor ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders