本文整理汇总了C++中Platform::return_rectangle方法的典型用法代码示例。如果您正苦于以下问题:C++ Platform::return_rectangle方法的具体用法?C++ Platform::return_rectangle怎么用?C++ Platform::return_rectangle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Platform
的用法示例。
在下文中一共展示了Platform::return_rectangle方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: move_bonus
int Bonus::move_bonus(double distance, Platform plat) {
this->cir.center.y+=distance;
point P=intersects(this->cir,plat.return_rectangle());
if(cir.center.y>640+cir.r) return -1;
else {
if(P.x!=INF&&P.y!=INF) return this->type;
else return 0;
}
}
示例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
//co zwraca opisane jest w Ball.h
int Ball::move(vbl &blocks, vbo &borders, vbn &bonuses, Platform &plat, int blocksuntouched[], int &blocks_left) {
lBR_tmp.clear();
lBoR_tmp.clear();
bool col = false;
bool usun = false;
bool usun_zolte = 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 && !find(*it)/*lastBorderReflection != it*/) {
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);
lBoR_tmp.push_back(*it);
// lastBorderReflection = it;
// lastBlockReflection = blocks.end();
}
else if (w.x != INF && find(*it)) {
puts("err 2*lBoR");
lBoR_tmp.push_back(*it);
}
}
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 && !find(*it)/*lastBlockReflection != it*/) {
lBR_tmp.push_back(*it);
// lastBlockReflection = it;
// lastBorderReflection = borders.end();
col = true;
cc++;
reflect(w);
if ((*it).get_lives()==(*it).get_maxlives()) {
blocksuntouched[(*it).get_type()]--;
int yellowblock=3;
if(blocksuntouched[yellowblock]==0) {
usun_zolte = true;
blocksuntouched[yellowblock]=-1;
// lastBlockReflection = blocks.end();
// lBR_tmp.clear();
}
}
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;
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");
//.........这里部分代码省略.........
示例4: move
//co zwraca opisane jest w Ball.h
int Ball::move(vbl &blocks, vbo &borders, vbn &bonuses, Platform &plat, int blocksuntouched[], int &blocks_left, int &new_points) {
lBR_tmp.clear();
lBoR_tmp.clear();
bool col = false;
bool usun = false;
bool usun_zolte = false;
new_points = 0;
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 && !find(*it)/*lastBorderReflection != it*/) {
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);
lBoR_tmp.push_back(*it);
// lastBorderReflection = it;
// lastBlockReflection = blocks.end();
}
else if (w.x != INF && find(*it)) {
puts("err 2*lBoR");
lBoR_tmp.push_back(*it);
}
}
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() && !usun; it++) {
rr = (*it).return_rectangle();
w = collision(rr);
if (w.x != INF && !find(*it)) {
lBR_tmp.push_back(*it);
col = true;
cc++;
reflect(w);
if ((*it).get_lives()==(*it).get_maxlives()) {
blocksuntouched[(*it).get_type()]--;
int yellowblock=3;
if(blocksuntouched[yellowblock]==0) {
usun_zolte = true;
blocksuntouched[yellowblock]=-1;
}
}
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;
new_points += (*it).get_type();
it--;
blocks.erase(it+1);
blocks_left--;
}
//tworzenie bonusu
int bonustype;
if (chanceforbonus) {
double random_no = (double)rand() / RAND_MAX;
if (random_no < 0.850) chanceforbonus = false;
else if (chanceforbonus && random_no < 0.870) bonustype = 1;
else if (chanceforbonus && random_no < 0.905) bonustype = 2;
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;
//.........这里部分代码省略.........
示例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;
}