BWAPI::TilePositions width and height?

https://github.com/bwapi/bwapi
TheBlueGnu
Posts: 27
Joined: Fri May 20, 2011 12:34 pm

BWAPI::TilePositions width and height?

Postby TheBlueGnu » Sun Jul 17, 2011 12:14 pm

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.
Heinermann
Posts: 362
Joined: Thu Apr 26, 2007 12:42 am

Postby Heinermann » Wed Jul 20, 2011 4:22 pm

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.
TheBlueGnu
Posts: 27
Joined: Fri May 20, 2011 12:34 pm

Postby TheBlueGnu » Mon Jul 25, 2011 5:16 am

[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 :).

Return to “BWAPI (wrappers in other languages / questions and announcements related to BWAPI itself)”

Who is online

Users browsing this forum: No registered users and 1 guest