main.cpp 854 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "ArenaScene.h"
  2. using namespace Crown;
  3. class WndCtrl: public KeyboardListener
  4. {
  5. public:
  6. WndCtrl()
  7. {
  8. GetDevice()->GetInputManager()->RegisterKeyboardListener(this);
  9. }
  10. virtual void KeyReleased(const KeyboardEvent& event)
  11. {
  12. if (event.key == KC_ESCAPE)
  13. {
  14. GetDevice()->StopRunning();
  15. }
  16. }
  17. };
  18. int main(int argc, char** argv)
  19. {
  20. int wndW = 800;
  21. int wndH = 480;
  22. if (argc == 3)
  23. {
  24. wndW = atoi(argv[1]);
  25. wndH = atoi(argv[2]);
  26. }
  27. Device* mDevice = GetDevice();
  28. if (!mDevice->Init(wndW, wndH, 32, false))
  29. {
  30. return 0;
  31. }
  32. WndCtrl ctrl;
  33. ArenaScene* mainScene = new ArenaScene(wndW, wndH);
  34. GetDevice()->GetSceneManager()->SelectNextScene(mainScene);
  35. mDevice->GetMainWindow()->SetTitle("Crown Engine v0.1 - Chainsaw Buffet");
  36. while (mDevice->IsRunning())
  37. {
  38. mDevice->Frame();
  39. }
  40. mDevice->Shutdown();
  41. return 0;
  42. }