HTML5 Canvas algorithm to generate random symmetrical at vertical axis

Go To StackoverFlow.com

0

I am working on a game where a shape is generated in a 8 x 8 matrix on a canvas . The user needs to identify if a generated shape is symmetrical at the vertical axis or not, so for generating a symmetric shape I am thinking of creating a 4 x 8 array populate the array randomly with 1 and 0 ( for the shapes) once this is done then I iterate over the 4 x 8 array and create another array of 8 x 8 which mirrors the 4 x 8 matrix.

Is there a better way to do this ?

2012-04-04 17:12
by user94437


1

Without seeing code and without knowing what criteria to use, "better" will be very hard to determine.

That said, your approach sounds reasonable. Give it a try, and be careful not to prematurely optimize. :)

2012-04-04 17:16
by John Fisher
Yeah, 64 is a small value in almost all situations : - Thomas 2012-04-04 17:20
Ads