This commit is contained in:
RafayAhmad7548 2024-06-16 18:53:25 +05:00
parent 37776af5db
commit ab03d5f10c
4045 changed files with 286212 additions and 3 deletions

View file

@ -0,0 +1,17 @@
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
public:
Paddle(int width, int x) : height(25), y(10), width(width), x(x){
DrawRectangle(x, y, width, height, colors[GRAY]);
}
};

View file

@ -0,0 +1,30 @@
#ifndef PADDLE_H
#define PADDLE_H
#include "Ball.h"
class Paddle{
const int height;
int width;
int x;
int y;
float *color;
public:
Paddle(int width, int x, int y, float *color);
Paddle(const Paddle& other);
void draw();
void checkCollision(Ball& ball);
int getX();
int getY();
int getWidth();
int getHeight();
Paddle& setWidth(int width);
Paddle& setX(int x);
~Paddle();
};
#endif

View file

@ -0,0 +1,7 @@
class Paddle{
const int height;
int width;
};

View file

@ -0,0 +1,32 @@
#include "util.h"
#include "Ball.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color) : height(25), y(10), width(width), x(x), color(color){}
void draw(){
DrawRectangle(x, y, width, height, color);
}
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;
}
void 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);
}
}
};

View file

@ -0,0 +1,23 @@
#ifndef PADDLE_H
#define PADDLE_H
#include "Ball.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color);
void draw();
void checkCollision(Ball& ball);
Paddle& setX(int x);
};
#endif

View file

@ -0,0 +1,18 @@
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x) : height(25), y(10), width(width), x(x){
DrawRectangle(x, y, width, height, colors[GRAY]);
}
};

View file

@ -0,0 +1,21 @@
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color) : height(25), y(10), width(width), x(x), color(color){
DrawRectangle(x, y, width, height, color);
}
Paddle& setX(int x) : x(x){
return *this;
}
};

View file

@ -0,0 +1,3 @@
class Paddle{
};

View file

@ -0,0 +1,13 @@
class Paddle{
const int height;
const int y;
int width;
int x;
public:
Paddle(int width, int x) : height(25), y(10), width(width), x(x){}
};

View file

@ -0,0 +1,30 @@
// #ifndef PADDLE_H
// #define PADDLE_H
#include "Ball.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color);
Paddle(const Paddle& other);
void draw();
void checkCollision(Ball& ball);
int getX();
int getY();
int getWidth();
int getHeight();
Paddle& setWidth(int width);
Paddle& setX(int x);
~Paddle();
};
// #endif

View file

@ -0,0 +1,36 @@
#ifndef PADDLE_H
#define PADDLE_H
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color) : height(25), y(10), width(width), x(x), color(color){}
void draw(){
DrawRectangle(x, y, width, height, color);
}
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;
}
void 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);
}
}
};
#endif

View file

@ -0,0 +1,26 @@
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color) : height(25), y(10), width(width), x(x), color(color){}
void draw(){
DrawRectangle(x, y, width, height, color);
}
Paddle& setX(int x){
if(x < 10) this->x = 10;
else if(x > 1010) this->x = 1010;
else this->x = x - width/2;
return *this;
}
};

View file

@ -0,0 +1,37 @@
#ifndef PADDLE_H
#define PADDLE_H
#include "util.h"
#include "Paddle.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color) : height(25), y(10), width(width), x(x), color(color){}
void draw(){
DrawRectangle(x, y, width, height, color);
}
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;
}
void 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);
}
}
};
#endif

View file

@ -0,0 +1,29 @@
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color) : height(25), y(10), width(width), x(x), color(color){}
void draw(){
DrawRectangle(x, y, width, height, color);
}
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;
}
void checkCollision(Ball ball){
}
};

View file

@ -0,0 +1,17 @@
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color) : height(25), y(10), width(width), x(x), color(color){
DrawRectangle(x, y, width, height, color);
}
};

View file

@ -0,0 +1,26 @@
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color) : height(25), y(10), width(width), x(x), color(color){}
void draw(){
DrawRectangle(x, y, width, height, color);
}
Paddle& setX(int x){
if(x < 10 + width/2) this->x = 10;
else if(x > 1010 - width/2) this->x = 1010 - width/2;
else this->x = x - width/2;
return *this;
}
};

View file

@ -0,0 +1,17 @@
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
public:
Paddle(int width, int x) : height(25), y(10), width(width), x(x){
}
};

View file

@ -0,0 +1,30 @@
#ifndef PADDLE_H
#define PADDLE_H
#include "Ball.h"
class Paddle{
const int height;
int width;
int x;
int y;
float *color;
public:
Paddle(int width, int x, int y, float *color);
Paddle(const Paddle& other);
void draw();
void checkCollision(Ball& ball);
int getX();
int getY();
int getWidth();
int getHeight();
Paddle& setWidth(int width);
Paddle& setX(int x);
~Paddle();
};
#endif

View file

@ -0,0 +1,25 @@
// #ifndef PADDLE_H
// #define PADDLE_H
#include "Ball.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color);
Paddle(const Paddle& other);
void draw();
void checkCollision(Ball& ball);
Paddle& setX(int x);
~Paddle();
};
// #endif

View file

@ -0,0 +1,11 @@
class Paddle{
const int height;
const int y;
int width;
int x;
Paddle(int width, int x) : height(25), y(10), width(width), x(x){}
};

View file

@ -0,0 +1,25 @@
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color) : height(25), y(10), width(width), x(x), color(color){}
void draw(){
DrawRectangle(x, y, width, height, color);
}
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;
}
};

View file

@ -0,0 +1,31 @@
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color) : height(25), y(10), width(width), x(x), color(color){}
void draw(){
DrawRectangle(x, y, width, height, color);
}
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;
}
void checkCollision(Ball& ball){
if(ball.getY() - ball.getRadius() < y+height && ball.getX()+ball.getRadius() > x && ball.getX()-ball.getRadius() < x+width){
}
}
};

View file

@ -0,0 +1,25 @@
#ifndef PADDLE_H
#define PADDLE_H
#include "Ball.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color);
Paddle(const Paddle& other);
void draw();
void checkCollision(Ball& ball);
Paddle& setX(int x);
~Paddle();
};
#endif

View file

@ -0,0 +1,31 @@
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color) : height(25), y(10), width(width), x(x), color(color){}
void draw(){
DrawRectangle(x, y, width, height, color);
}
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;
}
void 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);
}
}
};

View file

@ -0,0 +1,29 @@
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color) : height(25), y(10), width(width), x(x), color(color){}
void draw(){
DrawRectangle(x, y, width, height, color);
}
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;
}
void checkCollision(Ball& ball){
if(ball.getY() - ball.getRadius() < y+height)
}
};

View file

@ -0,0 +1,24 @@
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color) : height(25), y(10), width(width), x(x), color(color){
DrawRectangle(x, y, width, height, color);
}
Paddle& setX(int x){
if(x < 10) this->x = 10;
else if(x > 1010) this->x = 1010;
else this->x = x;
return *this;
}
};

View file

@ -0,0 +1,26 @@
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color) : height(25), y(10), width(width), x(x), color(color){}
void draw(){
DrawRectangle(x, y, width, height, color);
}
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;
}
};

View file

@ -0,0 +1,8 @@
class Paddle{
const int height;
int width;
int x;
};

View file

@ -0,0 +1,25 @@
// #ifndef PADDLE_H
// #define PADDLE_H
#include "Ball.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color);
Paddle(const Paddle& other);
void draw();
void checkCollision(Ball& ball);
Paddle& setX(int x);
~Paddle();
};
// #endif

View file

@ -0,0 +1,26 @@
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color) : height(25), y(10), width(width), x(x), color(color){}
void draw(){
DrawRectangle(x, y, width, height, color);
}
Paddle& setX(int x){
if(x < 10 + width/2) this->x = 10;
else if(x > 1010) this->x = 1010;
else this->x = x - width/2;
return *this;
}
};

View file

@ -0,0 +1 @@
{"version":1,"resource":"file:///home/rafayahmad/Stuff/OOP/Project/Paddle.h","entries":[{"id":"Dt2C.h","timestamp":1714200679116},{"id":"4KNP.h","timestamp":1714200711026},{"id":"byMj.h","timestamp":1714200727315},{"id":"hxhi.h","timestamp":1714200783746},{"id":"RvBk.h","timestamp":1714200841565},{"id":"Ew26.h","timestamp":1714200888536},{"id":"iV7D.h","timestamp":1714200909619},{"id":"O7K2.h","timestamp":1714200921529},{"id":"1ley.h","timestamp":1714200956598},{"id":"BPcE.h","timestamp":1714200992267},{"id":"feI3.h","timestamp":1714201027859},{"id":"NCjl.h","timestamp":1714201052246},{"id":"C7ri.h","timestamp":1714201175956},{"id":"zbsV.h","timestamp":1714201195839},{"id":"YQvB.h","timestamp":1714201397756},{"id":"jp4I.h","timestamp":1714201497858},{"id":"vRgW.h","timestamp":1714201620190},{"id":"JEJu.h","timestamp":1714201649363},{"id":"e8vk.h","timestamp":1714201687442},{"id":"Nw8Q.h","timestamp":1714201785494},{"id":"Yvrc.h","timestamp":1714201867484},{"id":"VZhV.h","timestamp":1714201926613},{"id":"MItV.h","timestamp":1714272245240},{"id":"kiFm.h","timestamp":1714272268258},{"id":"YDp5.h","timestamp":1714272477576},{"id":"Vdky.h","timestamp":1714272622464},{"id":"XBS6.h","timestamp":1714272681632},{"id":"4vkl.h","timestamp":1714272761248},{"id":"l6Ih.h","timestamp":1714272966483},{"id":"gWeL.h","timestamp":1714272996828},{"id":"JjpJ.h","timestamp":1714273832560},{"id":"G86Y.h","timestamp":1714273846260},{"id":"my86.h","timestamp":1714273978593},{"id":"mPMf.h","timestamp":1714273997766},{"id":"9WNn.h","timestamp":1714274337833},{"id":"gPwQ.h","timestamp":1714294440659},{"id":"WzLI.h","timestamp":1714700105840},{"id":"idN5.h","timestamp":1714700308271},{"id":"hmex.h","timestamp":1714700558138},{"id":"Qi0D.h","timestamp":1714733697738},{"id":"c0HE.h","timestamp":1714734073958},{"id":"nf01.h","timestamp":1714822743409},{"id":"rwFs.h","timestamp":1714822779869},{"id":"yt8Q.h","timestamp":1714822826452},{"id":"FDHa.h","timestamp":1714888981463},{"id":"t8bD.h","timestamp":1714890061176},{"id":"g1sy.h","timestamp":1715160321925},{"id":"3kIi.h","timestamp":1715160332091},{"id":"P8Gi.h","timestamp":1715160406180}]}

View file

@ -0,0 +1,18 @@
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color) : height(25), y(10), width(width), x(x){
DrawRectangle(x, y, width, height, colors[GRAY]);
}
};

View file

@ -0,0 +1,30 @@
#ifndef PADDLE_H
#define PADDLE_H
#include "Ball.h"
class Paddle{
const int height;
int width;
int x;
int y;
float *color;
public:
Paddle(int width, int x, float *color);
Paddle(const Paddle& other);
void draw();
void checkCollision(Ball& ball);
int getX();
int getY();
int getWidth();
int getHeight();
Paddle& setWidth(int width);
Paddle& setX(int x);
~Paddle();
};
#endif

View file

@ -0,0 +1,24 @@
#ifndef PADDLE_H
#define PADDLE_H
#include "Ball.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color);
Paddle(const Paddle& other);
void draw();
void checkCollision(Ball& ball);
Paddle& setX(int x);
};
#endif

View file

@ -0,0 +1,36 @@
#ifndef PADDLE_H
#define PADDLE_H
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color) : height(25), y(10), width(width), x(x), color(color){}
void draw(){
DrawRectangle(x, y, width, height, color);
}
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;
}
void 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);
}
}
};
#endif

View file

@ -0,0 +1,25 @@
#ifndef PADDLE_H
#define PADDLE_H
#include "Ball.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color);
Paddle(const Paddle& other);
void draw();
void checkCollision(Ball& ball);
Paddle& setX(int x);
~Paddle();
};
#endif

View file

@ -0,0 +1,11 @@
class Paddle{
const int height;
const int y;
int width;
int x;
};

View file

@ -0,0 +1,16 @@
class Paddle{
const int height;
const int y;
int width;
int x;
public:
Paddle(int width, int x) : height(25), y(10), width(width), x(x){
}
};

View file

@ -0,0 +1,25 @@
#ifndef PADDLE_H
#define PADDLE_H
#include "Ball.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color);
Paddle(const Paddle& other);
void draw();
void checkCollision(Ball& ball);
Paddle& setX(int x);
// ~Paddle();
};
#endif

View file

@ -0,0 +1,26 @@
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color) : height(25), y(10), width(width), x(x), color(color){}
void draw(){
DrawRectangle(x, y, width, height, color);
}
Paddle& setX(int x){
if(x < 10) this->x = 10;
else if(x > 1010) this->x = 1010;
else this->x = x;
return *this;
}
};

View file

@ -0,0 +1,28 @@
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color) : height(25), y(10), width(width), x(x), color(color){}
void draw(){
DrawRectangle(x, y, width, height, color);
}
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;
}
void checkCollision(Ball& ball){
}
};

View file

@ -0,0 +1,31 @@
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color) : height(25), y(10), width(width), x(x), color(color){}
void draw(){
DrawRectangle(x, y, width, height, color);
}
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;
}
void 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);
}
}
};

View file

@ -0,0 +1,22 @@
#ifndef PADDLE_H
#define PADDLE_H
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color);
void draw();
void checkCollision(Ball& ball);
Paddle& setX(int x);
};
#endif

View file

@ -0,0 +1,35 @@
#ifndef PADDLE_H
#define PADDLE_H
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color);
void draw(){
DrawRectangle(x, y, width, height, color);
}
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;
}
void 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);
}
}
};
#endif

View file

@ -0,0 +1,27 @@
// #ifndef PADDLE_H
// #define PADDLE_H
#include "Ball.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color);
Paddle(const Paddle& other);
void draw();
void checkCollision(Ball& ball);
void getX();
void getY();
Paddle& setX(int x);
~Paddle();
};
// #endif

View file

@ -0,0 +1,27 @@
// #ifndef PADDLE_H
// #define PADDLE_H
#include "Ball.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color);
Paddle(const Paddle& other);
void draw();
void checkCollision(Ball& ball);
int getX();
int getY();
Paddle& setX(int x);
~Paddle();
};
// #endif

View file

@ -0,0 +1,30 @@
#ifndef PADDLE_H
#define PADDLE_H
#include "Ball.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color);
Paddle(const Paddle& other);
void draw();
void checkCollision(Ball& ball);
int getX();
int getY();
int getWidth();
int getHeight();
Paddle& setWidth(int width);
Paddle& setX(int x);
~Paddle();
};
#endif

View file

@ -0,0 +1,26 @@
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color) : height(25), y(10), width(width), x(x), color(color){}
void draw(){
DrawRectangle(x, y, width, height, color);
}
Paddle& setX(int x){
if(x < 10) this->x = 10;
else if(x > 1010) this->x = 1010;
else this->x = x + width/2;
return *this;
}
};

View file

@ -0,0 +1,29 @@
// #ifndef PADDLE_H
// #define PADDLE_H
#include "Ball.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color);
Paddle(const Paddle& other);
void draw();
void checkCollision(Ball& ball);
int getX();
int getY();
int getWidth();
int getHeight();
Paddle& setX(int x);
~Paddle();
};
// #endif

View file

@ -0,0 +1,22 @@
#include "util.h"
class Paddle{
const int height;
const int y;
int width;
int x;
float *color;
public:
Paddle(int width, int x, float *color) : height(25), y(10), width(width), x(x), color(color){
DrawRectangle(x, y, width, height, color);
}
Paddle& setX(int x){
this->x = x;
return *this;
}
};