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.