本文整理汇总了C++中Coordinate::SetX方法的典型用法代码示例。如果您正苦于以下问题:C++ Coordinate::SetX方法的具体用法?C++ Coordinate::SetX怎么用?C++ Coordinate::SetX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Coordinate
的用法示例。
在下文中一共展示了Coordinate::SetX方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WorldToBlip
void Radar::WorldToBlip( Coordinate &w, Coordinate &b ) {
Player *p = Player::Instance();
Coordinate player = p->GetWorldPosition();
b.SetX( ( ( w.GetX() - player.GetX() ) / float(visibility) ) * ( RADAR_WIDTH / 2.0 ) );
b.SetY( ( ( w.GetY() - player.GetY() ) / float(visibility) ) * ( RADAR_HEIGHT / 2.0 ) );
}
示例2: FromXMLNode
bool Gate::FromXMLNode( xmlDocPtr doc, xmlNodePtr node ) {
xmlNodePtr attr;
string value;
Coordinate pos;
if( (attr = FirstChildNamed(node,"x")) ){
value = NodeToString(doc,attr);
pos.SetX( atof( value.c_str() ));
} else return false;
if( (attr = FirstChildNamed(node,"y")) ){
value = NodeToString(doc,attr);
pos.SetY( atof( value.c_str() ));
} else return false;
SetWorldPosition( pos );
if( (attr = FirstChildNamed(node,"exit")) ){
value = NodeToString(doc,attr);
Gate* exit = Gates::Instance()->GetGate( value );
if( exit != NULL ) {
Gate::SetPair(this,exit);
}
}
return true;
}
示例3: Draw
/**\brief Draws the radar.
*/
void Radar::Draw( Camera* camera, SpriteManager* sprites ) {
short int radar_mid_x = RADAR_MIDDLE_X + Video::GetWidth() - 129;
short int radar_mid_y = RADAR_MIDDLE_Y + 5;
int radarSize;
Coordinate focus = camera->GetFocusCoordinate();
/*if(largeMode) {
if( visibility <= QUADRANTSIZE )
{
Map* map = (Map*)UI::Search( "/Map/" );
assert(map); // large mode should only be on when there is a map.
if(map) {
map->SetCenter( focus );
map->SetScale( 300.0 / (2*visibility) );
}
}
return;
}*/
list<Sprite*> *spriteList = sprites->GetSpritesNear(camera->GetFocusCoordinate(), (float)visibility);
for( list<Sprite*>::const_iterator iter = spriteList->begin(); iter != spriteList->end(); iter++)
{
Coordinate blip;
Sprite *sprite = *iter;
// Calculate the blip coordinate for this sprite
Coordinate wpos = sprite->GetWorldPosition();
WorldToBlip( focus, wpos, blip );
// Use the OpenGL Crop Rectangle to ensure that the blip is on the radar
/* Convert to screen coords */
blip.SetX( blip.GetX() + radar_mid_x );
blip.SetY( blip.GetY() + radar_mid_y );
radarSize = int((sprite->GetRadarSize() / float(visibility)) * (RADAR_HEIGHT / 4.0));
if( radarSize >= 1 ) {
if(sprite->GetID() == Hud::GetTarget() && Timer::GetTicks() % 1000 < 100)
Video::DrawCircle( blip, radarSize, 2, WHITE );
else
Video::DrawCircle( blip, radarSize, 1, sprite->GetRadarColor() );
} else {
if(sprite->GetID() == Hud::GetTarget() && Timer::GetTicks() % 1000 < 100)
Video::DrawCircle( blip, 1, 2, WHITE );
else
Video::DrawPoint( blip, sprite->GetRadarColor() );
}
}
delete spriteList;
}
示例4:
/**\brief Constructor using a full Full Description
*/
Planet::Planet( string _name, float _x, float _y, Image* _image, Alliance* _alliance, bool _landable, int _traffic, int _militiaSize, int _sphereOfInfluence, list<Technology*> _technologies):
alliance(_alliance),
landable(_landable),
traffic(_traffic),
militiaSize(_militiaSize),
sphereOfInfluence(_sphereOfInfluence),
technologies(_technologies)
{
// Check the inputs
assert(_image);
assert(_alliance);
Coordinate pos;
pos.SetX(_x);
pos.SetY(_y);
SetWorldPosition( pos );
SetName(_name);
SetImage(_image);
Image::Store(name,GetImage());
SetRadarColor(Color::Get(48, 160, 255));
}
示例5: Draw
/**\brief Draws the radar.
*/
void Radar::Draw( void ) {
short int radar_mid_x = RADAR_MIDDLE_X + Video::GetWidth() - 129;
short int radar_mid_y = RADAR_MIDDLE_Y + 5;
int radarSize;
list<Sprite*> *spriteList = SpriteManager::Instance()->GetSpritesNear(Camera::Instance()->GetFocusCoordinate(), (float)visibility);
for( list<Sprite*>::const_iterator iter = spriteList->begin(); iter != spriteList->end(); iter++)
{
Coordinate blip;
Sprite *sprite = *iter;
//if( sprite->GetDrawOrder() == DRAW_ORDER_PLAYER ) continue;
// Calculate the blip coordinate for this sprite
Coordinate wpos = sprite->GetWorldPosition();
WorldToBlip( wpos, blip );
// Use the OpenGL Crop Rectangle to ensure that the blip is on the radar
/* Convert to screen coords */
blip.SetX( blip.GetX() + radar_mid_x );
blip.SetY( blip.GetY() + radar_mid_y );
radarSize = int((sprite->GetRadarSize() / float(visibility)) * (RADAR_HEIGHT/4.0));
if( radarSize >= 1 ) {
if(sprite->GetID() == Hud::GetTarget() && Timer::GetTicks() % 1000 < 100)
Video::DrawCircle( blip, radarSize, 2, WHITE );
else
Video::DrawCircle( blip, radarSize, 1, sprite->GetRadarColor() );
} else {
if(sprite->GetID() == Hud::GetTarget() && Timer::GetTicks() % 1000 < 100)
Video::DrawCircle( blip, 1, 2, WHITE );
else
Video::DrawPoint( blip, sprite->GetRadarColor() );
}
}
delete spriteList;
}
示例6: Draw
/**\brief Draws the radar.
*/
void Radar::Draw( void ) {
short int radar_mid_x = RADAR_MIDDLE_X + Video::GetWidth() - 129;
short int radar_mid_y = RADAR_MIDDLE_Y + 5;
int radarSize;
list<Sprite*> *spriteList = SpriteManager::Instance()->GetSpritesNear(Camera::Instance()->GetFocusCoordinate(), (float)visibility);
for( list<Sprite*>::const_iterator iter = spriteList->begin(); iter != spriteList->end(); iter++)
{
Coordinate blip;
Sprite *sprite = *iter;
//if( sprite->GetDrawOrder() == DRAW_ORDER_PLAYER ) continue;
// Calculate the blip coordinate for this sprite
Coordinate wpos = sprite->GetWorldPosition();
WorldToBlip( wpos, blip );
if( blip.ViolatesBoundary( -(RADAR_HEIGHT / 2.0), (RADAR_WIDTH / 2.0), (RADAR_HEIGHT / 2.0), -(RADAR_WIDTH / 2.0) ) == false ) {
/* blip is on the radar */
/* Convert to screen coords */
blip.SetX( blip.GetX() + radar_mid_x );
blip.SetY( blip.GetY() + radar_mid_y );
radarSize = int((sprite->GetRadarSize() / float(visibility)) * (RADAR_HEIGHT/4.0));
if( radarSize >= 1 ) {
Video::DrawCircle( blip, radarSize, 1, sprite->GetRadarColor() );
} else {
Video::DrawPoint( blip, sprite->GetRadarColor() );
}
}
}
delete spriteList;
}
示例7: FromXMLNode
/**\brief Parse one player out of an xml node.
*/
bool Planet::FromXMLNode( xmlDocPtr doc, xmlNodePtr node ) {
xmlNodePtr attr;
string value;
Coordinate pos;
if( (attr = FirstChildNamed(node,"alliance")) ){
value = NodeToString(doc,attr);
alliance = Alliances::Instance()->GetAlliance(value);
if(alliance==NULL)
{
LogMsg(ERR, "Could not create Planet '%s'. Unknown Alliance '%s'.", this->GetName().c_str(), value.c_str());
return false;
}
} else return false;
if( (attr = FirstChildNamed(node,"x")) ){
value = NodeToString(doc,attr);
pos.SetX( atof( value.c_str() ));
} else return false;
if( (attr = FirstChildNamed(node,"y")) ){
value = NodeToString(doc,attr);
pos.SetY( atof( value.c_str() ));
} else return false;
SetWorldPosition( pos );
if( (attr = FirstChildNamed(node,"landable")) ){
value = NodeToString(doc,attr);
landable = ( atoi( value.c_str() ) != 0);
} else return false;
if( (attr = FirstChildNamed(node,"traffic")) ){
value = NodeToString(doc,attr);
traffic = (short int) atoi( value.c_str() );
} else return false;
if( (attr = FirstChildNamed(node,"image")) ){
Image* image = Image::Get( NodeToString(doc,attr) );
Image::Store(name, image);
SetImage(image);
} else return false;
if( (attr = FirstChildNamed(node,"militia")) ){
value = NodeToString(doc,attr);
militiaSize = (short int) atoi( value.c_str() );
} else return false;
if( (attr = FirstChildNamed(node,"sphereOfInfluence")) ){
value = NodeToString(doc,attr);
sphereOfInfluence = atoi( value.c_str() );
} else return false;
for( attr = FirstChildNamed(node,"technology"); attr!=NULL; attr = NextSiblingNamed(attr,"technology") ){
value = NodeToString(doc,attr);
Technology *tech = Technologies::Instance()->GetTechnology( value );
technologies.push_back(tech);
}
technologies.unique();
return true;
}
示例8: WorldToBlip
/**\brief Gets the radar position based on world coordinate
* \param w Pointer to world coordinate
* \retval b Pointer to radar coordinate
*/
void Radar::WorldToBlip( Coordinate &w, Coordinate &b ) {
Coordinate focus = Camera::Instance()->GetFocusCoordinate();
b.SetX( ( ( w.GetX() - focus.GetX() ) / float(visibility) ) * ( RADAR_WIDTH / 2.0 ) );
b.SetY( ( ( w.GetY() - focus.GetY() ) / float(visibility) ) * ( RADAR_HEIGHT / 2.0 ) );
}
示例9: WorldToBlip
/**\brief Gets the radar position based on world coordinate
* \param w Pointer to world coordinate
* \retval b Pointer to radar coordinate
*/
void Radar::WorldToBlip( Coordinate focus, Coordinate &w, Coordinate &b ) {
b.SetX( ( ( w.GetX() - focus.GetX() ) / float(visibility) ) * ( RADAR_WIDTH / 2.0 ) );
b.SetY( ( ( w.GetY() - focus.GetY() ) / float(visibility) ) * ( RADAR_HEIGHT / 2.0 ) );
}