aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsalaaad2 <arthurdurant263@gmail.com>2022-01-02 20:29:46 +0100
committersalaaad2 <arthurdurant263@gmail.com>2022-01-02 20:29:46 +0100
commit30e2f2436fb1bdc688101e97f65ec1cf49ddb35d (patch)
treedcd31c2c405b55a9c301f89eda71434e1c3e6a31
downloadthreshold-30e2f2436fb1bdc688101e97f65ec1cf49ddb35d.tar.gz
threshold-30e2f2436fb1bdc688101e97f65ec1cf49ddb35d.tar.bz2
threshold-30e2f2436fb1bdc688101e97f65ec1cf49ddb35d.tar.xz
threshold-30e2f2436fb1bdc688101e97f65ec1cf49ddb35d.tar.zst
threshold-30e2f2436fb1bdc688101e97f65ec1cf49ddb35d.zip
initial commit
-rw-r--r--.gitignore8
-rw-r--r--CMakeLists.txt17
-rw-r--r--src/gameplay.cpp23
-rw-r--r--src/gameplay.hpp27
-rw-r--r--src/main.cpp58
-rw-r--r--src/window.cpp11
-rw-r--r--src/window.hpp15
7 files changed, 159 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..76e6b32
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,8 @@
+.DS_Store
+.idea
+*.log
+tmp/
+
+
+.ccls*
+build*
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..d25a131
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 3.15)
+project(space)
+
+find_package(raylib 3.0 REQUIRED) # Requires at least version 3.0
+
+set(CMAKE_C_STANDARD 11) # Requires C11 standard
+
+add_executable(${PROJECT_NAME} src/main.cpp src/window.cpp src/gameplay.cpp)
+
+target_link_libraries(${PROJECT_NAME} raylib m pthread dl)
+
+# Checks if OSX and links appropriate frameworks (only required on MacOS)
+if (APPLE)
+ target_link_libraries(${PROJECT_NAME} "-framework IOKit")
+ target_link_libraries(${PROJECT_NAME} "-framework Cocoa")
+ target_link_libraries(${PROJECT_NAME} "-framework OpenGL")
+endif()
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
new file mode 100644
index 0000000..4368954
--- /dev/null
+++ b/src/gameplay.cpp
@@ -0,0 +1,23 @@
+#include "gameplay.hpp"
+
+Enemy::Enemy(void)
+{
+ posX = GetRandomValue(0, SCREENWIDTH);
+ posY = GetRandomValue(0, SCREENHEIGHT);
+ direction = (Vector2){posX, posY};
+}
+
+Enemy::~Enemy() {}
+Game::~Game() {}
+
+Game::Game(void)
+{
+ nEnemies = GetRandomValue(0, 15);
+
+ enemies = new Enemy[15];
+}
+
+void Game::start() const
+{
+
+}
diff --git a/src/gameplay.hpp b/src/gameplay.hpp
new file mode 100644
index 0000000..3b611fe
--- /dev/null
+++ b/src/gameplay.hpp
@@ -0,0 +1,27 @@
+#ifndef GAMEPLAY_H_
+#define GAMEPLAY_H_
+
+#include "window.hpp"
+
+class Enemy {
+ float posX;
+ float posY;
+ Vector2 direction;
+ public:
+ Enemy();
+ ~Enemy();
+};
+
+class Game {
+ int nEnemies;
+
+ Enemy * enemies;
+
+ public:
+ Game();
+ ~Game();
+
+ void start() const ;
+};
+
+#endif // GAMEPLAY_H_
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..f5a27af
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,58 @@
+#include "window.hpp"
+#include "gameplay.hpp"
+#include <iostream>
+
+gameState gs = TITLE;
+
+Game* game = new Game;
+
+int main(void) {
+ initWindow();
+
+ // Main game loop
+ while (!WindowShouldClose()) /* Detect window close button or ESC key */
+ {
+ switch (gs) {
+ case (TITLE):
+ {
+ if (IsKeyPressed(KEY_ENTER))
+ {
+ gs = GAMEPLAY;
+ }
+ break ;
+ }
+ case (GAMEPLAY):
+ {
+ break ;
+ }
+ case (ENDING):
+ {
+ break ;
+ }
+ }
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ switch (gs) {
+ case (TITLE):
+ {
+ DrawText("LOGO SCREEN", 20, 20, 40, LIGHTGRAY);
+ break ;
+ }
+ case (GAMEPLAY):
+ {
+ game->start();
+ break ;
+ }
+ case (ENDING):
+ {
+ DrawText("GOOD BYE SCREEN", 20, 20, 40, LIGHTGRAY);
+ break ;
+ }
+ }
+ EndDrawing();
+ }
+ CloseWindow();
+ return 0;
+}
diff --git a/src/window.cpp b/src/window.cpp
new file mode 100644
index 0000000..17731c0
--- /dev/null
+++ b/src/window.cpp
@@ -0,0 +1,11 @@
+#include "window.hpp"
+
+int
+initWindow(void) {
+ // Initialization
+ InitWindow(SCREENWIDTH, SCREENHEIGHT, "WIP -- coolspace");
+ InitAudioDevice();
+ SetTargetFPS(60);
+
+ return (0);
+}
diff --git a/src/window.hpp b/src/window.hpp
new file mode 100644
index 0000000..82abd2a
--- /dev/null
+++ b/src/window.hpp
@@ -0,0 +1,15 @@
+#ifndef WINDOW_H_
+#define WINDOW_H_
+
+#include "raylib.h"
+
+int initWindow(void);
+
+#define SCREENWIDTH 800
+#define SCREENHEIGHT 450
+
+typedef enum gameState {
+TITLE = 0, GAMEPLAY, ENDING
+} gameState ;
+
+#endif // WINDOW_H_