Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. /*
  2. ** EPITECH PROJECT, 2020
  3. ** OOP_arcade_2019
  4. ** File description:
  5. ** main
  6. */
  7.  
  8. #include "../DLLoader/Loader.hpp"
  9. #include "../Wrappers/WrSFML/WrSFML.hpp"
  10. #include "../Core/Core.hpp"
  11.  
  12. std::unique_ptr<Arcade::Core> LoadCore(const std::string startLibPath)
  13. {
  14.     LibraryHandler library = dlopen("core.so", RTLD_LAZY);
  15.     void* core = dlsym(library, "GetCore");
  16.  
  17.     std::unique_ptr<Arcade::Core> engine = (reinterpret_cast<std::unique_ptr<Arcade::Core> (*)(const std::string&)>(core))(startLibPath);
  18.  
  19.     return engine;
  20. }
  21.  
  22. int main(int ac, char** av)
  23. {
  24.     std::unique_ptr<Arcade::Core> engine;
  25.  
  26.     if (ac >= 2)
  27.         engine = LoadCore(av[1]);
  28.     else
  29.         return -1;
  30.  
  31.     engine->WindowCreate("Ma belle fenetre", 1280, 720);
  32.     engine->ImageAdd("smiley", "assets/smiley.png", 0.2f);
  33.  
  34.     engine->EventAddKey("P", [&engine] {
  35.         engine->WindowClose();
  36.     });
  37.  
  38.     engine->ImageSetPosition("smiley", 500, 300);
  39.  
  40.     while (engine->WindowIsOpen())
  41.     {
  42.         engine->ImageMove("smiley", engine->InputGetAxis() * 2);
  43.  
  44.         engine->WindowClear();
  45.  
  46.         engine->WindowDraw("smiley");
  47.  
  48.         engine->WindowUpdate();
  49.     }
  50.  
  51.     engine->WindowClose();
  52.  
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement