From 2a2de71696d5cc2f805aafa667eeb07d2b75e073 Mon Sep 17 00:00:00 2001 From: Andy Belle-Isle Date: Sun, 25 Aug 2019 15:05:51 -0400 Subject: Fixed link formatting in README --- README.md | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index f8312d9..ac53de9 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,17 @@ -gamedev2 -======== +# gamedev2 gamedev2 is a reincarnation of a previous - (project)[github.com/tcsullivan/gamedev] created by - (Andy Belle-Isle)[github.com/drumsetmonkey] and - (Clyne Sullivan)[github.com/tcsullivan]. + [project](github.com/tcsullivan/gamedev) created by + [Andy Belle-Isle](github.com/drumsetmonkey) and + [Clyne Sullivan](github.com/tcsullivan). -After a long time developing (gamedev)[github.com/tcsullivan/gamedev], +After a long time developing [gamedev](github.com/tcsullivan/gamedev), we decided a large amount of the codebase was rather messy and inefficient. Instead of rewriting gamedev piece by piece, we decided that the final product would be of a much higher quality if the project was restarted from scratch. ## Goal -------- The goal of gamedev2 is to create a commercial-grade video game in which content can be created through the use of scripting languages such as Lua. One of the things that sets gamedev2 apart from many other indie games is that gamedev2 @@ -22,12 +20,10 @@ implement only the necessary features needed to make gamedev2 run smoothly without the extra bloat brought on by a general purpose game engine. ## Features (Planned) ---------------------- * Fully modifiable through the use of scripting languages * Multiplayer ## Libraries ------------- The libraries used to develop gamedev2 are as follows: * SDL2 * OpenGL @@ -39,7 +35,6 @@ The libraries used to develop gamedev2 are as follows: ## Building gamedev2 --------------------- ### Build Requirements gamedev2 is actively developed on Linux, so the Windows build process may not be as simple as the Linux requirements listed below. @@ -52,7 +47,7 @@ In order to build gamedev2 the following programs are needed: In order to build gamedev2 on Linux, the process is fairly simple. 1. First cd into the root gamedev2 directory ``` -cd gamedev +cd gamedev2 ``` 2. EntityX must be build first before the rest of gamedev2 @@ -66,7 +61,7 @@ cd ../.. ``` make ``` -In order to make gamedev2 using multiple threads, the following can be run: +In order to make gamedev2 using multiple threads, use the following instead: ``` make -jN ``` -- cgit v1.2.3 From 9f88bdf8d6a67da532376a6bd1fbb2a5435ccaba Mon Sep 17 00:00:00 2001 From: Andy Belle-Isle Date: Sun, 25 Aug 2019 15:06:28 -0400 Subject: Fixed link formatting again, whoops --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ac53de9..81f87c8 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # gamedev2 gamedev2 is a reincarnation of a previous - [project](github.com/tcsullivan/gamedev) created by - [Andy Belle-Isle](github.com/drumsetmonkey) and - [Clyne Sullivan](github.com/tcsullivan). + [project](https://github.com/tcsullivan/gamedev) created by + [Andy Belle-Isle](https://github.com/drumsetmonkey) and + [Clyne Sullivan](https://github.com/tcsullivan). -After a long time developing [gamedev](github.com/tcsullivan/gamedev), +After a long time developing [gamedev](https://github.com/tcsullivan/gamedev), we decided a large amount of the codebase was rather messy and inefficient. Instead of rewriting gamedev piece by piece, we decided that the final product would be of a much higher quality if the project was restarted from -- cgit v1.2.3 From 036816eee4972b96196c8becbfc534c8b045150a Mon Sep 17 00:00:00 2001 From: tcsullivan Date: Sun, 25 Aug 2019 15:28:57 -0400 Subject: added logic and render loops --- Makefile | 2 +- src/main.cpp | 31 +++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 9d2f336..46e61b7 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ CC = gcc CXX = g++ -LIBS = -lSDL2 +LIBS = -lSDL2 -lpthread CXXFLAGS = -ggdb -std=c++17 \ -Wall -Wextra -Werror -pedantic \ diff --git a/src/main.cpp b/src/main.cpp index bd53101..707c912 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,13 +20,21 @@ #include +#include +#include #include #include +#include constexpr const char *title = "gamedev2"; constexpr int width = 640; constexpr int height = 480; +std::atomic_bool shouldRun; + +static void renderLoop(void); +static void logicLoop(void); + int main([[maybe_unused]] int argc, [[maybe_unused]] char *argv[]) { // Initialize SDL @@ -49,9 +57,28 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char *argv[]) return -1; } - // TODO game - SDL_Delay(1000); + // Start game + shouldRun.store(true); + std::thread logic (logicLoop); + renderLoop(); + logic.join(); return 0; } +void renderLoop(void) +{ + using namespace std::chrono_literals; + + // TODO render + while (shouldRun.load()) + std::this_thread::sleep_for(100ms); +} + +void logicLoop(void) +{ + // TODO handle logic + SDL_Delay(1000); + shouldRun.store(false); +} + -- cgit v1.2.3 From 92756db816a6e0fc7ff06c6fd83d512ecb4d61f6 Mon Sep 17 00:00:00 2001 From: tcsullivan Date: Sun, 25 Aug 2019 15:49:06 -0400 Subject: added SDL key events --- src/main.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 707c912..778ae73 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -77,8 +77,24 @@ void renderLoop(void) void logicLoop(void) { - // TODO handle logic - SDL_Delay(1000); - shouldRun.store(false); + using namespace std::chrono_literals; + + std::cout << "Press escape to exit." << std::endl; + + while (shouldRun.load()) { + for (SDL_Event event; SDL_PollEvent(&event);) { + switch (event.type) { + case SDL_KEYUP: + // Exit game on escape + if (event.key.keysym.sym == SDLK_ESCAPE) + shouldRun.store(false); + break; + default: + break; + } + } + + std::this_thread::sleep_for(100ms); + } } -- cgit v1.2.3