本文整理汇总了C++中Dot::setX方法的典型用法代码示例。如果您正苦于以下问题:C++ Dot::setX方法的具体用法?C++ Dot::setX怎么用?C++ Dot::setX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dot
的用法示例。
在下文中一共展示了Dot::setX方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rand
Asteroid::Asteroid(int ast_size){
int i, gen, dots, interval, angle, radius, min_radius, delta_radius;
Asteroid* ast;
Dot d;
item = NULL;
dots = 3*pow(2,ast_size);
interval = 360/dots;
min_radius = 10*pow(2,ast_size);
delta_radius = 1.25*min_radius;
//Generating vertex
for(i=0; i<dots; i++){
angle = rand()%interval + i*interval;
radius = rand()%delta_radius + min_radius;
d.setX(radius*cos(angle*PI/180));
d.setY(radius*sin(angle*PI/180));
loop_vertex.push_back(d);
}
if(ast_size != SMALL){
//Generating subparts
gen = rand()%2+2;
while(gen>0){
ast = new Asteroid(ast_size-1);
d.setX(rand()%4-2);
d.setY(rand()%4-2);
ast->setSpeed(d);
parts.push_back(ast);
gen--;
}
}
if(ast_size == BIG){
//Generating item
gen = rand()%(NUM_ITEMS*3);
if(gen%3 == 0){
item = new Item(gen/3);
item->setSpeed(rand()%360, 0.25);
}
}
//Adjusting centroid
centralize();
//setColor(0, 1, (float)(BIG - ast_size)/BIG);
setColor(0, (GLfloat)(ast_size*0.125 + 0.75), (GLfloat)(0.25-ast_size*0.125));
setHandling(1);
if(rand()%2 == 0){
commands[TURN_LEFT] = true;
}
else{
commands[TURN_RIGHT] = true;
}
}
示例2: resetGame
void myGame::resetGame()
{
ghosts.clear();
dots.clear();
//create patterns
Pattern* ghostPattern1 = new Pattern(1);
ghostPattern1->addStep(0, "CAMP", 40, [&] (Entity* e) {
Ghost* myself = static_cast<Ghost*>(e) ;
int waypoint = myself->targetWaypoint ;
VECTOR2 center = *myself->getCenter() ;
float left_edge = myself->getX();
float right_edge = myself->getX() + myself->getWidth()*myself->getScale();
float top_edge = myself->getY();
float bottom_edge = myself->getY() + myself->getHeight()*myself->getScale();
VECTOR2 currentWaypoint = waypointSet1[waypoint] ;
if( currentWaypoint.x > left_edge &&
currentWaypoint.x < right_edge &&
currentWaypoint.y > top_edge &&
currentWaypoint.y < bottom_edge)
myself->targetWaypoint++ ;
if( myself->targetWaypoint > 3) myself->targetWaypoint = 0 ;
myself->waypointTrack(waypointSet1[waypoint]);
myself->vectorTrack(&player, 180);
}) ;
Pattern* ghostPattern2 = new Pattern(1);
ghostPattern2->addStep(0, "CAMP", 40, [&] (Entity* e) {
Ghost* myself = static_cast<Ghost*>(e) ;
int waypoint = myself->targetWaypoint ;
VECTOR2 center = *myself->getCenter() ;
float left_edge = myself->getX();
float right_edge = myself->getX() + myself->getWidth()*myself->getScale();
float top_edge = myself->getY();
float bottom_edge = myself->getY() + myself->getHeight()*myself->getScale();
VECTOR2 currentWaypoint = waypointSet2[waypoint] ;
if( currentWaypoint.x > left_edge &&
currentWaypoint.x < right_edge &&
currentWaypoint.y > top_edge &&
currentWaypoint.y < bottom_edge)
myself->targetWaypoint++ ;
if( myself->targetWaypoint > 3) myself->targetWaypoint = 0 ;
myself->waypointTrack(waypointSet2[waypoint]);
myself->vectorTrack(&player, 180);
}) ;
//create entities
// ghost 1
Ghost* ghost1 = new Ghost() ;
if (!ghost1->initialize(this, ghostNS::WIDTH, ghostNS::HEIGHT, 4, &allTM))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing ghost entity"));
ghost1->setX(0);
ghost1->setY(0);
ghosts.add(ghost1, new Pattern(ghostPattern1));
// ghost 2
Ghost* ghost2 = new Ghost() ;
if (!ghost2->initialize(this, ghostNS::WIDTH, ghostNS::HEIGHT, 4, &allTM))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing ghost entity"));
ghost2->setX(GAME_WIDTH - ghostNS::WIDTH*ghostNS::SCALE);
ghost2->setY(GAME_HEIGHT - ghostNS::HEIGHT*ghostNS::SCALE);
ghost2->setCurrentFrame(1);
ghosts.add(ghost2, new Pattern(ghostPattern2));
// dots
rows = 4 ;
cols = 5 ;
for(int i = 0; i < rows; ++i)
{
for(int j = 0; j < cols; ++j)
{
Dot* newDot = new Dot() ;
if (!newDot->initialize(this, dotNS::WIDTH, dotNS::HEIGHT, 4, &allTM))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing dot entity"));
newDot->setX( ((GAME_WIDTH/cols)*j) + 50);
newDot->setY( ((GAME_HEIGHT/rows)*i) + 50);
newDot->setScale(dotNS::SCALE);
dots.add(newDot);
}
}
dotsRemaining = rows * cols ;
}
示例3: transf
Dot Dot::transf(float rotatee, Dot translade){
Dot p;
p.setX(x*cos(rotatee*PI/180)-y*sin(rotatee*PI/180));
p.setY(x*sin(rotatee*PI/180)+y*cos(rotatee*PI/180));
return (p + translade);
}