Page 1 of 1

BWAPI::TilePositions width and height?

Posted: Sun Jul 17, 2011 12:14 pm
by TheBlueGnu
I was going through the BWSAL code and noticed in BasicAIModule ConstructionManager.cpp in the section "//if the type is a normal building (not an addon)" it says:

b->position = BWAPI::Position(b->tilePosition.x()*32 + b->type.tileWidth()*16, b->tilePosition.y()*32 + b->type.tileHeight()*16);

Now I thought starcraft tiles were 32x32 units (32 in x and 32 in y). Why would this line of code also add the tile's width*16 to it's x position and it's height*16 to the y?

I wonder if this is why I had trouble getting the ai to see and build at specific tile positions.

Posted: Wed Jul 20, 2011 4:22 pm
by Heinermann
Because it will give the CENTER of the unit.
It's the same as b->type.tileWidth()*32 / 2.

If it was just *32 it will give the unit's right/bottom positions instead of the center.

Posted: Mon Jul 25, 2011 5:16 am
by TheBlueGnu
[quote name='Heinermann' date='21 July 2011 - 12:22 AM' timestamp='1311178945' post='10297']
Because it will give the CENTER of the unit.
It's the same as b->type.tileWidth()*32 / 2.

If it was just *32 it will give the unit's right/bottom positions instead of the center.
[/quote]

Ahhhh ok, that explains a lot. I actually got it working using the BWSAL code, but thanks for your help :).