Nanoic

Untitled

Feb 7th, 2024
1,321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. #define OLC_PGE_APPLICATION
  2. #include "olcPixelGameEngine.h"
  3. using namespace std;
  4.  
  5. class NodeBoxes : public olc::PixelGameEngine
  6. {
  7. public:
  8.     NodeBoxes() {
  9.         sAppName = "boxes";
  10.  
  11.  
  12.     }
  13.  
  14.     struct rect
  15.     {
  16.         olc::vf2d pos;
  17.         olc::vf2d size;
  18.  
  19.     };
  20.  
  21.  
  22.     //struct line {
  23.     //  olc::vf2d initPos;
  24.     //  olc::vf2d termPos;
  25.     //};
  26.  
  27. public:
  28.     bool OnUserCreate() override
  29.     {
  30.         return true;
  31.     }
  32.  
  33.     bool OnUserUpdate(float fElapsedTime) override
  34.     {
  35.  
  36.         float nodeAXPos = 50.0f;
  37.         float nodeAYPos = 70.0f;
  38.        
  39.         float nodeBXPos = 110.0f;
  40.         float nodeBYPos = 60.0f;
  41.  
  42.         float nodeAHeight = 50.0f;
  43.         float nodeAWidth = 50.0f;
  44.  
  45.         float nodeBHeight = 50.0f;
  46.         float nodeBWidth = 50.0f;
  47.  
  48.  
  49.         rect r = { {nodeAXPos, nodeAYPos}, {nodeAHeight, nodeAWidth } };
  50.         rect r2 = { {nodeBXPos, nodeBYPos}, {nodeBHeight, nodeBWidth } };
  51.  
  52.         //line l = { { nodeAXPos, nodeAYPos}, {nodeBXPos, nodeBYPos} };
  53.  
  54.         DrawRect(r.pos, r.size, olc::GREEN);
  55.         DrawRect(r2.pos, r2.size, olc::RED);
  56.  
  57.         /*olc::vf2d a = {nodeBXPos, nodeAXPos};
  58.         olc::vf2d b = { nodeBYPos, nodeAYPos };
  59.  
  60.         olc::vf2d c = a - b;
  61.  
  62.         float length = c.mag();
  63.         std::cout << length << endl;*/
  64.  
  65.         DrawLine(r.pos + r.size / 2, r2.pos + r2.size / 2, olc::WHITE);
  66.        
  67.  
  68.         return true;
  69.     }
  70. };
  71.  
  72. int main()
  73. {
  74.     NodeBoxes game;
  75.     if (game.Construct(256, 240, 4, 4))
  76.         game.Start();
  77.     else
  78.         std::wcout << "L" << std::endl;
  79.     return 0;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment