ID:263773
 
Code:
datum
Game
var
maxx=50
maxy=50
map[50][50]
New()
..()
spawn()
StartUp()
proc
StartUp()
world.maxx = src.maxx*2
world.maxy = world.maxx
for(var/x=1,x<=maxx,x++)
for(var/y=1,y<=maxy,y++)
var/gfx[0]
gfx += new/atom/movable/graphic(x,y,'Hex.dmi',"0,0")
gfx += new/atom/movable/graphic(x,y,'Hex.dmi',"1,0",32)
gfx += new/atom/movable/graphic(x,y,'Hex.dmi',"0,1",0,32)
gfx += new/atom/movable/graphic(x,y,'Hex.dmi',"1,1",32,32)
new/datum/atom/turf (x,y,gfx)

atom/movable
graphic
New(hex_x,hex_y,icon,icon_state,px,py)
src.icon = icon
src.icon_state = icon_state
spawn() LocateHex(hex_x,hex_y,px,py)
..()
proc
LocateHex(hex_x,hex_y,px,py)
var/stufflist = Hex_Coord(hex_x,hex_y,px,py)
z = 1
x = stufflist[1]
y = stufflist[2]
pixel_x += stufflist[3]
pixel_y += stufflist[4]


Problem description:
StartUp() should draw a 50x50 hex grid. maxx and maxy for this datum are both set to 50.
It doesn't draw a 50x50 hex grid, however.
Instead, it draws a single vertical column of hexes.
Swapping the two loops (changing X to Y and vice versa) causes it to draw one horizontal row.

Hex_Coord() converts Hex-Grid Coordinates to Cartesian Square-Grid coordinates. I use it so that I can place each individual 32x32 square of each of the hexes onto the map.

With a bit more debugging, I discovered that it's drawing the 49 other columns at 0,0,0. I'm pretty sure that the problem is in the two for()'s in StartUp(), because if I change the initial value of X, it will move the one column that it draws accordingly.

I can't figure out what's causing it to draw only one of the columns at the correct coordinates. Help please?

[EDIT]: I've also discovered that it's only drawing 25 hexes in the one column. If I change the code to this
                for(var/y=1,y<=maxy,y++)
var/gfx[0]
gfx += new/atom/movable/graphic(1,y,'Hex.dmi',"0,0")
gfx += new/atom/movable/graphic(1,y,'Hex.dmi',"1,0",32)
gfx += new/atom/movable/graphic(1,y,'Hex.dmi',"0,1",0,32)
gfx += new/atom/movable/graphic(1,y,'Hex.dmi',"1,1",32,32)
new/datum/atom/turf (1,y,gfx)
gfx.Cut()
gfx += new/atom/movable/graphic(2,y,'Hex.dmi',"0,0")
gfx += new/atom/movable/graphic(2,y,'Hex.dmi',"1,0",32)
gfx += new/atom/movable/graphic(2,y,'Hex.dmi',"0,1",0,32)
gfx += new/atom/movable/graphic(2,y,'Hex.dmi',"1,1",32,32)
new/datum/atom/turf (2,y,gfx)

It will generate two columns, with lengths 13 and 12.
I'm pretty sure it's got everything to do with your Hex_Coord() procedure. Also, why don't you check the maxx and maxy variables, plus the x and y locations (real and hex) for the hexes. Have it output in that New procedure you have over there.
In response to CaptFalcon33035
I've already done the latter. maxx and maxy are both in the code I showed, and the x and y locations for the hexes will go up to 1,19 (hex) and 3,37 (real).

I don't think it's my Hex_Coord() procedure at all.

proc
Hex_Coord(var/hex_x,var/hex_y,var/px,var/py)
var/x
var/y = hex_y*(46)
if(hex_y%2)
x = hex_x*58
else
x = hex_x*58+29
px += x%32
py += y%32
x = round(x/32)
y = round(y/32)
while(px <=-16)
x --
px += 32
while(px >= 16)
x ++
px -= 32
while(py <=-16)
y --
py += 32
while(py >= 16)
y ++
py -= 32
return list(round(x),round(y),px,py)