Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualshadowisadog

Posted 23 October 2012 - 10:10 PM

Sure,

The code is creating a new rectangle called position at 0,0 and using the width and the height of the tile from the Tiles array at element 0 (the first element). This is not good code, because that would be better done as a constant, or loaded from a data file of some sort. position is also a terrible variable name.

Then there is a for loop where x goes from 0 to the width (not quite sure if the width is in pixels, or the width in tiles...). The code calculates the x and y positions from the baseWidth/2, and baseHeight/2 multiplied by x. I am not sure where y went...

Then in the nested loop the z axis foes from 0 to depth. This is bad variable naming because once again not sure if depth is in pixels or tiles. The array is two dimensional and being accessed so the element is at x, z.... not sure why this is being done... I would opt for a three dimensional array, or maybe a 2d array and have a block class handle its layers..

Here is a link to maybe a better resource: http://www.xnaresources.com/default.asp?page=Tutorial:TileEngineSeries:4

#2shadowisadog

Posted 23 October 2012 - 10:07 PM

Sure,

The code is creating a new rectangle called position at 0,0 and using the width and the height of the tile from the Tiles array at element 0 (the first element). This is not good code, because that would be better done as a constant, or loaded from a data file of some sort. position is also a terrible variable name.

Then there is a for loop where x goes from 0 to the width (not quite sure if the width is in pixels, or the width in tiles...). The code calculates the x and y positions from the baseWidth/2, and baseHeight/2 multiplied by x. I am not sure where y went... once again not good code.

Then in the nested loop the z axis foes from 0 to depth. This is bad variable naming because once again not sure if depth is in pixels or tiles. The array is two dimensional and being accessed so the element is at x, z.... not sure why this is being done... I would opt for a three dimensional array, or maybe a 2d array and have a block class handle its layers...

I just don't think that the code you posted is very good at all (or I don't understand it, and it is poorly commented).

#1shadowisadog

Posted 23 October 2012 - 10:07 PM

Sure,

The code is creating a new rectangle called position at 0,0 and using the width and the height of the tile from the Tiles array at element 0 (the first element). This is not good code, because that would be better done as a constant, or loaded from a data file of some sort.

Then there is a for loop where x goes from 0 to the width (not quite sure if the width is in pixels, or the width in tiles...). The code calculates the x and y positions from the baseWidth/2, and baseHeight/2 multiplied by x. I am not sure where y went... once again not good code.

Then in the nested loop the z axis foes from 0 to depth. This is bad variable naming because once again not sure if depth is in pixels or tiles. The array is two dimensional and being accessed so the element is at x, z.... not sure why this is being done... I would opt for a three dimensional array, or maybe a 2d array and have a block class handle its layers...

I just don't think that the code you posted is very good at all (or I don't understand it, and it is poorly commented).

PARTNERS