diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..59cc32a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/include/cute_headers-master \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..3086f2c --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,28 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "(gdb) Launch", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/bin/main", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}/bin", + "environment": [], + "externalConsole": true, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + "preLaunchTask": "build" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..ef6f0e0 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,34 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "type": "shell", + "command": "make", + "group": "build", + "problemMatcher": "$gcc" + }, + { + "type": "cppbuild", + "label": "C/C++: g++ build active file", + "command": "/usr/bin/g++", + "args": [ + "-g", + "${file}", + "-o", + "${fileDirname}/${fileBasenameNoExtension}" + ], + "options": { + "cwd": "${workspaceFolder}/bin/main" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Task generated by Debugger." + } + ] +} \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c3625a8 --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +CXX := g++ +CXX_FLAGS := -std=c++17 -ggdb + +BIN := bin +SRC := src +INCLUDE := include + +LIBRARIES := +EXECUTABLE := main + + +all: $(BIN)/$(EXECUTABLE) + +run: clean all + clear + ./$(BIN)/$(EXECUTABLE) + +$(BIN)/$(EXECUTABLE): $(SRC)/*.cpp $(SRC)/components/*.cpp $(SRC)/imgui/*.cpp $(SRC)/logic/*.cpp $(SRC)/shaders/*.cpp $(SRC)/textureManager/*.cpp src/glad.c + $(CXX) $(CXX_FLAGS) -I$(INCLUDE) -I$(INCLUDE)/imgui -I$(INCLUDE)/logic $^ -o $@ $(LIBRARIES) -lGL -lglfw3 -lX11 -lXxf86vm -lXrandr -lpthread -lXi -ldl -lXinerama -lXcursor + +clean: + -rm $(BIN)/* \ No newline at end of file diff --git a/Project1.vcxproj b/Project1.vcxproj deleted file mode 100644 index ec45d2f..0000000 --- a/Project1.vcxproj +++ /dev/null @@ -1,209 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - {851AA053-F6FF-4194-AD1A-FE25D73B16CF} - Project1 - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - true - C:\API\opengl\include;$(IncludePath) - C:\API\opengl\libs;$(LibraryPath) - - - false - - - false - C:\API\opengl\include;$(IncludePath) - C:\API\opengl\libs;$(LibraryPath) - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - GLFW\glfw3.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - GLFW\glfw3.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Project1.vcxproj.filters b/Project1.vcxproj.filters deleted file mode 100644 index 12800c7..0000000 --- a/Project1.vcxproj.filters +++ /dev/null @@ -1,165 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - - - - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - - - - - \ No newline at end of file diff --git a/Project1.vcxproj.user b/Project1.vcxproj.user deleted file mode 100644 index 429333d..0000000 --- a/Project1.vcxproj.user +++ /dev/null @@ -1,6 +0,0 @@ - - - - true - - \ No newline at end of file diff --git a/imgui.ini b/bin/imgui.ini similarity index 54% rename from imgui.ini rename to bin/imgui.ini index da24cdf..e425069 100644 --- a/imgui.ini +++ b/bin/imgui.ini @@ -1,15 +1,10 @@ -[Window][Debug##Default] -Pos=60,60 -Size=400,400 -Collapsed=0 - -[Window][Hello, world!] -Pos=60,60 -Size=345,180 -Collapsed=0 - -[Window][babyboigame] -Pos=290,196 -Size=352,243 -Collapsed=0 - +[Window][Debug##Default] +Pos=60,60 +Size=400,400 +Collapsed=0 + +[Window][babyboigame] +Pos=60,60 +Size=352,249 +Collapsed=0 + diff --git a/bin/main b/bin/main new file mode 100755 index 0000000..2b8d7cb Binary files /dev/null and b/bin/main differ diff --git a/shaders/shader.frag b/bin/shaders/shader.frag similarity index 100% rename from shaders/shader.frag rename to bin/shaders/shader.frag diff --git a/shaders/shader.vert b/bin/shaders/shader.vert similarity index 100% rename from shaders/shader.vert rename to bin/shaders/shader.vert diff --git a/shaders/shaderTilemap.frag b/bin/shaders/shaderTilemap.frag similarity index 100% rename from shaders/shaderTilemap.frag rename to bin/shaders/shaderTilemap.frag diff --git a/shaders/shaderTilemap.vert b/bin/shaders/shaderTilemap.vert similarity index 100% rename from shaders/shaderTilemap.vert rename to bin/shaders/shaderTilemap.vert diff --git a/animationManager.h b/include/animationManager.h similarity index 100% rename from animationManager.h rename to include/animationManager.h diff --git a/enemy.h b/include/enemy.h similarity index 90% rename from enemy.h rename to include/enemy.h index 6dd9929..c56fcf9 100644 --- a/enemy.h +++ b/include/enemy.h @@ -1,13 +1,13 @@ #pragma once -#include +#include #include #include #include "iostream" #include //#include -#include "SpriteRenderer.h" +#include "spriteRenderer.h" #include "resourceManager.h" #include "animationManager.h" diff --git a/game.h b/include/game.h similarity index 84% rename from game.h rename to include/game.h index db76d8c..ff75fda 100644 --- a/game.h +++ b/include/game.h @@ -1,5 +1,5 @@ #pragma once -#include +#include #include #include @@ -11,11 +11,11 @@ #include #include "resourceManager.h" -#include "SpriteRenderer.h" -#include "Player.h" -#include "Enemy.h" -#include "Object.h" -#include "terrainFile/world.h" +#include "spriteRenderer.h" +#include "player.h" +#include "enemy.h" +#include "object.h" +#include "world.h" #include #include diff --git a/vendor/imconfig.h b/include/imgui/imconfig.h similarity index 100% rename from vendor/imconfig.h rename to include/imgui/imconfig.h diff --git a/vendor/imgui.h b/include/imgui/imgui.h similarity index 100% rename from vendor/imgui.h rename to include/imgui/imgui.h diff --git a/vendor/imgui_impl_glfw.h b/include/imgui/imgui_impl_glfw.h similarity index 100% rename from vendor/imgui_impl_glfw.h rename to include/imgui/imgui_impl_glfw.h diff --git a/vendor/imgui_impl_opengl3.h b/include/imgui/imgui_impl_opengl3.h similarity index 100% rename from vendor/imgui_impl_opengl3.h rename to include/imgui/imgui_impl_opengl3.h diff --git a/vendor/imgui_internal.h b/include/imgui/imgui_internal.h similarity index 100% rename from vendor/imgui_internal.h rename to include/imgui/imgui_internal.h diff --git a/vendor/imstb_rectpack.h b/include/imgui/imstb_rectpack.h similarity index 100% rename from vendor/imstb_rectpack.h rename to include/imgui/imstb_rectpack.h diff --git a/vendor/imstb_textedit.h b/include/imgui/imstb_textedit.h similarity index 100% rename from vendor/imstb_textedit.h rename to include/imgui/imstb_textedit.h diff --git a/vendor/imstb_truetype.h b/include/imgui/imstb_truetype.h similarity index 100% rename from vendor/imstb_truetype.h rename to include/imgui/imstb_truetype.h diff --git a/resourceManager.h b/include/logic/resourceManager.h similarity index 92% rename from resourceManager.h rename to include/logic/resourceManager.h index 95dcc36..51013a5 100644 --- a/resourceManager.h +++ b/include/logic/resourceManager.h @@ -3,11 +3,11 @@ #include #include -#include +#include #include -#include "textureManager/texture.h" -#include "shaders/shader.h" +#include "texture.h" +#include "shader.h" // A static singleton ResourceManager class that hosts several diff --git a/shaders/Shader.h b/include/logic/shader.h similarity index 100% rename from shaders/Shader.h rename to include/logic/shader.h diff --git a/SpriteRenderer.h b/include/logic/spriteRenderer.h similarity index 84% rename from SpriteRenderer.h rename to include/logic/spriteRenderer.h index ba84aeb..ea61971 100644 --- a/SpriteRenderer.h +++ b/include/logic/spriteRenderer.h @@ -1,10 +1,10 @@ #pragma once -#include +#include #include #include -#include "textureManager/texture.h" -#include "shaders/shader.h" +#include "texture.h" +#include "shader.h" class SpriteRenderer diff --git a/textureManager/texture.h b/include/logic/texture.h similarity index 95% rename from textureManager/texture.h rename to include/logic/texture.h index 1fde1e8..e922e35 100644 --- a/textureManager/texture.h +++ b/include/logic/texture.h @@ -1,7 +1,7 @@ #pragma once // Texture2D is able to store and configure a texture in OpenGL. // It also hosts utility functions for easy management. -#include +#include class Texture { diff --git a/Object.h b/include/object.h similarity index 87% rename from Object.h rename to include/object.h index 1f17713..fd89edf 100644 --- a/Object.h +++ b/include/object.h @@ -1,12 +1,12 @@ #pragma once -#include "SpriteRenderer.h" +#include "spriteRenderer.h" #include "resourceManager.h" #include "animationManager.h" #include -#include +#include #include #include #include diff --git a/Player.h b/include/player.h similarity index 90% rename from Player.h rename to include/player.h index 4dce7fe..7cf76b3 100644 --- a/Player.h +++ b/include/player.h @@ -1,13 +1,13 @@ #pragma once -#include +#include #include #include #include "iostream" #include //#include -#include "SpriteRenderer.h" +#include "spriteRenderer.h" #include "resourceManager.h" #include "animationManager.h" diff --git a/terrainFile/world.h b/include/world.h similarity index 69% rename from terrainFile/world.h rename to include/world.h index 63dce06..effefd3 100644 --- a/terrainFile/world.h +++ b/include/world.h @@ -2,12 +2,12 @@ #include #include -#include "../Object.h" +#include "object.h" class World { public: - Texture Sprite = ResourceManager::LoadTexture("art/terrain/dirt.png", "dirtSheet"); + Texture Sprite = ResourceManager::LoadTexture("../art/terrain/dirt.png", "dirtSheet"); glm::vec2 blocksize; std::vector objects; std::vector> tileData; diff --git a/enemy.cpp b/src/components/enemy.cpp similarity index 95% rename from enemy.cpp rename to src/components/enemy.cpp index d8210fd..1a3bd4a 100644 --- a/enemy.cpp +++ b/src/components/enemy.cpp @@ -1,4 +1,4 @@ -#include "Enemy.h" +#include "enemy.h" Enemy::Enemy(glm::vec2 pos, glm::vec2 size) :Position(pos), Size(size) diff --git a/Object.cpp b/src/components/object.cpp similarity index 96% rename from Object.cpp rename to src/components/object.cpp index 07fbd5f..185d31a 100644 --- a/Object.cpp +++ b/src/components/object.cpp @@ -1,4 +1,4 @@ -#include "Object.h" +#include "object.h" Object::Object(Texture sprite, glm::vec2 pos, glm::vec2 size, int blockType) :Sprite(sprite),Position(pos),Size(size), blockType(blockType) diff --git a/Player.cpp b/src/components/player.cpp similarity index 93% rename from Player.cpp rename to src/components/player.cpp index aaeed21..fae9c37 100644 --- a/Player.cpp +++ b/src/components/player.cpp @@ -1,9 +1,9 @@ -#include "Player.h" +#include "player.h" Player::Player(glm::vec2 pos, glm::vec2 size) :Position(pos), Size(size) { - ResourceManager::LoadTexture("art/player/playerAnim.png", "idle1"); + ResourceManager::LoadTexture("../art/player/playerAnim.png", "idle1"); this->Sprite = ResourceManager::GetTexture("idle1"); } Player::~Player(){} diff --git a/terrainFile/world.cpp b/src/components/world.cpp similarity index 100% rename from terrainFile/world.cpp rename to src/components/world.cpp diff --git a/game.cpp b/src/game.cpp similarity index 97% rename from game.cpp rename to src/game.cpp index a08e58e..6da3f96 100644 --- a/game.cpp +++ b/src/game.cpp @@ -1,4 +1,4 @@ -#include "Game.h" +#include "game.h" void framebuffer_size_callback(GLFWwindow* window, int width, int height); diff --git a/glad.c b/src/glad.c similarity index 100% rename from glad.c rename to src/glad.c diff --git a/vendor/imgui.cpp b/src/imgui/imgui.cpp similarity index 100% rename from vendor/imgui.cpp rename to src/imgui/imgui.cpp diff --git a/vendor/imgui_demo.cpp b/src/imgui/imgui_demo.cpp similarity index 100% rename from vendor/imgui_demo.cpp rename to src/imgui/imgui_demo.cpp diff --git a/vendor/imgui_draw.cpp b/src/imgui/imgui_draw.cpp similarity index 100% rename from vendor/imgui_draw.cpp rename to src/imgui/imgui_draw.cpp diff --git a/vendor/imgui_impl_glfw.cpp b/src/imgui/imgui_impl_glfw.cpp similarity index 100% rename from vendor/imgui_impl_glfw.cpp rename to src/imgui/imgui_impl_glfw.cpp diff --git a/vendor/imgui_impl_opengl3.cpp b/src/imgui/imgui_impl_opengl3.cpp similarity index 100% rename from vendor/imgui_impl_opengl3.cpp rename to src/imgui/imgui_impl_opengl3.cpp diff --git a/vendor/imgui_widgets.cpp b/src/imgui/imgui_widgets.cpp similarity index 100% rename from vendor/imgui_widgets.cpp rename to src/imgui/imgui_widgets.cpp diff --git a/resourceManager.cpp b/src/logic/resourceManager.cpp similarity index 100% rename from resourceManager.cpp rename to src/logic/resourceManager.cpp diff --git a/SpriteRenderer.cpp b/src/logic/spriteRenderer.cpp similarity index 96% rename from SpriteRenderer.cpp rename to src/logic/spriteRenderer.cpp index 2519434..acc415d 100644 --- a/SpriteRenderer.cpp +++ b/src/logic/spriteRenderer.cpp @@ -1,4 +1,4 @@ -#include "SpriteRenderer.h" +#include "spriteRenderer.h" SpriteRenderer::SpriteRenderer(Shader& shader) diff --git a/shaders/Shader.cpp b/src/shaders/shader.cpp similarity index 100% rename from shaders/Shader.cpp rename to src/shaders/shader.cpp diff --git a/src/shaders/shader.frag b/src/shaders/shader.frag new file mode 100644 index 0000000..ddc95a3 --- /dev/null +++ b/src/shaders/shader.frag @@ -0,0 +1,14 @@ +#version 330 core +in vec2 texCoord; + +out vec4 fragColor; + +uniform sampler2D image; + +void main() +{ + vec4 texColor = texture(image, texCoord); + if(texColor.a < 0.1) + discard; + fragColor = texColor; +} \ No newline at end of file diff --git a/src/shaders/shader.vert b/src/shaders/shader.vert new file mode 100644 index 0000000..d14df44 --- /dev/null +++ b/src/shaders/shader.vert @@ -0,0 +1,15 @@ +#version 330 core + +layout (location = 0) in vec4 aPos; + +uniform mat4 model; +uniform mat4 view; +uniform mat4 projection; + +out vec2 texCoord; + +void main() +{ + gl_Position = projection * view * vec4(aPos.xy,0.0,1.0); + texCoord = aPos.zw; +} \ No newline at end of file diff --git a/src/shaders/shaderTilemap.frag b/src/shaders/shaderTilemap.frag new file mode 100644 index 0000000..ddc95a3 --- /dev/null +++ b/src/shaders/shaderTilemap.frag @@ -0,0 +1,14 @@ +#version 330 core +in vec2 texCoord; + +out vec4 fragColor; + +uniform sampler2D image; + +void main() +{ + vec4 texColor = texture(image, texCoord); + if(texColor.a < 0.1) + discard; + fragColor = texColor; +} \ No newline at end of file diff --git a/src/shaders/shaderTilemap.vert b/src/shaders/shaderTilemap.vert new file mode 100644 index 0000000..6ce2ab9 --- /dev/null +++ b/src/shaders/shaderTilemap.vert @@ -0,0 +1,15 @@ +#version 330 core + +layout (location = 0) in vec4 aPos; + +uniform mat4 model; +uniform mat4 view; +uniform mat4 projection; +uniform int offset[]; +out vec2 texCoord; + +void main() +{ + gl_Position = projection * view * model * vec4(aPos.xy,0.0,1.0); + texCoord = aPos.zw; +} \ No newline at end of file diff --git a/Source.cpp b/src/source.cpp similarity index 100% rename from Source.cpp rename to src/source.cpp diff --git a/stb_image.cpp b/src/stb_image.cpp similarity index 100% rename from stb_image.cpp rename to src/stb_image.cpp diff --git a/textureManager/texture.cpp b/src/textureManager/texture.cpp similarity index 100% rename from textureManager/texture.cpp rename to src/textureManager/texture.cpp