codebackup / bwapi

Automatically exported from code.google.com/p/bwapi
0 stars 0 forks source link

get Minerals #417

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Actually i m working in jnibwapi. however i need to do some stuff in bwapi. I 
want to get the current minerals and gas of the game. So i found the method 
minerals() in the class player. I tried to do something like that

BWAPI::Player* player;

int minerals = player->minerals();

in debugging i got no errors, but i cant run the game. Any idea?

Original issue reported on code.google.com by snake__p...@hotmail.com on 16 Nov 2011 at 10:57

GoogleCodeExporter commented 9 years ago
You are declaring a pointer to a player class, but you cannot create or use a 
player class that was not directly obtained by the Game class.

You must use the following:

int minerals = Broodwar->self()->minerals();

Where Broodwar is a pointer to the Game class obtained from BWAPI, and self() 
is a member that returns a pointer to a Player object that represents the 
current player.

Original comment by AHeinerm on 17 Nov 2011 at 10:26

GoogleCodeExporter commented 9 years ago
Actually that's not entirely true.
You can declare a pointer, but you must initialize it with a BWAPI function.

BWAPI::Player *myself = Broodwar->self();

Original comment by AHeinerm on 17 Nov 2011 at 10:28

GoogleCodeExporter commented 9 years ago
Thanks deathkni as i am begginer in bwapi, its quite a help.

Original comment by snake__p...@hotmail.com on 17 Nov 2011 at 10:34