test
This commit is contained in:
parent
37776af5db
commit
ab03d5f10c
4045 changed files with 286212 additions and 3 deletions
24
.config/Code/User/History/a91b7ce/04sU.cpp
Normal file
24
.config/Code/User/History/a91b7ce/04sU.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY()-ball.getRadius() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
39
.config/Code/User/History/a91b7ce/0S68.cpp
Normal file
39
.config/Code/User/History/a91b7ce/0S68.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
int Paddle::getX(){
|
||||
return x;
|
||||
}
|
||||
int Paddle::getY(){
|
||||
return y;
|
||||
}
|
||||
int Paddle::getWidth(){
|
||||
return width;
|
||||
}
|
||||
int Paddle::getHeight(){
|
||||
return height;
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){}
|
36
.config/Code/User/History/a91b7ce/0xWD.cpp
Normal file
36
.config/Code/User/History/a91b7ce/0xWD.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x){
|
||||
// color = new float[3];
|
||||
color = other.color;
|
||||
}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
// y = 5, 5, 2.5
|
||||
// x = 0, 5, 5/2 sqrt3
|
||||
int vx, vy;
|
||||
switch(rand()%3){
|
||||
case 0: vx = 0; vy = 5; break;
|
||||
case 1: vx = 5; vy = 5; break;
|
||||
case 4: vx = 5/2 * sqrt(3); vy = 5/2; break;
|
||||
}
|
||||
vx *= ball.getVX()>0 ? -1 : 1;
|
||||
if(ball.getY() - ball.getRadius() <= y+height && ball.getX()-ball.getRadius() >= x && ball.getX()+ball.getRadius() < x+width) ball.setVY(y);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(x);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < 10 + width/2) this->x = 10;
|
||||
else if(x > 1010 - width/2) this->x = 1010 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
28
.config/Code/User/History/a91b7ce/1VNp.cpp
Normal file
28
.config/Code/User/History/a91b7ce/1VNp.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){
|
||||
// delete color;
|
||||
}
|
36
.config/Code/User/History/a91b7ce/2adX.cpp
Normal file
36
.config/Code/User/History/a91b7ce/2adX.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x){
|
||||
// color = new float[3];
|
||||
color = other.color;
|
||||
}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
// y = 5, 5, 2.5
|
||||
// x = 0, 5, 5/2 sqrt3
|
||||
int vx, vy;
|
||||
switch(rand()%3){
|
||||
case 0: vx = 0; vy = 5; break;
|
||||
case 1: vx = 5; vy = 5; break;
|
||||
case 2: vx = 5/2 * sqrt(3); vy = 5/2; break;
|
||||
}
|
||||
vx *= ball.getVX()>0 ? -1 : 1;
|
||||
if(ball.getY() - ball.getRadius() <= y+height && ball.getX()-ball.getRadius() >= x && ball.getX()+ball.getRadius() < x+width) ball.setVY(vy);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(vx);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < 10 + width/2) this->x = 10;
|
||||
else if(x > 1010 - width/2) this->x = 1010 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
24
.config/Code/User/History/a91b7ce/2jXH.cpp
Normal file
24
.config/Code/User/History/a91b7ce/2jXH.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
36
.config/Code/User/History/a91b7ce/3A4q.cpp
Normal file
36
.config/Code/User/History/a91b7ce/3A4q.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x){
|
||||
// color = new float[3];
|
||||
color = other.color;
|
||||
}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
// y = 5, 5, 2.5
|
||||
// x = 0, 5, 5/2 sqrt3
|
||||
int vx, vy;
|
||||
switch(rand()%3){
|
||||
case 0: vx = 0; vy = 5; break;
|
||||
case 1: vx = 5; vy = 5; break;
|
||||
case 2: vx = 5/2 * sqrt(3); vy = 5/2; break;
|
||||
}
|
||||
vx *= ball.getVX()>0 ? -1 : 1;
|
||||
if(ball.getY() - ball.getRadius() <= y+height && ball.getX()-ball.getRadius() >= x && ball.getX()+ball.getRadius() < x+width) ball.setVY(y);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(x);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < 10 + width/2) this->x = 10;
|
||||
else if(x > 1010 - width/2) this->x = 1010 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
36
.config/Code/User/History/a91b7ce/5MJC.cpp
Normal file
36
.config/Code/User/History/a91b7ce/5MJC.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x){
|
||||
// color = new float[3];
|
||||
color = other.color;
|
||||
}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
// y = 5, 5, 2.5
|
||||
// x = 0, 5, 5/2 sqrt3
|
||||
// int vx, vy;
|
||||
// switch(rand()%3){
|
||||
// case 0: vx = 0; vy = 5; break;
|
||||
// case 1: vx = 5; vy = 5; break;
|
||||
// case 2: vx = 5/2 * sqrt(3); vy = 5/2; break;
|
||||
// }
|
||||
// vx *= ball.getVX()>0 ? -1 : 1;
|
||||
if(ball.getY() - ball.getRadius() <= y+height && ball.getX()-ball.getRadius() >= x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
35
.config/Code/User/History/a91b7ce/5WyT.cpp
Normal file
35
.config/Code/User/History/a91b7ce/5WyT.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x){
|
||||
// color = new float[3];
|
||||
color = other.color;
|
||||
}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
// y = 5, 5, 2.5
|
||||
// x = 0, 5, 5/2 sqrt3
|
||||
int x, y;
|
||||
switch(rand()%3){
|
||||
case 0: x = 0; y = 5; break;
|
||||
case 1: x = 5; y = 5; break;
|
||||
case 2: x = 5/2 * sqrt(3); y = 5/2; break;
|
||||
}
|
||||
if(ball.getY() - ball.getRadius() <= y+height && ball.getX()-ball.getRadius() >= x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1-random);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < 10 + width/2) this->x = 10;
|
||||
else if(x > 1010 - width/2) this->x = 1010 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
36
.config/Code/User/History/a91b7ce/5q1D.cpp
Normal file
36
.config/Code/User/History/a91b7ce/5q1D.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x){
|
||||
// color = new float[3];
|
||||
color = other.color;
|
||||
}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
// y = 5, 5, 2.5
|
||||
// x = 0, 5, 5/2 sqrt3
|
||||
// int vx, vy;
|
||||
// switch(rand()%3){
|
||||
// case 0: vx = 0; vy = 5; break;
|
||||
// case 1: vx = 5; vy = 5; break;
|
||||
// case 2: vx = 5/2 * sqrt(3); vy = 5/2; break;
|
||||
// }
|
||||
// vx *= ball.getVX()>0 ? -1 : 1;
|
||||
if(ball.getY() - ball.getRadius() <= y+height && ball.getX()-ball.getRadius() >= x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1020 - width/2) this->x = 1020 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
36
.config/Code/User/History/a91b7ce/7K7X.cpp
Normal file
36
.config/Code/User/History/a91b7ce/7K7X.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x){
|
||||
// color = new float[3];
|
||||
color = other.color;
|
||||
}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
// y = 5, 5, 2.5
|
||||
// x = 0, 5, 5/2 sqrt3
|
||||
int vx, vy;
|
||||
switch(rand()%3){
|
||||
case 0: vx = 0; vy = 5; break;
|
||||
case 1: vx = 5; vy = 5; break;
|
||||
// case 4: vx = 5/2 * sqrt(3); vy = 5/2; break;
|
||||
}
|
||||
vx *= ball.getVX()>0 ? -1 : 1;
|
||||
if(ball.getY() - ball.getRadius() <= y+height && ball.getX()-ball.getRadius() >= x && ball.getX()+ball.getRadius() < x+width) ball.setVY(y);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(x);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < 10 + width/2) this->x = 10;
|
||||
else if(x > 1010 - width/2) this->x = 1010 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
36
.config/Code/User/History/a91b7ce/7Qai.cpp
Normal file
36
.config/Code/User/History/a91b7ce/7Qai.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x){
|
||||
// color = new float[3];
|
||||
color = other.color;
|
||||
}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
// y = 5, 5, 2.5
|
||||
// x = 0, 5, 5/2 sqrt3
|
||||
int x, y;
|
||||
switch(rand()%3){
|
||||
case 0: x = 0; y = 5; break;
|
||||
case 1: x = 5; y = 5; break;
|
||||
case 2: x = 5/2 * sqrt(3); y = 5/2; break;
|
||||
}
|
||||
x *= ball.getVX()>0 ? -1 : 1;
|
||||
if(ball.getY() - ball.getRadius() <= y+height && ball.getX()-ball.getRadius() >= x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1-random);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < 10 + width/2) this->x = 10;
|
||||
else if(x > 1010 - width/2) this->x = 1010 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
60
.config/Code/User/History/a91b7ce/8iMb.cpp
Normal file
60
.config/Code/User/History/a91b7ce/8iMb.cpp
Normal file
|
@ -0,0 +1,60 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, int y, float *color) : height(20), y(y), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
//TODO: Redo Collisoin
|
||||
|
||||
|
||||
if(ball.getX() >= x && ball.getX() <= x+width){
|
||||
if(ball.getY()+ball.getRadius() >= y && ball.getY()+ball.getRadius() <= y+4){
|
||||
|
||||
}
|
||||
else if(ball.getY()-ball.getRadius() <= y+height && ball.getY()+ball.getRadius() <= y-4){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width){
|
||||
// ball.setVY(ball.getVY()*-1);
|
||||
// color = ball.getColor()
|
||||
// }
|
||||
// if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
// //TODO: game over screen
|
||||
// if(ball.getY() < 0) ball.setVY(ball.getVY()*-1);
|
||||
}
|
||||
|
||||
int Paddle::getX(){
|
||||
return x;
|
||||
}
|
||||
int Paddle::getY(){
|
||||
return y;
|
||||
}
|
||||
int Paddle::getWidth(){
|
||||
return width;
|
||||
}
|
||||
int Paddle::getHeight(){
|
||||
return height;
|
||||
}
|
||||
|
||||
Paddle& Paddle::setWidth(int width){
|
||||
this->width = width;
|
||||
return *this;
|
||||
}
|
||||
Paddle& Paddle::setX(int x){
|
||||
// if(x < width/2) this->x = 0;
|
||||
// else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
// else this->x = x - width/2;
|
||||
this->x = x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){}
|
55
.config/Code/User/History/a91b7ce/B0DW.cpp
Normal file
55
.config/Code/User/History/a91b7ce/B0DW.cpp
Normal file
|
@ -0,0 +1,55 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, int y, float *color) : height(20), y(y), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
//TODO: Redo Collisoin
|
||||
|
||||
|
||||
if(ball.getX() >= x && ball.getX() <= x+width){
|
||||
|
||||
}
|
||||
|
||||
|
||||
// if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width){
|
||||
// ball.setVY(ball.getVY()*-1);
|
||||
// color = ball.getColor();
|
||||
// }
|
||||
// if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
// //TODO: game over screen
|
||||
// if(ball.getY() < 0) ball.setVY(ball.getVY()*-1);
|
||||
}
|
||||
|
||||
int Paddle::getX(){
|
||||
return x;
|
||||
}
|
||||
int Paddle::getY(){
|
||||
return y;
|
||||
}
|
||||
int Paddle::getWidth(){
|
||||
return width;
|
||||
}
|
||||
int Paddle::getHeight(){
|
||||
return height;
|
||||
}
|
||||
|
||||
Paddle& Paddle::setWidth(int width){
|
||||
this->width = width;
|
||||
return *this;
|
||||
}
|
||||
Paddle& Paddle::setX(int x){
|
||||
// if(x < width/2) this->x = 0;
|
||||
// else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
// else this->x = x - width/2;
|
||||
this->x = x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){}
|
60
.config/Code/User/History/a91b7ce/CXIf.cpp
Normal file
60
.config/Code/User/History/a91b7ce/CXIf.cpp
Normal file
|
@ -0,0 +1,60 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, int y, float *color) : height(20), y(y), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
//TODO: Redo Collisoin
|
||||
|
||||
|
||||
if(ball.getX() >= x && ball.getX() <= x+width){
|
||||
if(ball.getY()+ball.getRadius() >= y && ball.getY()+ball.getRadius() <= y+4){
|
||||
|
||||
}
|
||||
else if(ball.getY()-ball.getRadius() <= y+height && ball.getY()+ball.getRadius() <= y-4){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width){
|
||||
// ball.setVY(ball.getVY()*-1);
|
||||
// color = ball.getColor()
|
||||
// }
|
||||
// if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
// //TODO: game over screen
|
||||
// if(ball.getY() < 0) ball.setVY(ball.getVY()*-1);
|
||||
}
|
||||
|
||||
int Paddle::getX(){
|
||||
return x;
|
||||
}
|
||||
int Paddle::getY(){
|
||||
return y;
|
||||
}
|
||||
int Paddle::getWidth(){
|
||||
return width;
|
||||
}
|
||||
int Paddle::getHeight(){
|
||||
return height;
|
||||
}
|
||||
|
||||
Paddle& Paddle::setWidth(int width){
|
||||
this->width = width;
|
||||
return *this;
|
||||
}
|
||||
Paddle& Paddle::setX(int x){
|
||||
// if(x < width/2) this->x = 0;
|
||||
// else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
// else this->x = x - width/2;
|
||||
this->x = x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){}
|
36
.config/Code/User/History/a91b7ce/D3xr.cpp
Normal file
36
.config/Code/User/History/a91b7ce/D3xr.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x){
|
||||
// color = new float[3];
|
||||
color = other.color;
|
||||
}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
// y = 5, 5, 2.5
|
||||
// x = 0, 5, 5/2 sqrt3
|
||||
int vx, vy;
|
||||
switch(rand()%3){
|
||||
case 0: x = 0; y = 5; break;
|
||||
case 1: x = 5; y = 5; break;
|
||||
case 2: x = 5/2 * sqrt(3); y = 5/2; break;
|
||||
}
|
||||
x *= ball.getVX()>0 ? -1 : 1;
|
||||
if(ball.getY() - ball.getRadius() <= y+height && ball.getX()-ball.getRadius() >= x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < 10 + width/2) this->x = 10;
|
||||
else if(x > 1010 - width/2) this->x = 1010 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
24
.config/Code/User/History/a91b7ce/DFtM.cpp
Normal file
24
.config/Code/User/History/a91b7ce/DFtM.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
if(ball.getY() - ball.getRadius() <= y+height && ball.getX()-ball.getRadius() >= x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
36
.config/Code/User/History/a91b7ce/F9Q0.cpp
Normal file
36
.config/Code/User/History/a91b7ce/F9Q0.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x){
|
||||
// color = new float[3];
|
||||
color = other.color;
|
||||
}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
// y = 5, 5, 2.5
|
||||
// x = 0, 5, 5/2 sqrt3
|
||||
int x, y;
|
||||
switch(rand()%3){
|
||||
case 0: x = 0; y = 5; break;
|
||||
case 1: x = 5; y = 5; break;
|
||||
case 2: x = 5/2 * sqrt(3); y = 5/2; break;
|
||||
}
|
||||
x *= ball.getVX()>0 ? -1 : 1;
|
||||
if(ball.getY() - ball.getRadius() <= y+height && ball.getX()-ball.getRadius() >= x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < 10 + width/2) this->x = 10;
|
||||
else if(x > 1010 - width/2) this->x = 1010 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
58
.config/Code/User/History/a91b7ce/G3YE.cpp
Normal file
58
.config/Code/User/History/a91b7ce/G3YE.cpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, int y, float *color) : height(20), y(y), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
//TODO: Redo Collisoin
|
||||
|
||||
|
||||
if(ball.getX() >= x && ball.getX() <= x+width){
|
||||
if(ball.getY()+ball.getRadius() >= y && ball.getY()+ball.getRadius() <= y+4){
|
||||
|
||||
}
|
||||
else if(ball.getY())
|
||||
}
|
||||
|
||||
|
||||
// if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width){
|
||||
// ball.setVY(ball.getVY()*-1);
|
||||
// color = ball.getColor()
|
||||
// }
|
||||
// if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
// //TODO: game over screen
|
||||
// if(ball.getY() < 0) ball.setVY(ball.getVY()*-1);
|
||||
}
|
||||
|
||||
int Paddle::getX(){
|
||||
return x;
|
||||
}
|
||||
int Paddle::getY(){
|
||||
return y;
|
||||
}
|
||||
int Paddle::getWidth(){
|
||||
return width;
|
||||
}
|
||||
int Paddle::getHeight(){
|
||||
return height;
|
||||
}
|
||||
|
||||
Paddle& Paddle::setWidth(int width){
|
||||
this->width = width;
|
||||
return *this;
|
||||
}
|
||||
Paddle& Paddle::setX(int x){
|
||||
// if(x < width/2) this->x = 0;
|
||||
// else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
// else this->x = x - width/2;
|
||||
this->x = x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){}
|
46
.config/Code/User/History/a91b7ce/KLQU.cpp
Normal file
46
.config/Code/User/History/a91b7ce/KLQU.cpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
//TODO: Redo Collisoin
|
||||
if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width){
|
||||
ball.setVY(ball.getVY()*-1);
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) ball.setVY(ball.getVY()*-1);
|
||||
}
|
||||
|
||||
int Paddle::getX(){
|
||||
return x;
|
||||
}
|
||||
int Paddle::getY(){
|
||||
return y;
|
||||
}
|
||||
int Paddle::getWidth(){
|
||||
return width;
|
||||
}
|
||||
int Paddle::getHeight(){
|
||||
return height;
|
||||
}
|
||||
|
||||
Paddle& Paddle::setWidth(int width){
|
||||
this->width = width;
|
||||
return *this;
|
||||
}
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){}
|
43
.config/Code/User/History/a91b7ce/KPLX.cpp
Normal file
43
.config/Code/User/History/a91b7ce/KPLX.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) ball.setVY(ball.getVY()*-1);
|
||||
}
|
||||
|
||||
int Paddle::getX(){
|
||||
return x;
|
||||
}
|
||||
int Paddle::getY(){
|
||||
return y;
|
||||
}
|
||||
int Paddle::getWidth(){
|
||||
return width;
|
||||
}
|
||||
int Paddle::getHeight(){
|
||||
return height;
|
||||
}
|
||||
|
||||
Paddle& Paddle::setWidth(int width){
|
||||
this->width = width;
|
||||
return *this;
|
||||
}
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){}
|
47
.config/Code/User/History/a91b7ce/NBMe.cpp
Normal file
47
.config/Code/User/History/a91b7ce/NBMe.cpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
//TODO: Redo Collisoin
|
||||
if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width){
|
||||
ball.setVY(ball.getVY()*-1);
|
||||
color
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) ball.setVY(ball.getVY()*-1);
|
||||
}
|
||||
|
||||
int Paddle::getX(){
|
||||
return x;
|
||||
}
|
||||
int Paddle::getY(){
|
||||
return y;
|
||||
}
|
||||
int Paddle::getWidth(){
|
||||
return width;
|
||||
}
|
||||
int Paddle::getHeight(){
|
||||
return height;
|
||||
}
|
||||
|
||||
Paddle& Paddle::setWidth(int width){
|
||||
this->width = width;
|
||||
return *this;
|
||||
}
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){}
|
36
.config/Code/User/History/a91b7ce/NNgM.cpp
Normal file
36
.config/Code/User/History/a91b7ce/NNgM.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x){
|
||||
// color = new float[3];
|
||||
color = other.color;
|
||||
}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
// y = 5, 5, 2.5
|
||||
// x = 0, 5, 5/2 sqrt3
|
||||
int x, y;
|
||||
switch(rand()%3){
|
||||
case 0: x = 0; y = 5; break;
|
||||
case 1: x = 5; y = 5; break;
|
||||
case 2: x = 5/2 * sqrt(3); y = 5/2; break;
|
||||
}
|
||||
x *= ball.getVX()>0 ? -1 : 1;
|
||||
if(ball.getY() - ball.getRadius() <= y+height && ball.getX()-ball.getRadius() >= x && ball.getX()+ball.getRadius() < x+width) ball.setVY(y);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(x);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < 10 + width/2) this->x = 10;
|
||||
else if(x > 1010 - width/2) this->x = 1010 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
43
.config/Code/User/History/a91b7ce/O0Js.cpp
Normal file
43
.config/Code/User/History/a91b7ce/O0Js.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
int Paddle::getX(){
|
||||
return x;
|
||||
}
|
||||
int Paddle::getY(){
|
||||
return y;
|
||||
}
|
||||
int Paddle::getWidth(){
|
||||
return width;
|
||||
}
|
||||
int Paddle::getHeight(){
|
||||
return height;
|
||||
}
|
||||
|
||||
Paddle& Paddle::setWidth(int width){
|
||||
this->width = width;
|
||||
return *this;
|
||||
}
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){}
|
24
.config/Code/User/History/a91b7ce/Odpa.cpp
Normal file
24
.config/Code/User/History/a91b7ce/Odpa.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
44
.config/Code/User/History/a91b7ce/Q4Ur.cpp
Normal file
44
.config/Code/User/History/a91b7ce/Q4Ur.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
//TODO: Redo Collisoin
|
||||
if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) ball.setVY(ball.getVY()*-1);
|
||||
}
|
||||
|
||||
int Paddle::getX(){
|
||||
return x;
|
||||
}
|
||||
int Paddle::getY(){
|
||||
return y;
|
||||
}
|
||||
int Paddle::getWidth(){
|
||||
return width;
|
||||
}
|
||||
int Paddle::getHeight(){
|
||||
return height;
|
||||
}
|
||||
|
||||
Paddle& Paddle::setWidth(int width){
|
||||
this->width = width;
|
||||
return *this;
|
||||
}
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){}
|
47
.config/Code/User/History/a91b7ce/THu2.cpp
Normal file
47
.config/Code/User/History/a91b7ce/THu2.cpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, int y, float *color) : height(20), y(y), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
//TODO: Redo Collisoin
|
||||
if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width){
|
||||
ball.setVY(ball.getVY()*-1);
|
||||
color = ball.getColor();
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) ball.setVY(ball.getVY()*-1);
|
||||
}
|
||||
|
||||
int Paddle::getX(){
|
||||
return x;
|
||||
}
|
||||
int Paddle::getY(){
|
||||
return y;
|
||||
}
|
||||
int Paddle::getWidth(){
|
||||
return width;
|
||||
}
|
||||
int Paddle::getHeight(){
|
||||
return height;
|
||||
}
|
||||
|
||||
Paddle& Paddle::setWidth(int width){
|
||||
this->width = width;
|
||||
return *this;
|
||||
}
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){}
|
27
.config/Code/User/History/a91b7ce/Ugos.cpp
Normal file
27
.config/Code/User/History/a91b7ce/Ugos.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x){
|
||||
// color = new float[3];
|
||||
color = other.color;
|
||||
}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
if(ball.getY() - ball.getRadius() <= y+height && ball.getX()-ball.getRadius() >= x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
42
.config/Code/User/History/a91b7ce/XsFa.cpp
Normal file
42
.config/Code/User/History/a91b7ce/XsFa.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
int Paddle::getX(){
|
||||
return x;
|
||||
}
|
||||
int Paddle::getY(){
|
||||
return y;
|
||||
}
|
||||
int Paddle::getWidth(){
|
||||
return width;
|
||||
}
|
||||
int Paddle::getHeight(){
|
||||
return height;
|
||||
}
|
||||
|
||||
Paddle& Paddle::setWidth(int width){
|
||||
this->width = width;
|
||||
}
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){}
|
36
.config/Code/User/History/a91b7ce/YpU9.cpp
Normal file
36
.config/Code/User/History/a91b7ce/YpU9.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x){
|
||||
// color = new float[3];
|
||||
color = other.color;
|
||||
}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
// y = 5, 5, 2.5
|
||||
// x = 0, 5, 5/2 sqrt3
|
||||
int x, y;
|
||||
switch(rand()%3){
|
||||
case 0: x = 0; y = 5; break;
|
||||
case 1: x = 5; y = 5; break;
|
||||
case 2: x = 5/2 * sqrt(3); y = 5/2; break;
|
||||
}
|
||||
x *= ball.getVX()>0 ? -1 : 1;
|
||||
if(ball.getY() - ball.getRadius() <= y+height && ball.getX()-ball.getRadius() >= x && ball.getX()+ball.getRadius() < x+width) ball.setVY(-1 * y);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(x);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < 10 + width/2) this->x = 10;
|
||||
else if(x > 1010 - width/2) this->x = 1010 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
28
.config/Code/User/History/a91b7ce/aMJd.cpp
Normal file
28
.config/Code/User/History/a91b7ce/aMJd.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Paddle::~Paddle(){
|
||||
// delete color;
|
||||
// }
|
24
.config/Code/User/History/a91b7ce/bXxD.cpp
Normal file
24
.config/Code/User/History/a91b7ce/bXxD.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
if(ball.getY()-ball.getRadius() <= y+height && ball.getX()-ball.getRadius() >= x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
1
.config/Code/User/History/a91b7ce/entries.json
Normal file
1
.config/Code/User/History/a91b7ce/entries.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":1,"resource":"file:///home/rafayahmad/Stuff/OOP/Project/Paddle.cpp","entries":[{"id":"5WyT.cpp","timestamp":1714539275035},{"id":"7Qai.cpp","timestamp":1714539344292},{"id":"qqmp.cpp","timestamp":1714539360759},{"id":"YpU9.cpp","timestamp":1714539402620},{"id":"NNgM.cpp","timestamp":1714539427683},{"id":"ifvi.cpp","timestamp":1714539504094},{"id":"F9Q0.cpp","timestamp":1714539526401},{"id":"D3xr.cpp","timestamp":1714539555301},{"id":"3A4q.cpp","timestamp":1714539597397},{"id":"0xWD.cpp","timestamp":1714539735465},{"id":"7K7X.cpp","timestamp":1714539762397},{"id":"vdFJ.cpp","timestamp":1714539781990},{"id":"2adX.cpp","timestamp":1714540647029},{"id":"lAkT.cpp","timestamp":1714540752445},{"id":"mbeH.cpp","timestamp":1714540763618},{"id":"5q1D.cpp","timestamp":1714541559216},{"id":"5MJC.cpp","timestamp":1714616120206},{"id":"Ugos.cpp","timestamp":1714617314903},{"id":"DFtM.cpp","timestamp":1714617336150},{"id":"bXxD.cpp","timestamp":1714654800035},{"id":"Odpa.cpp","timestamp":1714654885176},{"id":"04sU.cpp","timestamp":1714657128644},{"id":"kPIl.cpp","timestamp":1714657148654},{"id":"taDs.cpp","timestamp":1714657227115},{"id":"tVWW.cpp","timestamp":1714657300310},{"id":"2jXH.cpp","timestamp":1714657585803},{"id":"gUv1.cpp","timestamp":1714700175605},{"id":"aMJd.cpp","timestamp":1714700273269},{"id":"1VNp.cpp","timestamp":1714700409175},{"id":"zuPC.cpp","timestamp":1714700638702},{"id":"xZ39.cpp","timestamp":1714822774685},{"id":"0S68.cpp","timestamp":1714822853819},{"id":"XsFa.cpp","timestamp":1714889006956},{"id":"O0Js.cpp","timestamp":1714889464396},{"id":"lxQw.cpp","timestamp":1714890149716},{"id":"KPLX.cpp","timestamp":1715093187632},{"id":"Q4Ur.cpp","timestamp":1715093979719},{"id":"KLQU.cpp","timestamp":1715145793197},{"id":"NBMe.cpp","timestamp":1715145804796},{"id":"uJGn.cpp","timestamp":1715145819288},{"id":"THu2.cpp","timestamp":1715160430725},{"id":"lmcp.cpp","timestamp":1715162788677},{"id":"B0DW.cpp","timestamp":1715178753175},{"id":"fHa3.cpp","timestamp":1715178802042},{"id":"zrg3.cpp","timestamp":1715178825751},{"id":"G3YE.cpp","timestamp":1715178848224},{"id":"CXIf.cpp","timestamp":1715178885685},{"id":"8iMb.cpp","timestamp":1715178913102},{"id":"vEKv.cpp","timestamp":1715178951750},{"id":"lDIq.cpp","timestamp":1715179670593}]}
|
55
.config/Code/User/History/a91b7ce/fHa3.cpp
Normal file
55
.config/Code/User/History/a91b7ce/fHa3.cpp
Normal file
|
@ -0,0 +1,55 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, int y, float *color) : height(20), y(y), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
//TODO: Redo Collisoin
|
||||
|
||||
|
||||
if(ball.getX() >= x && ball.getX() <= x+width){
|
||||
if(ball.getY()-ball.getRadius() >= y && ball.getY() <= y+4)
|
||||
}
|
||||
|
||||
|
||||
// if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width){
|
||||
// ball.setVY(ball.getVY()*-1);
|
||||
// color = ball.getColor()
|
||||
// }
|
||||
// if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
// //TODO: game over screen
|
||||
// if(ball.getY() < 0) ball.setVY(ball.getVY()*-1);
|
||||
}
|
||||
|
||||
int Paddle::getX(){
|
||||
return x;
|
||||
}
|
||||
int Paddle::getY(){
|
||||
return y;
|
||||
}
|
||||
int Paddle::getWidth(){
|
||||
return width;
|
||||
}
|
||||
int Paddle::getHeight(){
|
||||
return height;
|
||||
}
|
||||
|
||||
Paddle& Paddle::setWidth(int width){
|
||||
this->width = width;
|
||||
return *this;
|
||||
}
|
||||
Paddle& Paddle::setX(int x){
|
||||
// if(x < width/2) this->x = 0;
|
||||
// else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
// else this->x = x - width/2;
|
||||
this->x = x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){}
|
28
.config/Code/User/History/a91b7ce/gUv1.cpp
Normal file
28
.config/Code/User/History/a91b7ce/gUv1.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){
|
||||
delete color;
|
||||
}
|
36
.config/Code/User/History/a91b7ce/ifvi.cpp
Normal file
36
.config/Code/User/History/a91b7ce/ifvi.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x){
|
||||
// color = new float[3];
|
||||
color = other.color;
|
||||
}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
// y = 5, 5, 2.5
|
||||
// x = 0, 5, 5/2 sqrt3
|
||||
int x, y;
|
||||
switch(rand()%3){
|
||||
case 0: x = 0; y = 5; break;
|
||||
case 1: x = 5; y = 5; break;
|
||||
case 2: x = 5/2 * sqrt(3); y = 5/2; break;
|
||||
}
|
||||
x *= ball.getVX()>0 ? -1 : 1;
|
||||
if(ball.getY() - ball.getRadius() <= y+height && ball.getX()-ball.getRadius() >= x && ball.getX()+ball.getRadius() < x+width) {ball.setVY(y); cout<<111;}
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(x);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < 10 + width/2) this->x = 10;
|
||||
else if(x > 1010 - width/2) this->x = 1010 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
24
.config/Code/User/History/a91b7ce/kPIl.cpp
Normal file
24
.config/Code/User/History/a91b7ce/kPIl.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY()-ball.getRadius() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
36
.config/Code/User/History/a91b7ce/lAkT.cpp
Normal file
36
.config/Code/User/History/a91b7ce/lAkT.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x){
|
||||
// color = new float[3];
|
||||
color = other.color;
|
||||
}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
// y = 5, 5, 2.5
|
||||
// x = 0, 5, 5/2 sqrt3
|
||||
int vx, vy;
|
||||
switch(rand()%3){
|
||||
case 0: vx = 0; vy = 5; break;
|
||||
case 1: vx = 5; vy = 5; break;
|
||||
case 2: vx = 5/2 * sqrt(3); vy = 5/2; break;
|
||||
}
|
||||
vx *= ball.getVX()>0 ? -1 : 1;
|
||||
if(ball.getY() - ball.getRadius() <= y+height && ball.getX()-ball.getRadius() >= x && ball.getX()+ball.getRadius() < x+width) ball.setVY(vy);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(vx);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1010 - width/2) this->x = 1010 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
64
.config/Code/User/History/a91b7ce/lDIq.cpp
Normal file
64
.config/Code/User/History/a91b7ce/lDIq.cpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, int y, float *color) : height(20), y(y), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
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);
|
||||
color = ball.getColor();
|
||||
}
|
||||
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);
|
||||
color = ball.getColor();
|
||||
}
|
||||
}
|
||||
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);
|
||||
color = ball.getColor();
|
||||
}
|
||||
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);
|
||||
color = ball.getColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int Paddle::getX(){
|
||||
return x;
|
||||
}
|
||||
int Paddle::getY(){
|
||||
return y;
|
||||
}
|
||||
int Paddle::getWidth(){
|
||||
return width;
|
||||
}
|
||||
int Paddle::getHeight(){
|
||||
return height;
|
||||
}
|
||||
|
||||
Paddle& Paddle::setWidth(int width){
|
||||
this->width = width;
|
||||
return *this;
|
||||
}
|
||||
Paddle& Paddle::setX(int x){
|
||||
// if(x < width/2) this->x = 0;
|
||||
// else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
// else this->x = x - width/2;
|
||||
this->x = x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){}
|
48
.config/Code/User/History/a91b7ce/lmcp.cpp
Normal file
48
.config/Code/User/History/a91b7ce/lmcp.cpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, int y, float *color) : height(20), y(y), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
//TODO: Redo Collisoin
|
||||
if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width){
|
||||
ball.setVY(ball.getVY()*-1);
|
||||
color = ball.getColor();
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) ball.setVY(ball.getVY()*-1);
|
||||
}
|
||||
|
||||
int Paddle::getX(){
|
||||
return x;
|
||||
}
|
||||
int Paddle::getY(){
|
||||
return y;
|
||||
}
|
||||
int Paddle::getWidth(){
|
||||
return width;
|
||||
}
|
||||
int Paddle::getHeight(){
|
||||
return height;
|
||||
}
|
||||
|
||||
Paddle& Paddle::setWidth(int width){
|
||||
this->width = width;
|
||||
return *this;
|
||||
}
|
||||
Paddle& Paddle::setX(int x){
|
||||
// if(x < width/2) this->x = 0;
|
||||
// else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
// else this->x = x - width/2;
|
||||
this->x = x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){}
|
43
.config/Code/User/History/a91b7ce/lxQw.cpp
Normal file
43
.config/Code/User/History/a91b7ce/lxQw.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) ball.setVY(ball.getVY()*-1);
|
||||
}
|
||||
|
||||
int Paddle::getX(){
|
||||
return x;
|
||||
}
|
||||
int Paddle::getY(){
|
||||
return y;
|
||||
}
|
||||
int Paddle::getWidth(){
|
||||
return width;
|
||||
}
|
||||
int Paddle::getHeight(){
|
||||
return height;
|
||||
}
|
||||
|
||||
Paddle& Paddle::setWidth(int width){
|
||||
this->width = width;
|
||||
return *this;
|
||||
}
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){}
|
36
.config/Code/User/History/a91b7ce/mbeH.cpp
Normal file
36
.config/Code/User/History/a91b7ce/mbeH.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x){
|
||||
// color = new float[3];
|
||||
color = other.color;
|
||||
}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
// y = 5, 5, 2.5
|
||||
// x = 0, 5, 5/2 sqrt3
|
||||
int vx, vy;
|
||||
switch(rand()%3){
|
||||
case 0: vx = 0; vy = 5; break;
|
||||
case 1: vx = 5; vy = 5; break;
|
||||
case 2: vx = 5/2 * sqrt(3); vy = 5/2; break;
|
||||
}
|
||||
vx *= ball.getVX()>0 ? -1 : 1;
|
||||
if(ball.getY() - ball.getRadius() <= y+height && ball.getX()-ball.getRadius() >= x && ball.getX()+ball.getRadius() < x+width) ball.setVY(vy);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(vx);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1020 - width/2) this->x = 1020 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
36
.config/Code/User/History/a91b7ce/qqmp.cpp
Normal file
36
.config/Code/User/History/a91b7ce/qqmp.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x){
|
||||
// color = new float[3];
|
||||
color = other.color;
|
||||
}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
// y = 5, 5, 2.5
|
||||
// x = 0, 5, 5/2 sqrt3
|
||||
int x, y;
|
||||
switch(rand()%3){
|
||||
case 0: x = 0; y = 5; break;
|
||||
case 1: x = 5; y = 5; break;
|
||||
case 2: x = 5/2 * sqrt(3); y = 5/2; break;
|
||||
}
|
||||
x *= ball.getVX()>0 ? -1 : 1;
|
||||
if(ball.getY() - ball.getRadius() <= y+height && ball.getX()-ball.getRadius() >= x && ball.getX()+ball.getRadius() < x+width) ball.setVY(y);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(x);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < 10 + width/2) this->x = 10;
|
||||
else if(x > 1010 - width/2) this->x = 1010 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
24
.config/Code/User/History/a91b7ce/tVWW.cpp
Normal file
24
.config/Code/User/History/a91b7ce/tVWW.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY()-ball.getRadius() < y+height && ball.getX()+ball.getRadius() >= x && ball.getX()-ball.getRadius() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
24
.config/Code/User/History/a91b7ce/taDs.cpp
Normal file
24
.config/Code/User/History/a91b7ce/taDs.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY()-ball.getRadius() <= y+height && ball.getX()+ball.getRadius() >= x && ball.getX()-ball.getRadius() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
47
.config/Code/User/History/a91b7ce/uJGn.cpp
Normal file
47
.config/Code/User/History/a91b7ce/uJGn.cpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
//TODO: Redo Collisoin
|
||||
if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width){
|
||||
ball.setVY(ball.getVY()*-1);
|
||||
color = ball.getColor();
|
||||
}
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) ball.setVY(ball.getVY()*-1);
|
||||
}
|
||||
|
||||
int Paddle::getX(){
|
||||
return x;
|
||||
}
|
||||
int Paddle::getY(){
|
||||
return y;
|
||||
}
|
||||
int Paddle::getWidth(){
|
||||
return width;
|
||||
}
|
||||
int Paddle::getHeight(){
|
||||
return height;
|
||||
}
|
||||
|
||||
Paddle& Paddle::setWidth(int width){
|
||||
this->width = width;
|
||||
return *this;
|
||||
}
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){}
|
79
.config/Code/User/History/a91b7ce/vEKv.cpp
Normal file
79
.config/Code/User/History/a91b7ce/vEKv.cpp
Normal file
|
@ -0,0 +1,79 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, int y, float *color) : height(20), y(y), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
//TODO: Redo Collisoin
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// if(ball.getX() >= x && ball.getX() <= x+width){
|
||||
// if(ball.getY()+ball.getRadius() >= y && ball.getY()+ball.getRadius() <= y+4){
|
||||
|
||||
// }
|
||||
// else if(ball.getY()-ball.getRadius() <= y+height && ball.getY()+ball.getRadius() <= y-4){
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width){
|
||||
// ball.setVY(ball.getVY()*-1);
|
||||
// color = ball.getColor()
|
||||
// }
|
||||
// if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
// //TODO: game over screen
|
||||
// if(ball.getY() < 0) ball.setVY(ball.getVY()*-1);
|
||||
}
|
||||
|
||||
int Paddle::getX(){
|
||||
return x;
|
||||
}
|
||||
int Paddle::getY(){
|
||||
return y;
|
||||
}
|
||||
int Paddle::getWidth(){
|
||||
return width;
|
||||
}
|
||||
int Paddle::getHeight(){
|
||||
return height;
|
||||
}
|
||||
|
||||
Paddle& Paddle::setWidth(int width){
|
||||
this->width = width;
|
||||
return *this;
|
||||
}
|
||||
Paddle& Paddle::setX(int x){
|
||||
// if(x < width/2) this->x = 0;
|
||||
// else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
// else this->x = x - width/2;
|
||||
this->x = x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){}
|
36
.config/Code/User/History/a91b7ce/vdFJ.cpp
Normal file
36
.config/Code/User/History/a91b7ce/vdFJ.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x){
|
||||
// color = new float[3];
|
||||
color = other.color;
|
||||
}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
// y = 5, 5, 2.5
|
||||
// x = 0, 5, 5/2 sqrt3
|
||||
int vx, vy;
|
||||
switch(rand()%3){
|
||||
case 0: vx = 0; vy = 5; break;
|
||||
case 1: vx = 5; vy = 5; break;
|
||||
// case 4: vx = 5/2 * sqrt(3); vy = 5/2; break;
|
||||
}
|
||||
vx *= ball.getVX()>0 ? -1 : 1;
|
||||
if(ball.getY() - ball.getRadius() <= y+height && ball.getX()-ball.getRadius() >= x && ball.getX()+ball.getRadius() < x+width) ball.setVY(vy);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(vx);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < 10 + width/2) this->x = 10;
|
||||
else if(x > 1010 - width/2) this->x = 1010 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
33
.config/Code/User/History/a91b7ce/xZ39.cpp
Normal file
33
.config/Code/User/History/a91b7ce/xZ39.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
int Paddle::getX(){
|
||||
return x;
|
||||
}
|
||||
int Paddle::getY(){
|
||||
return y;
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){}
|
57
.config/Code/User/History/a91b7ce/zrg3.cpp
Normal file
57
.config/Code/User/History/a91b7ce/zrg3.cpp
Normal file
|
@ -0,0 +1,57 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, int y, float *color) : height(20), y(y), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
//TODO: Redo Collisoin
|
||||
|
||||
|
||||
if(ball.getX() >= x && ball.getX() <= x+width){
|
||||
if(ball.getY()-ball.getRadius() >= y && ball.getY() <= y+4){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width){
|
||||
// ball.setVY(ball.getVY()*-1);
|
||||
// color = ball.getColor()
|
||||
// }
|
||||
// if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
// //TODO: game over screen
|
||||
// if(ball.getY() < 0) ball.setVY(ball.getVY()*-1);
|
||||
}
|
||||
|
||||
int Paddle::getX(){
|
||||
return x;
|
||||
}
|
||||
int Paddle::getY(){
|
||||
return y;
|
||||
}
|
||||
int Paddle::getWidth(){
|
||||
return width;
|
||||
}
|
||||
int Paddle::getHeight(){
|
||||
return height;
|
||||
}
|
||||
|
||||
Paddle& Paddle::setWidth(int width){
|
||||
this->width = width;
|
||||
return *this;
|
||||
}
|
||||
Paddle& Paddle::setX(int x){
|
||||
// if(x < width/2) this->x = 0;
|
||||
// else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
// else this->x = x - width/2;
|
||||
this->x = x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){}
|
26
.config/Code/User/History/a91b7ce/zuPC.cpp
Normal file
26
.config/Code/User/History/a91b7ce/zuPC.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include "Paddle.h"
|
||||
#include "Ball.h"
|
||||
#include "util.h"
|
||||
|
||||
Paddle::Paddle(int width, int x, float *color) : height(20), y(10), width(width), x(x), color(color){}
|
||||
Paddle::Paddle(const Paddle& other) : height(other.height), y(other.y), width(other.width), x(other.x), color(other.color){}
|
||||
|
||||
void Paddle::draw(){
|
||||
DrawRectangle(x, y, width, height, color);
|
||||
}
|
||||
|
||||
void Paddle::checkCollision(Ball& ball){
|
||||
if(ball.getY()-ball.getRadius() == y+height && ball.getX()-ball.getRadius() > x && ball.getX()+ball.getRadius() < x+width) ball.setVY(ball.getVY()*-1);
|
||||
if(ball.getY() <= y+height && ball.getX() >= x && ball.getX() < x+width) ball.setVX(ball.getVX()*-1);
|
||||
//TODO: game over screen
|
||||
if(ball.getY() < 0) exit(1);
|
||||
}
|
||||
|
||||
Paddle& Paddle::setX(int x){
|
||||
if(x < width/2) this->x = 0;
|
||||
else if(x > 1050 - width/2) this->x = 1050 - width;
|
||||
else this->x = x - width/2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Paddle::~Paddle(){}
|
Loading…
Add table
Add a link
Reference in a new issue