本文整理汇总了C++中Platform::getSpeed方法的典型用法代码示例。如果您正苦于以下问题:C++ Platform::getSpeed方法的具体用法?C++ Platform::getSpeed怎么用?C++ Platform::getSpeed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Platform
的用法示例。
在下文中一共展示了Platform::getSpeed方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OpenMMException
Platform& Platform::findPlatform(const vector<string>& kernelNames) {
Platform* best = 0;
vector<Platform*>& platforms = getPlatforms();
double speed = 0.0;
for (int i = 0; i < (int) platforms.size(); ++i) {
if (platforms[i]->supportsKernels(kernelNames) && platforms[i]->getSpeed() > speed) {
best = platforms[i];
speed = best->getSpeed();
}
}
if (best == 0)
throw OpenMMException("No Platform supports all the requested kernels");
return *best;
}
示例2: move
//co zwraca opisane jest w Ball.h
int Ball::move(vbl &blocks, vbo &borders, vbn &bonuses, Platform plat, int blocksuntouched[]) {
bool col = false;
bool usun = false;
rectangle rr;
point w;
int cc = 0;
//zderzenie z obramowaniem
for (vbo::iterator it = borders.begin(); it != borders.end()/* && !col*/ && !usun; it++) {
rr = (*it).return_rectangle();
w = collision(rr);
if (w.x != INF) {
if (!(*it).isMurderous()) {
col = true;
cc++;
reflect(w);
this->moze_odbic_sie_od_platformy = true;
}
else {
usun = true;
break;
}
change_vec(0.0, 0.0);
}
}
bool chanceforbonus=false; //zmienna spamiętująca czy usunięto klocek
point bonuscords;
//zderzenie z blokiem
for (vbl::iterator it = blocks.begin(); it != blocks.end()/* && !col*/ && !usun; it++) {
rr = (*it).return_rectangle();
w = collision(rr);
if (w.x != INF) {
col = true;
cc++;
reflect(w);
if ((*it).get_lives()==(*it).get_maxlives()) blocksuntouched[(*it).get_type()]--;
if ((*it).hit(1)) { // uderzenie z siłą 1 - do zmiany !!!
chanceforbonus=true;
bonuscords.x=((*it).return_rectangle().bottomright.x+(*it).return_rectangle().upperleft.x)/2;
bonuscords.y=(*it).return_rectangle().bottomright.y;
blocks.erase(it);
}
//tworzenie bonusu
srand(time(0));
int bonustype=rand()%3+1;
if(bonustype%2==0&&chanceforbonus) chanceforbonus=true;
else chanceforbonus=false;
if(chanceforbonus) {
circle cir;
cir.r=16;
cir.center=bonuscords;
Bonus bonus(cir, bonustype);
bonuses.push_back(bonus);
}
this->moze_odbic_sie_od_platformy = true;
break;
}
}
bool plat_col = false;
//zderzenie z platformą będzie tu ↓
// if (this->moze_odbic_sie_od_platformy == true) {
rr = plat.return_rectangle();
w = collision(rr);
if (w.x != INF) {
plat_col = true;
cc++;
if (this->moze_odbic_sie_od_platformy) {
double dist = (w.x-(rr.upperleft.x + (rr.bottomright.x-rr.upperleft.x)/2));
reflect(w);
change_vec(plat.getSpeed(), dist); //sprawdź czy nie krawędź
}
this->moze_odbic_sie_od_platformy = false;
}
// }
//if (cc > 1) cout<<"errrrr\n";
if (cc > 1 && plat_col) usun = true;
(this->cir).center.x += speed*mv.x;
(this->cir).center.y += speed*mv.y;
//.........这里部分代码省略.........
示例3: move
//.........这里部分代码省略.........
else if (chanceforbonus && random_no < 0.945) bonustype = 3;
else if (chanceforbonus && random_no < 0.980) bonustype = 4;
else if (chanceforbonus && random_no <= 1.0) bonustype = 5;
/*
1 - zmniejsz platformę
2 - zwiększ platformę
3 - dodaj border na dole
4 - dodaj 2 nowe piłki
5 - dodaj życie
*/
//bonustype=2;
}
if(chanceforbonus) {
circle cir;
//cir.r=16;
cir.center=bonuscords;
Bonus bonus(cir, bonustype);
bonuses.push_back(bonus);
}
this->moze_odbic_sie_od_platformy = true;
break;
}
else if (w.x != INF && find(*it)) {
puts("err 2*lBR");
lBR_tmp.push_back(*it);
}
}
if (usun_zolte) {
int yellowblock = 3;
for (vbl::iterator it2 = blocks.begin(); it2 != blocks.end(); it2++) { //to nie powinno być w części rysowania!
if((*it2).get_type()==yellowblock) {
new_points += (*it2).get_type();
it2--;
blocks.erase(it2+1);
blocks_left--;
}
}
}
//zderzenie z platformą
bool plat_col = false;
rr = plat.return_rectangle();
w = collision(rr);
if (w.x != INF) {
plat_col = true;
cc++;
if (this->moze_odbic_sie_od_platformy) {
double dist = (w.x-(rr.upperleft.x + (rr.bottomright.x-rr.upperleft.x)/2));
reflect(w);
change_vec(plat.getSpeed(), dist); //sprawdź czy nie krawędź
}
this->moze_odbic_sie_od_platformy = false;
}
if (!plat_col && blocksuntouched[0]) {
w=collision(bon_bl);
if (w.x != INF) {
cc++;
reflect(w);
this->moze_odbic_sie_od_platformy = false;
change_vec(0.0, 0.0);
blocksuntouched[0] = 0;
}
}
/*else if (plat_col && blocksuntouched[0]) {
blocksuntouched[0] = 0;
}*/
lBR.clear();
for (vbl::iterator it = lBR_tmp.begin(); it != lBR_tmp.end(); it++) {
lBR.push_back(*it);
}
lBoR.clear();
for (vbo::iterator it = lBoR_tmp.begin(); it != lBoR_tmp.end(); it++) {
lBoR.push_back(*it);
}
if (cc > 1) puts("errrrr");
if (cc > 1 && plat_col) {
mv.x = 0;
mv.y = 10;
if ((this->cir).center.y < 595) mv.y *= -1;
if ((this->cir).center.x > 480) (this->cir).center.x -= 0.1;
else (this->cir).center.x += 0.1;
//usun = true;
}
(this->cir).center.x += speed*mv.x;
(this->cir).center.y += speed*mv.y;
if (usun && !plat_col) return 1;
else if (usun && plat_col) return 2;
else if (plat_col) return 3;
else return 4;
}
示例4: move
//.........这里部分代码省略.........
it--;
blocks.erase(it+1);
blocks_left--;
// lastBlockReflection = blocks.end();
}
//printf("bloki: %d\n", blocks_left);
//lastBlockReflection = blocks.end();
//tworzenie bonusu
int bonustype=rand()%5;
bonustype++;
// bonustype=5;
if(rand()%3==0&&chanceforbonus) chanceforbonus=true;
else chanceforbonus=false;
if(chanceforbonus) {
circle cir;
//cir.r=16;
cir.center=bonuscords;
Bonus bonus(cir, bonustype);
bonuses.push_back(bonus);
}
this->moze_odbic_sie_od_platformy = true;
break;
}
else if (w.x != INF && find(*it)/*lastBlockReflection == it*/) {
puts("err 2*lBR");
lBR_tmp.push_back(*it);
}
}
if (usun_zolte) {
int yellowblock = 3;
for (vbl::iterator it2 = blocks.begin(); it2 != blocks.end(); it2++) { //to nie powinno być w części rysowania!
if((*it2).get_type()==yellowblock) {
it2--;
blocks.erase(it2+1);
blocks_left--;
}
}
}
bool plat_col = false;
//zderzenie z platformą będzie tu ↓
// if (this->moze_odbic_sie_od_platformy == true) {
rr = plat.return_rectangle();
w = collision(rr);
if (w.x != INF) {
plat_col = true;
cc++;
if (this->moze_odbic_sie_od_platformy) {
double dist = (w.x-(rr.upperleft.x + (rr.bottomright.x-rr.upperleft.x)/2));
reflect(w);
change_vec(plat.getSpeed(), dist); //sprawdź czy nie krawędź
// lastBorderReflection = borders.end();
// lastBlockReflection = blocks.end();
}
this->moze_odbic_sie_od_platformy = false;
}
// }
if (!plat_col && blocksuntouched[0]) {
w=collision(bon_bl);
if (w.x != INF) {
cc++;
reflect(w);
// lastBorderReflection = borders.end();
// lastBlockReflection = blocks.end();
this->moze_odbic_sie_od_platformy = false;
change_vec(0.0, 0.0);
blocksuntouched[0]=0;
}
}
lBR.clear();
for (vbl::iterator it = lBR_tmp.begin(); it != lBR_tmp.end(); it++) {
lBR.push_back(*it);
// (*it).print();
}
lBoR.clear();
for (vbo::iterator it = lBoR_tmp.begin(); it != lBoR_tmp.end(); it++) {
lBoR.push_back(*it);
// (*it).print();
}
if (cc > 1) puts("errrrr");
if (cc > 1 && plat_col) usun = true;
(this->cir).center.x += speed*mv.x;
(this->cir).center.y += speed*mv.y;
if (usun && !plat_col) return 1;
else if (usun && plat_col) return 2;
else if (plat_col) return 3;
else return 4;
}
示例5: move
//co zwraca opisane jest w Ball.h
int Ball::move(vbl &blocks, vbo &borders, Platform plat) {
bool col = false;
bool usun = false;
rectangle rr;
point w;
//zderzenie z obramowaniem
for (vbo::iterator it = borders.begin(); it != borders.end() && !col && !usun; it++) {
rr = (*it).return_rectangle();
w = collision(rr);
if (w.x != INF) {
if (!(*it).isMurderous()) {
col = true;
reflect(w);
this->moze_odbic_sie_od_platformy = true;
}
else {
usun = true;
break;
}
}
}
//zderzenie z blokiem
for (vbl::iterator it = blocks.begin(); it != blocks.end() && !col && !usun; it++) {
rr = (*it).return_rectangle();
w = collision(rr);
if (w.x != INF) {
col = true;
reflect(w);
if ((*it).hit(1)) { // uderzenie z siłą 1 - do zmiany !!!
cout<<"usuwam...\n";
blocks.erase(it);
}
this->moze_odbic_sie_od_platformy = true;
break;
}
}
bool plat_col = false;
//zderzenie z platformą będzie tu ↓
// if (this->moze_odbic_sie_od_platformy == true) {
rr = plat.return_rectangle();
w = collision(rr);
if (w.x != INF) {
plat_col = true;
if (this->moze_odbic_sie_od_platformy) {
change_vec(plat.getSpeed());
reflect(w);
}
this->moze_odbic_sie_od_platformy = false;
}
// }
(this->cir).center.x += speed*mv.x;
(this->cir).center.y += speed*mv.y;
if (usun && !plat_col) return 1;
else if (usun && plat_col) return 2;
else if (plat_col) return 3;
else return 4;
}