test
This commit is contained in:
parent
37776af5db
commit
ab03d5f10c
4045 changed files with 286212 additions and 3 deletions
80
.config/Code/User/History/-605b3219/0147.cpp
Normal file
80
.config/Code/User/History/-605b3219/0147.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() <= y+4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getY() >= y+height-4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() >= x && ball.getX() <= x+4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() <= x+width && ball.getX() >= x+width-4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x+width/2, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
90
.config/Code/User/History/-605b3219/0rhK.cpp
Normal file
90
.config/Code/User/History/-605b3219/0rhK.cpp
Normal file
|
@ -0,0 +1,90 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() <= y+4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
ball.setY(ball.getY()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getY() >= y+height-4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
ball.setY(ball.getY()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() >= x && ball.getX() <= x+4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
ball.setX(ball.getX()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() <= x+width && ball.getX() >= x+width-4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
ball.setX(ball.getX()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]){
|
||||
food = new BlueFood(x+width/2, y);
|
||||
ball.setColor(colors[BLUE]);
|
||||
}
|
||||
else if(color == colors[RED]){
|
||||
food = new RedFood(x+width/2, y);
|
||||
ball.setColor(colors[RED]);
|
||||
}
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
96
.config/Code/User/History/-605b3219/2I7A.cpp
Normal file
96
.config/Code/User/History/-605b3219/2I7A.cpp
Normal file
|
@ -0,0 +1,96 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() <= y+4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
ball.setY(ball.getY()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getY() >= y+height-4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
ball.setY(ball.getY()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() >= x && ball.getX() <= x+4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
ball.setX(ball.getX()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() <= x+width && ball.getX() >= x+width-4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
ball.setX(ball.getX()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]){
|
||||
food = new BlueFood(x+width/2, y);
|
||||
ball.setColor(colors[BLUE]);
|
||||
}
|
||||
else if(color == colors[RED]){
|
||||
food = new RedFood(x+width/2, y);
|
||||
ball.setColor(colors[RED]);
|
||||
}
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]){
|
||||
food = new PinkFood(x+width/2, y);
|
||||
ball.setColor(colors[PINK]);
|
||||
}
|
||||
else if(color == colors[YELLOW]){
|
||||
food = new YellowFood(x+width/2, y);
|
||||
ball.setColor(colors[YELLOW]);
|
||||
}
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
81
.config/Code/User/History/-605b3219/37IS.cpp
Normal file
81
.config/Code/User/History/-605b3219/37IS.cpp
Normal file
|
@ -0,0 +1,81 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
// return 0 if didnt collide, 1 if brick broken, 2 if collison but not broken
|
||||
int Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
83
.config/Code/User/History/-605b3219/4P8x.cpp
Normal file
83
.config/Code/User/History/-605b3219/4P8x.cpp
Normal file
|
@ -0,0 +1,83 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
// return 0 if didnt collide, 1 if brick broken, 2 if collison but not broken
|
||||
int Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2) color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
else if(strength == 1) color = colors[GREEN];
|
||||
else{ //1
|
||||
if(color == colors[GREEN]) food = new GreenFood(x, y);
|
||||
else if(color == colors[PINK]) food = new PinkFood(x, y);
|
||||
else if(color == colors[BLUE]) food = new BlueFood(x, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x, y);
|
||||
}
|
||||
if(color == colors[GREEN]) food = new GreenFood(x, y);
|
||||
else if(color == colors[PINK]) food = new PinkFood(x, y);
|
||||
else if(color == colors[BLUE]) food = new BlueFood(x, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x, y);
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
75
.config/Code/User/History/-605b3219/5OMR.cpp
Normal file
75
.config/Code/User/History/-605b3219/5OMR.cpp
Normal file
|
@ -0,0 +1,75 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
// return 0 if didnt collide, 1 if brick broken, 2 if collison but not broken
|
||||
int Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2) color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
else if(strength == 1) color = colors[GREEN];
|
||||
else{
|
||||
if(color == colors[GREEN]) food[i][j] = new GreenFood(bricks[i][j]->getX() , bricks[i][j]->getY());
|
||||
else if(color == colors[PINK]) food[i][j] = new PinkFood(bricks[i][j]->getX() , bricks[i][j]->getY());
|
||||
else if(color == colors[BLUE]) food[i][j] = new BlueFood(bricks[i][j]->getX() , bricks[i][j]->getY());
|
||||
else if(color == colors[RED]) food[i][j] = new RedFood(bricks[i][j]->getX() , bricks[i][j]->getY());
|
||||
else if(color == colors[YELLOW]) food[i][j] = new YellowFood(bricks[i][j]->getX() , bricks[i][j]->getY());
|
||||
delete bricks[i][j];
|
||||
bricks[i][j] = nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
80
.config/Code/User/History/-605b3219/5oJy.cpp
Normal file
80
.config/Code/User/History/-605b3219/5oJy.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() <= y+2){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getY() >= y+height-2){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() >= x && ball.getX() <= x+2){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() <= x+width && ball.getX() > x+width/2){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x+width/2, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
80
.config/Code/User/History/-605b3219/6BYd.cpp
Normal file
80
.config/Code/User/History/-605b3219/6BYd.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() >= x ){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() <= x+width){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x+width/2, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
79
.config/Code/User/History/-605b3219/6HTj.cpp
Normal file
79
.config/Code/User/History/-605b3219/6HTj.cpp
Normal file
|
@ -0,0 +1,79 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
// return 0 if didnt collide, 1 if brick broken, 2 if collison but not broken
|
||||
int Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else if(color == colors[GREEN]) food = new GreenFood(x, y);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
80
.config/Code/User/History/-605b3219/6VFU.cpp
Normal file
80
.config/Code/User/History/-605b3219/6VFU.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x+width/2, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
83
.config/Code/User/History/-605b3219/6sFc.cpp
Normal file
83
.config/Code/User/History/-605b3219/6sFc.cpp
Normal file
|
@ -0,0 +1,83 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() <= y+4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
ball.setY(ball.getY()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getY() >= y+height-4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
ball.setY(ball.getY()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() >= x && ball.getX() <= x+4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
ball.setX(ball.getX()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() <= x+width && ball.getX() >= x+width-4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x+width/2, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
97
.config/Code/User/History/-605b3219/7BXG.cpp
Normal file
97
.config/Code/User/History/-605b3219/7BXG.cpp
Normal file
|
@ -0,0 +1,97 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() <= y+4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
ball.setY(ball.getY()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getY() >= y+height-4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
ball.setY(ball.getY()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() >= x && ball.getX() <= x+4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
ball.setX(ball.getX()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() <= x+width && ball.getX() >= x+width-4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
ball.setX(ball.getX()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]){
|
||||
food = new BlueFood(x+width/2, y);
|
||||
ball.setColor(colors[BLUE]);
|
||||
}
|
||||
else if(color == colors[RED]){
|
||||
food = new RedFood(x+width/2, y);
|
||||
ball.setColor(colors[RED]);
|
||||
}
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]){
|
||||
food = new PinkFood(x+width/2, y);
|
||||
ball.setColor(colors[PINK]);
|
||||
}
|
||||
else if(color == colors[YELLOW]){
|
||||
food = new YellowFood(x+width/2, y);
|
||||
ball.setColor(colors[YELLOW]);
|
||||
}
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
ball.setColor(colors[GREEN]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
80
.config/Code/User/History/-605b3219/8qNi.cpp
Normal file
80
.config/Code/User/History/-605b3219/8qNi.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x+width/2, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
81
.config/Code/User/History/-605b3219/9UJV.cpp
Normal file
81
.config/Code/User/History/-605b3219/9UJV.cpp
Normal file
|
@ -0,0 +1,81 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
// return 0 if didnt collide, 1 if brick broken, 2 if collison but not broken
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
84
.config/Code/User/History/-605b3219/9dBn.cpp
Normal file
84
.config/Code/User/History/-605b3219/9dBn.cpp
Normal file
|
@ -0,0 +1,84 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() <= y+4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
ball.setY(ball.getY()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getY() >= y+height-4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
ball.setY(ball.getY()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() >= x && ball.getX() <= x+4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
ball.setX(ball.getX()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() <= x+width && ball.getX() >= x+width-4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
ball.setX(ball.getX()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x+width/2, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
80
.config/Code/User/History/-605b3219/BCVg.cpp
Normal file
80
.config/Code/User/History/-605b3219/BCVg.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x+width/2, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
80
.config/Code/User/History/-605b3219/CHLq.cpp
Normal file
80
.config/Code/User/History/-605b3219/CHLq.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x+width/2, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
98
.config/Code/User/History/-605b3219/Clxq.cpp
Normal file
98
.config/Code/User/History/-605b3219/Clxq.cpp
Normal file
|
@ -0,0 +1,98 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
food = nullptr;
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() <= y+4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
ball.setY(ball.getY()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getY() >= y+height-4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
ball.setY(ball.getY()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() >= x && ball.getX() <= x+4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
ball.setX(ball.getX()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() <= x+width && ball.getX() >= x+width-4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
ball.setX(ball.getX()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]){
|
||||
food = new BlueFood(x+width/2, y);
|
||||
ball.setColor(colors[BLUE]);
|
||||
}
|
||||
else if(color == colors[RED]){
|
||||
food = new RedFood(x+width/2, y);
|
||||
ball.setColor(colors[RED]);
|
||||
}
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]){
|
||||
food = new PinkFood(x+width/2, y);
|
||||
ball.setColor(colors[PINK]);
|
||||
}
|
||||
else if(color == colors[YELLOW]){
|
||||
food = new YellowFood(x+width/2, y);
|
||||
ball.setColor(colors[YELLOW]);
|
||||
}
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
ball.setColor(colors[GREEN]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
80
.config/Code/User/History/-605b3219/DD9X.cpp
Normal file
80
.config/Code/User/History/-605b3219/DD9X.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() < y+width/2){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x+width/2, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
81
.config/Code/User/History/-605b3219/E1KT.cpp
Normal file
81
.config/Code/User/History/-605b3219/E1KT.cpp
Normal file
|
@ -0,0 +1,81 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
// return 0 if didnt collide, 1 if brick broken, 2 if collison but not broken
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x+width/2, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
87
.config/Code/User/History/-605b3219/EZ6j.cpp
Normal file
87
.config/Code/User/History/-605b3219/EZ6j.cpp
Normal file
|
@ -0,0 +1,87 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() <= y+4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
ball.setY(ball.getY()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getY() >= y+height-4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
ball.setY(ball.getY()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() >= x && ball.getX() <= x+4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
ball.setX(ball.getX()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() <= x+width && ball.getX() >= x+width-4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
ball.setX(ball.getX()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]){
|
||||
food = new BlueFood(x+width/2, y);
|
||||
ball.setColor(colors[BLUE]);
|
||||
}
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
80
.config/Code/User/History/-605b3219/F7Xm.cpp
Normal file
80
.config/Code/User/History/-605b3219/F7Xm.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x+width/2, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
75
.config/Code/User/History/-605b3219/GFY6.cpp
Normal file
75
.config/Code/User/History/-605b3219/GFY6.cpp
Normal file
|
@ -0,0 +1,75 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
// return 0 if didnt collide, 1 if brick broken, 2 if collison but not broken
|
||||
int Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2) color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
else if(strength == 1) color = colors[GREEN];
|
||||
else{
|
||||
if(bricks[i][j]->getColor() == colors[GREEN]) food[i][j] = new GreenFood(bricks[i][j]->getX() , bricks[i][j]->getY());
|
||||
else if(bricks[i][j]->getColor() == colors[PINK]) food[i][j] = new PinkFood(bricks[i][j]->getX() , bricks[i][j]->getY());
|
||||
else if(bricks[i][j]->getColor() == colors[BLUE]) food[i][j] = new BlueFood(bricks[i][j]->getX() , bricks[i][j]->getY());
|
||||
else if(bricks[i][j]->getColor() == colors[RED]) food[i][j] = new RedFood(bricks[i][j]->getX() , bricks[i][j]->getY());
|
||||
else if(bricks[i][j]->getColor() == colors[YELLOW]) food[i][j] = new YellowFood(bricks[i][j]->getX() , bricks[i][j]->getY());
|
||||
delete bricks[i][j];
|
||||
bricks[i][j] = nullptr;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
82
.config/Code/User/History/-605b3219/OyfZ.cpp
Normal file
82
.config/Code/User/History/-605b3219/OyfZ.cpp
Normal file
|
@ -0,0 +1,82 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
// return 0 if didnt collide, 1 if brick broken, 2 if collison but not broken
|
||||
int Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
80
.config/Code/User/History/-605b3219/QVe0.cpp
Normal file
80
.config/Code/User/History/-605b3219/QVe0.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
// return 0 if didnt collide, 1 if brick broken, 2 if collison but not broken
|
||||
int Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else food = new GreenFood(x, y);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
87
.config/Code/User/History/-605b3219/Qcda.cpp
Normal file
87
.config/Code/User/History/-605b3219/Qcda.cpp
Normal file
|
@ -0,0 +1,87 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() <= y+4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
ball.setY(ball.getY()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getY() >= y+height-4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
ball.setY(ball.getY()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() >= x && ball.getX() <= x+4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
ball.setX(ball.getX()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() <= x+width && ball.getX() >= x+width-4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
ball.setX(ball.getX()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]){
|
||||
food = new BlueFood(x+width/2, y);
|
||||
|
||||
}
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
81
.config/Code/User/History/-605b3219/TdlT.cpp
Normal file
81
.config/Code/User/History/-605b3219/TdlT.cpp
Normal file
|
@ -0,0 +1,81 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
// return 0 if didnt collide, 1 if brick broken, 2 if collison but not broken
|
||||
void Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
80
.config/Code/User/History/-605b3219/UMCY.cpp
Normal file
80
.config/Code/User/History/-605b3219/UMCY.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() < y+height/2){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getY() > y+height/2){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() >= x && ball.getX() < x+width/2){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() <= x+width && ball.getX() > x+width/2){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x+width/2, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
82
.config/Code/User/History/-605b3219/WfEw.cpp
Normal file
82
.config/Code/User/History/-605b3219/WfEw.cpp
Normal file
|
@ -0,0 +1,82 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() <= y+4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
ball.setY(ball.getY()/10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getY() >= y+height-4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
ball.setY(ball.getY()/10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() >= x && ball.getX() <= x+4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() <= x+width && ball.getX() >= x+width-4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x+width/2, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
83
.config/Code/User/History/-605b3219/Wp0d.cpp
Normal file
83
.config/Code/User/History/-605b3219/Wp0d.cpp
Normal file
|
@ -0,0 +1,83 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() <= y+4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
ball.setY(ball.getY()/10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getY() >= y+height-4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
ball.setY(ball.getY()/10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() >= x && ball.getX() <= x+4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
ball.setX(ball.getX()/10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() <= x+width && ball.getX() >= x+width-4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x+width/2, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
85
.config/Code/User/History/-605b3219/a08R.cpp
Normal file
85
.config/Code/User/History/-605b3219/a08R.cpp
Normal file
|
@ -0,0 +1,85 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
// return 0 if didnt collide, 1 if brick broken, 2 if collison but not broken
|
||||
int Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
if(food != nullptr){
|
||||
delete food;
|
||||
food = nullptr;
|
||||
}
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
86
.config/Code/User/History/-605b3219/d30c.cpp
Normal file
86
.config/Code/User/History/-605b3219/d30c.cpp
Normal file
|
@ -0,0 +1,86 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
// return 0 if didnt collide, 1 if brick broken, 2 if collison but not broken
|
||||
int Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
|
||||
}
|
||||
else if(strength == 1) color = colors[GREEN];
|
||||
else{
|
||||
if(color == colors[GREEN]) food = new GreenFood(x, y);
|
||||
else if(color == colors[PINK]) food = new PinkFood(x, y);
|
||||
else if(color == colors[BLUE]) food = new BlueFood(x, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x, y);
|
||||
}
|
||||
if(color == colors[GREEN]) food = new GreenFood(x, y);
|
||||
else if(color == colors[PINK]) food = new PinkFood(x, y);
|
||||
else if(color == colors[BLUE]) food = new BlueFood(x, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x, y);
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
1
.config/Code/User/History/-605b3219/entries.json
Normal file
1
.config/Code/User/History/-605b3219/entries.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":1,"resource":"file:///home/rafayahmad/Stuff/OOP/Project/Brick.cpp","entries":[{"id":"sj9w.cpp","timestamp":1714814810108},{"id":"GFY6.cpp","timestamp":1714814828315},{"id":"nqCQ.cpp","timestamp":1714814855104},{"id":"5OMR.cpp","timestamp":1714814877497},{"id":"eqqM.cpp","timestamp":1714814925399},{"id":"ims7.cpp","timestamp":1714814938023},{"id":"xjb0.cpp","timestamp":1714814959090},{"id":"4P8x.cpp","timestamp":1714814977672},{"id":"yO0T.cpp","timestamp":1714814987901},{"id":"d30c.cpp","timestamp":1714815021344},{"id":"gVbU.cpp","timestamp":1714815038304},{"id":"6HTj.cpp","timestamp":1714815066698},{"id":"QVe0.cpp","timestamp":1714815091025},{"id":"OyfZ.cpp","timestamp":1714815106952},{"id":"oSSB.cpp","timestamp":1714815198282},{"id":"a08R.cpp","timestamp":1714815552346},{"id":"37IS.cpp","timestamp":1714815570923},{"id":"TdlT.cpp","timestamp":1714823978578},{"id":"9UJV.cpp","timestamp":1714823994441},{"id":"E1KT.cpp","timestamp":1714824076697},{"id":"6VFU.cpp","timestamp":1714973498921},{"id":"8qNi.cpp","timestamp":1715077847129},{"id":"BCVg.cpp","timestamp":1715092314595},{"id":"yyYN.cpp","timestamp":1715092359837},{"id":"CHLq.cpp","timestamp":1715092379901},{"id":"6BYd.cpp","timestamp":1715092425477},{"id":"F7Xm.cpp","timestamp":1715092506976},{"id":"DD9X.cpp","timestamp":1715092649619},{"id":"tdP7.cpp","timestamp":1715092679902},{"id":"UMCY.cpp","timestamp":1715092716730},{"id":"oH9o.cpp","timestamp":1715138358177},{"id":"scWS.cpp","timestamp":1715138378038},{"id":"5oJy.cpp","timestamp":1715138393011},{"id":"v5JH.cpp","timestamp":1715138409294},{"id":"nsFB.cpp","timestamp":1715138550564},{"id":"ldx1.cpp","timestamp":1715138776281},{"id":"0147.cpp","timestamp":1715138806257},{"id":"WfEw.cpp","timestamp":1715138898243},{"id":"Wp0d.cpp","timestamp":1715138925126},{"id":"6sFc.cpp","timestamp":1715138946059},{"id":"9dBn.cpp","timestamp":1715138962342},{"id":"ux0h.cpp","timestamp":1715145366638},{"id":"f412.cpp","timestamp":1715145392743},{"id":"Qcda.cpp","timestamp":1715145437594},{"id":"EZ6j.cpp","timestamp":1715145572580},{"id":"0rhK.cpp","timestamp":1715145588737},{"id":"tOZb.cpp","timestamp":1715145638483},{"id":"2I7A.cpp","timestamp":1715145654130},{"id":"7BXG.cpp","timestamp":1715145667760},{"id":"Clxq.cpp","timestamp":1715176510591}]}
|
73
.config/Code/User/History/-605b3219/eqqM.cpp
Normal file
73
.config/Code/User/History/-605b3219/eqqM.cpp
Normal file
|
@ -0,0 +1,73 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
// return 0 if didnt collide, 1 if brick broken, 2 if collison but not broken
|
||||
int Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2) color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
else if(strength == 1) color = colors[GREEN];
|
||||
else{ //1
|
||||
if(color == colors[GREEN]) food = new GreenFood(bricks->getX() , bricks->getY());
|
||||
else if(color == colors[PINK]) food = new PinkFood(bricks->getX() , bricks->getY());
|
||||
else if(color == colors[BLUE]) food = new BlueFood(bricks->getX() , bricks->getY());
|
||||
else if(color == colors[RED]) food = new RedFood(bricks->getX() , bricks->getY());
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(bricks->getX() , bricks->getY());
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
87
.config/Code/User/History/-605b3219/f412.cpp
Normal file
87
.config/Code/User/History/-605b3219/f412.cpp
Normal file
|
@ -0,0 +1,87 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() <= y+4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
ball.setY(ball.getY()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getY() >= y+height-4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
ball.setY(ball.getY()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() >= x && ball.getX() <= x+4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
ball.setX(ball.getX()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() <= x+width && ball.getX() >= x+width-4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
ball.setX(ball.getX()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]){
|
||||
food = new BlueFood(x+width/2, y);
|
||||
|
||||
}
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
85
.config/Code/User/History/-605b3219/gVbU.cpp
Normal file
85
.config/Code/User/History/-605b3219/gVbU.cpp
Normal file
|
@ -0,0 +1,85 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
// return 0 if didnt collide, 1 if brick broken, 2 if collison but not broken
|
||||
int Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1) color = colors[GREEN];
|
||||
else{
|
||||
if(color == colors[GREEN]) food = new GreenFood(x, y);
|
||||
else if(color == colors[PINK]) food = new PinkFood(x, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x, y);
|
||||
}
|
||||
if(color == colors[GREEN]) food = new GreenFood(x, y);
|
||||
else if(color == colors[PINK]) food = new PinkFood(x, y);
|
||||
else if(color == colors[BLUE]) food = new BlueFood(x, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x, y);
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
78
.config/Code/User/History/-605b3219/ims7.cpp
Normal file
78
.config/Code/User/History/-605b3219/ims7.cpp
Normal file
|
@ -0,0 +1,78 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
// return 0 if didnt collide, 1 if brick broken, 2 if collison but not broken
|
||||
int Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2) color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
else if(strength == 1) color = colors[GREEN];
|
||||
else{ //1
|
||||
if(color == colors[GREEN]) food = new GreenFood(bricks->getX() , bricks->getY());
|
||||
else if(color == colors[PINK]) food = new PinkFood(bricks->getX() , bricks->getY());
|
||||
else if(color == colors[BLUE]) food = new BlueFood(bricks->getX() , bricks->getY());
|
||||
else if(color == colors[RED]) food = new RedFood(bricks->getX() , bricks->getY());
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(bricks->getX() , bricks->getY());
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
81
.config/Code/User/History/-605b3219/ldx1.cpp
Normal file
81
.config/Code/User/History/-605b3219/ldx1.cpp
Normal file
|
@ -0,0 +1,81 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() <= y+4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getY() >= y+height-4){
|
||||
tVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() >= x && ball.getX() <= x+4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() <= x+width && ball.getX() >= x+width-4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x+width/2, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
80
.config/Code/User/History/-605b3219/nqCQ.cpp
Normal file
80
.config/Code/User/History/-605b3219/nqCQ.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
// return 0 if didnt collide, 1 if brick broken, 2 if collison but not broken
|
||||
int Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2) color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
else if(strength == 1) color = colors[GREEN];
|
||||
else{
|
||||
if(bricks[i][j]->getColor() == colors[GREEN]) food[i][j] = new GreenFood(bricks[i][j]->getX() , bricks[i][j]->getY());
|
||||
else if(bricks[i][j]->getColor() == colors[PINK]) food[i][j] = new PinkFood(bricks[i][j]->getX() , bricks[i][j]->getY());
|
||||
else if(bricks[i][j]->getColor() == colors[BLUE]) food[i][j] = new BlueFood(bricks[i][j]->getX() , bricks[i][j]->getY());
|
||||
else if(bricks[i][j]->getColor() == colors[RED]) food[i][j] = new RedFood(bricks[i][j]->getX() , bricks[i][j]->getY());
|
||||
else if(bricks[i][j]->getColor() == colors[YELLOW]) food[i][j] = new YellowFood(bricks[i][j]->getX() , bricks[i][j]->getY());
|
||||
delete bricks[i][j];
|
||||
bricks[i][j] = nullptr;
|
||||
}
|
||||
if(bricks[i][j]->getColor() == colors[GREEN]) food[i][j] = new GreenFood(bricks[i][j]->getX() , bricks[i][j]->getY());
|
||||
else if(bricks[i][j]->getColor() == colors[PINK]) food[i][j] = new PinkFood(bricks[i][j]->getX() , bricks[i][j]->getY());
|
||||
else if(bricks[i][j]->getColor() == colors[BLUE]) food[i][j] = new BlueFood(bricks[i][j]->getX() , bricks[i][j]->getY());
|
||||
else if(bricks[i][j]->getColor() == colors[RED]) food[i][j] = new RedFood(bricks[i][j]->getX() , bricks[i][j]->getY());
|
||||
else if(bricks[i][j]->getColor() == colors[YELLOW]) food[i][j] = new YellowFood(bricks[i][j]->getX() , bricks[i][j]->getY());
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
80
.config/Code/User/History/-605b3219/nsFB.cpp
Normal file
80
.config/Code/User/History/-605b3219/nsFB.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() <= y+4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getY() >= y+height-4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() >= x && ball.getX() <= x+4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() <= x+width && ball.getX() >= x+width-4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x+width/2, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
80
.config/Code/User/History/-605b3219/oH9o.cpp
Normal file
80
.config/Code/User/History/-605b3219/oH9o.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() <= y+2){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getY() > y+height/2){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() >= x && ball.getX() < x+width/2){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() <= x+width && ball.getX() > x+width/2){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x+width/2, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
82
.config/Code/User/History/-605b3219/oSSB.cpp
Normal file
82
.config/Code/User/History/-605b3219/oSSB.cpp
Normal file
|
@ -0,0 +1,82 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
// return 0 if didnt collide, 1 if brick broken, 2 if collison but not broken
|
||||
int Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
80
.config/Code/User/History/-605b3219/scWS.cpp
Normal file
80
.config/Code/User/History/-605b3219/scWS.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() <= y+2){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getY() >= y+height-2){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() >= x && ball.getX() < x+width/2){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() <= x+width && ball.getX() > x+width/2){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x+width/2, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
69
.config/Code/User/History/-605b3219/sj9w.cpp
Normal file
69
.config/Code/User/History/-605b3219/sj9w.cpp
Normal file
|
@ -0,0 +1,69 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
// return 0 if didnt collide, 1 if brick broken, 2 if collison but not broken
|
||||
int Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2) color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
else if(strength == 1) color = colors[GREEN];
|
||||
else{
|
||||
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
93
.config/Code/User/History/-605b3219/tOZb.cpp
Normal file
93
.config/Code/User/History/-605b3219/tOZb.cpp
Normal file
|
@ -0,0 +1,93 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() <= y+4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
ball.setY(ball.getY()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getY() >= y+height-4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
ball.setY(ball.getY()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() >= x && ball.getX() <= x+4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
ball.setX(ball.getX()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() <= x+width && ball.getX() >= x+width-4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
ball.setX(ball.getX()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]){
|
||||
food = new BlueFood(x+width/2, y);
|
||||
ball.setColor(colors[BLUE]);
|
||||
}
|
||||
else if(color == colors[RED]){
|
||||
food = new RedFood(x+width/2, y);
|
||||
ball.setColor(colors[RED]);
|
||||
}
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]){
|
||||
food = new PinkFood(x+width/2, y);
|
||||
ball.setColor(colors[PINK]);
|
||||
}
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
80
.config/Code/User/History/-605b3219/tdP7.cpp
Normal file
80
.config/Code/User/History/-605b3219/tdP7.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() < y+height/2){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getY() > y+height/2){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x+width/2, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
87
.config/Code/User/History/-605b3219/ux0h.cpp
Normal file
87
.config/Code/User/History/-605b3219/ux0h.cpp
Normal file
|
@ -0,0 +1,87 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() <= y+4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
ball.setY(ball.getY()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getY() >= y+height-4){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
ball.setY(ball.getY()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() >= x && ball.getX() <= x+4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
ball.setX(ball.getX()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() <= x+width && ball.getX() >= x+width-4){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
ball.setX(ball.getX()/10*10);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]){
|
||||
food = new BlueFood(x+width/2, y);
|
||||
|
||||
}
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
80
.config/Code/User/History/-605b3219/v5JH.cpp
Normal file
80
.config/Code/User/History/-605b3219/v5JH.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y && ball.getY() <= y+2){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getY() >= y+height-2){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY() : ball.getVY()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() >= x && ball.getX() <= x+2){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX()*-1 : ball.getVX());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() <= x+width && ball.getX() >= x+width-2){
|
||||
ball.setVX(ball.getVX()>0 ? ball.getVX() : ball.getVX()*-1);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x+width/2, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
78
.config/Code/User/History/-605b3219/xjb0.cpp
Normal file
78
.config/Code/User/History/-605b3219/xjb0.cpp
Normal file
|
@ -0,0 +1,78 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
// return 0 if didnt collide, 1 if brick broken, 2 if collison but not broken
|
||||
int Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2) color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
else if(strength == 1) color = colors[GREEN];
|
||||
else{ //1
|
||||
if(color == colors[GREEN]) food = new GreenFood(x, y);
|
||||
else if(color == colors[PINK]) food = new PinkFood(x, y);
|
||||
else if(color == colors[BLUE]) food = new BlueFood(x, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x, y);
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
83
.config/Code/User/History/-605b3219/yO0T.cpp
Normal file
83
.config/Code/User/History/-605b3219/yO0T.cpp
Normal file
|
@ -0,0 +1,83 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
// return 0 if didnt collide, 1 if brick broken, 2 if collison but not broken
|
||||
int Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() == y){
|
||||
ball.setVY(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() == y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2) color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
else if(strength == 1) color = colors[GREEN];
|
||||
else{
|
||||
if(color == colors[GREEN]) food = new GreenFood(x, y);
|
||||
else if(color == colors[PINK]) food = new PinkFood(x, y);
|
||||
else if(color == colors[BLUE]) food = new BlueFood(x, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x, y);
|
||||
}
|
||||
if(color == colors[GREEN]) food = new GreenFood(x, y);
|
||||
else if(color == colors[PINK]) food = new PinkFood(x, y);
|
||||
else if(color == colors[BLUE]) food = new BlueFood(x, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x, y);
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
80
.config/Code/User/History/-605b3219/yyYN.cpp
Normal file
80
.config/Code/User/History/-605b3219/yyYN.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
#include "Brick.h"
|
||||
#include "util.h"
|
||||
#include "GreenFood.cpp"
|
||||
#include "PinkFood.cpp"
|
||||
#include "BlueFood.cpp"
|
||||
#include "RedFood.cpp"
|
||||
#include "YellowFood.cpp"
|
||||
|
||||
Brick::Brick(){
|
||||
switch(rand()%5){
|
||||
case 0: color = colors[GREEN]; strength = 1; break;
|
||||
case 1: color = colors[PINK]; strength = 2; break;
|
||||
case 2: color = colors[BLUE]; strength = 3; break;
|
||||
case 3: color = colors[RED]; strength = 3; break;
|
||||
case 4: color = colors[YELLOW]; strength = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Brick::draw(int row, int col){
|
||||
x = col*width;
|
||||
y = 340 + row*height;
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
bool Brick::checkCollision(Ball& ball){
|
||||
bool collided = false;
|
||||
if(ball.getX() >= x && ball.getX() < x+width){
|
||||
if(ball.getY() >= y){
|
||||
ball.setVY(ball.getVY()>0 ? ball.getVY()*-1 : ball.getVY());
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getY() <= y+height){
|
||||
ball.setVY(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(ball.getY() >= y && ball.getY() < y+height){
|
||||
if(ball.getX() == x ){
|
||||
ball.setVX(-5);
|
||||
collided = true;
|
||||
}
|
||||
if(ball.getX() == x+width){
|
||||
ball.setVX(5);
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
if(collided){
|
||||
strength--;
|
||||
if(strength == 2){
|
||||
if(color == colors[BLUE]) food = new BlueFood(x+width/2, y);
|
||||
else if(color == colors[RED]) food = new RedFood(x+width/2, y);
|
||||
color = rand()%2 ? colors[PINK] : colors[YELLOW];
|
||||
}
|
||||
else if(strength == 1){
|
||||
if(color == colors[PINK]) food = new PinkFood(x+width/2, y);
|
||||
else if(color == colors[YELLOW]) food = new YellowFood(x+width/2, y);
|
||||
color = colors[GREEN];
|
||||
}
|
||||
else{
|
||||
food = new GreenFood(x+width/2, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Brick::getX(){
|
||||
return x;
|
||||
}
|
||||
int Brick::getY(){
|
||||
return y;
|
||||
}
|
||||
float* Brick::getColor(){
|
||||
return color;
|
||||
}
|
||||
Food* Brick::getFood(){
|
||||
return food;
|
||||
}
|
||||
|
||||
Brick::~Brick(){}
|
Loading…
Add table
Add a link
Reference in a new issue