summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--CMakeLists.txt6
-rw-r--r--kurator/CMakeLists.txt12
-rw-r--r--kurator/src/GameOver.cpp35
-rw-r--r--kurator/src/GameOver.h24
-rw-r--r--kurator/src/Scene.h16
-rw-r--r--kurator/src/Session.cpp33
-rw-r--r--kurator/src/Session.h22
-rw-r--r--kurator/src/Title.cpp40
-rw-r--r--kurator/src/Title.h24
-rw-r--r--kurator/src/main.cpp19
11 files changed, 232 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a5309e6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+build*/
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..f6aef10
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.16)
+project(kurator)
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_EXTENSIONS No)
+find_package(raylib 4 REQUIRED)
+add_subdirectory(kurator)
diff --git a/kurator/CMakeLists.txt b/kurator/CMakeLists.txt
new file mode 100644
index 0000000..75d00a4
--- /dev/null
+++ b/kurator/CMakeLists.txt
@@ -0,0 +1,12 @@
+project(kurator)
+add_executable(
+ ${PROJECT_NAME}
+ src/main.cpp
+ src/GameOver.cpp
+ src/Session.cpp
+ src/Title.cpp
+)
+target_link_libraries(
+ ${PROJECT_NAME}
+ PRIVATE raylib
+)
diff --git a/kurator/src/GameOver.cpp b/kurator/src/GameOver.cpp
new file mode 100644
index 0000000..9646c17
--- /dev/null
+++ b/kurator/src/GameOver.cpp
@@ -0,0 +1,35 @@
+#include "GameOver.h"
+
+#include <memory>
+#include <utility>
+
+#include <raylib.h>
+
+#include "Session.h"
+
+
+namespace kurator
+{
+
+
+GameOver::GameOver(std::shared_ptr<Session> _session) :
+ session {std::move(_session)}
+{
+}
+
+
+void
+GameOver::update(const float)
+{
+}
+
+
+void
+GameOver::draw() const
+{
+ ClearBackground(GRAY);
+ DrawText("Bye", 100, 100, 20, BLACK);
+}
+
+
+} // namespace kurator
diff --git a/kurator/src/GameOver.h b/kurator/src/GameOver.h
new file mode 100644
index 0000000..70b5c31
--- /dev/null
+++ b/kurator/src/GameOver.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include <memory>
+
+#include "Session.h"
+#include "Scene.h"
+
+
+namespace kurator
+{
+
+
+class GameOver : public Scene
+{
+public:
+ explicit GameOver(std::shared_ptr<Session> _session);
+ void update(float dt) override;
+ void draw() const override;
+private:
+ std::shared_ptr<Session> session;
+};
+
+
+} // namespace kurator
diff --git a/kurator/src/Scene.h b/kurator/src/Scene.h
new file mode 100644
index 0000000..fbd2480
--- /dev/null
+++ b/kurator/src/Scene.h
@@ -0,0 +1,16 @@
+#pragma once
+
+
+namespace kurator
+{
+
+
+class Scene
+{
+public:
+ virtual void update(float dt) = 0;
+ virtual void draw() const = 0;
+};
+
+
+} // namespace kurator
diff --git a/kurator/src/Session.cpp b/kurator/src/Session.cpp
new file mode 100644
index 0000000..07b19f1
--- /dev/null
+++ b/kurator/src/Session.cpp
@@ -0,0 +1,33 @@
+#include "Session.h"
+
+#include <memory>
+
+#include <raylib.h>
+
+#include "Scene.h"
+
+
+namespace kurator
+{
+
+
+void
+Session::set(std::shared_ptr<Scene> _scene)
+{
+ scene = _scene;
+}
+
+
+void
+Session::loop()
+{
+ if (!scene)
+ return;
+ scene->update(GetFrameTime());
+ BeginDrawing();
+ scene->draw();
+ EndDrawing();
+}
+
+
+} // namespace kurator
diff --git a/kurator/src/Session.h b/kurator/src/Session.h
new file mode 100644
index 0000000..cc8a4ee
--- /dev/null
+++ b/kurator/src/Session.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include <memory>
+
+#include "Scene.h"
+
+
+namespace kurator
+{
+
+
+class Session
+{
+public:
+ void set(std::shared_ptr<Scene> _scene);
+ void loop();
+private:
+ std::shared_ptr<Scene> scene;
+};
+
+
+} // namespace kurator
diff --git a/kurator/src/Title.cpp b/kurator/src/Title.cpp
new file mode 100644
index 0000000..56f52a8
--- /dev/null
+++ b/kurator/src/Title.cpp
@@ -0,0 +1,40 @@
+#include "Title.h"
+
+#include <memory>
+#include <utility>
+
+#include <raylib.h>
+
+#include "GameOver.h"
+#include "Session.h"
+
+
+namespace kurator
+{
+
+
+Title::Title(std::shared_ptr<Session> _session) :
+ session {std::move(_session)}
+{
+}
+
+
+void
+Title::update(const float)
+{
+ if (IsKeyPressed(KEY_SPACE)) {
+ auto next = std::make_shared<GameOver>(session);
+ session->set(next);
+ }
+}
+
+
+void
+Title::draw() const
+{
+ ClearBackground(BLACK);
+ DrawText("Hey", 100, 100, 20, GRAY);
+}
+
+
+} // namespace kurator
diff --git a/kurator/src/Title.h b/kurator/src/Title.h
new file mode 100644
index 0000000..c29dc99
--- /dev/null
+++ b/kurator/src/Title.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include <memory>
+
+#include "Session.h"
+#include "Scene.h"
+
+
+namespace kurator
+{
+
+
+class Title : public Scene
+{
+public:
+ explicit Title(std::shared_ptr<Session> _session);
+ void update(float dt) override;
+ void draw() const override;
+private:
+ std::shared_ptr<Session> session;
+};
+
+
+} // namespace kurator
diff --git a/kurator/src/main.cpp b/kurator/src/main.cpp
new file mode 100644
index 0000000..112be1a
--- /dev/null
+++ b/kurator/src/main.cpp
@@ -0,0 +1,19 @@
+#include <memory>
+
+#include <raylib.h>
+
+#include "Session.h"
+#include "Title.h"
+
+
+int
+main(int, char*[])
+{
+ InitWindow(800, 600, "Kurator");
+ auto session = std::make_shared<kurator::Session>();
+ auto title = std::make_shared<kurator::Title>(session);
+ session->set(title);
+ while (!WindowShouldClose())
+ session->loop();
+ CloseWindow();
+}