Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define OLC_PGE_APPLICATION
- #include "olcPixelGameEngine.h"
- using namespace std;
- class NodeBoxes : public olc::PixelGameEngine
- {
- public:
- NodeBoxes() {
- sAppName = "boxes";
- }
- struct rect
- {
- olc::vf2d pos;
- olc::vf2d size;
- };
- //struct line {
- // olc::vf2d initPos;
- // olc::vf2d termPos;
- //};
- public:
- bool OnUserCreate() override
- {
- return true;
- }
- bool OnUserUpdate(float fElapsedTime) override
- {
- float nodeAXPos = 50.0f;
- float nodeAYPos = 70.0f;
- float nodeBXPos = 110.0f;
- float nodeBYPos = 60.0f;
- float nodeAHeight = 50.0f;
- float nodeAWidth = 50.0f;
- float nodeBHeight = 50.0f;
- float nodeBWidth = 50.0f;
- rect r = { {nodeAXPos, nodeAYPos}, {nodeAHeight, nodeAWidth } };
- rect r2 = { {nodeBXPos, nodeBYPos}, {nodeBHeight, nodeBWidth } };
- //line l = { { nodeAXPos, nodeAYPos}, {nodeBXPos, nodeBYPos} };
- DrawRect(r.pos, r.size, olc::GREEN);
- DrawRect(r2.pos, r2.size, olc::RED);
- /*olc::vf2d a = {nodeBXPos, nodeAXPos};
- olc::vf2d b = { nodeBYPos, nodeAYPos };
- olc::vf2d c = a - b;
- float length = c.mag();
- std::cout << length << endl;*/
- DrawLine(r.pos + r.size / 2, r2.pos + r2.size / 2, olc::WHITE);
- return true;
- }
- };
- int main()
- {
- NodeBoxes game;
- if (game.Construct(256, 240, 4, 4))
- game.Start();
- else
- std::wcout << "L" << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment