Advertisement
Shaco74

MyFilledRectangle.cpp

Jan 4th, 2022
808
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. #include "MyFilledRectangle.h"
  4. #include "CImgGIP06.h"
  5.  
  6.  
  7. MyFilledRectangle::MyFilledRectangle(int px1, int py1, int px2, int py2)
  8. {
  9.     x1 = px1;
  10.     y1 = py1;
  11.     x2 = px2;
  12.     y2 = py2;
  13. }
  14.  
  15. void MyFilledRectangle::draw() const{
  16.     MyRectangle::draw();
  17.     int width = x2 - x1;
  18.     int height = y2 - y1;
  19.     if ((width > 4) and (height > 4))
  20.     {
  21.         //gip_draw_line()
  22.         for (int line = (y1 +2); line <= (y2 -2); line++)
  23.         {
  24.             gip_draw_line(x1 +2, line, x2-2, line, red);
  25.         }
  26.     }
  27. }
  28.  
  29. bool MyFilledRectangle::does_not_collide_with(const MyFilledRectangle& other) const
  30. {
  31.     return x1 > other.x2 || x2 < other.x1 || y1 > other.y2 || y2 < other.y1;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement