common.h 933 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef COMMON_H
  2. #define COMMON_H
  3. #include <r3d.h>
  4. #include <raylib.h>
  5. #include <raymath.h>
  6. #include <stdlib.h>
  7. #include <stddef.h>
  8. #ifndef RESOURCES_PATH
  9. # define RESOURCES_PATH "/"
  10. #endif
  11. /* === Example functions === */
  12. const char* Init(void);
  13. void Update(float delta);
  14. void Draw(void);
  15. void Close(void);
  16. /* === Helper Functions === */
  17. static inline void DrawCredits(const char* text)
  18. {
  19. int len = MeasureText(text, 16);
  20. DrawRectangle(0, GetScreenHeight() - 36, 20 + len, 36, ColorAlpha(BLACK, 0.5f));
  21. DrawRectangleLines(0, GetScreenHeight() - 36, 20 + len, 36, BLACK);
  22. DrawText(text, 10, GetScreenHeight() - 26, 16, LIME);
  23. }
  24. /* === Main program === */
  25. int main(void)
  26. {
  27. InitWindow(800, 600, "");
  28. const char* title = Init();
  29. SetWindowTitle(title);
  30. while (!WindowShouldClose()) {
  31. Update(GetFrameTime());
  32. BeginDrawing();
  33. Draw();
  34. EndDrawing();
  35. }
  36. Close();
  37. CloseWindow();
  38. return 0;
  39. }
  40. #endif // COMMON_H