-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from amantham20/main
Updating Dev to Latest
- Loading branch information
Showing
11 changed files
with
235 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# vscode cmake build | ||
build | ||
|
||
# clion cmake build | ||
cmake-build-debug | ||
cmake-build-release | ||
|
||
# clion settings | ||
.idea/ | ||
|
||
# vscode settings | ||
.vscode/ | ||
.github/ | ||
|
||
# Vim swap files | ||
*.swp | ||
*.swo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "third_party/Catch2"] | ||
path = third_party/Catch2 | ||
url = https://github.com/catchorg/Catch2.git | ||
[submodule "third_party/SFML"] | ||
path = third_party/SFML | ||
url = https://github.com/SFML/SFML.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
cmake_minimum_required(VERSION 3.12) | ||
|
||
project(CSE_491) | ||
|
||
set(CMAKE_CXX_STANDARD 20) | ||
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wcast-align -Winfinite-recursion -Wnon-virtual-dtor -Wnull-dereference -Woverloaded-virtual -pedantic") | ||
|
||
set(CMAKE_CXX_FLAGS_DEBUG "-g") | ||
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") | ||
set(CMAKE_CXX_FLAGS_MINSIZEREL "-DNDEBUG") | ||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g") | ||
|
||
# all the possible executables [each team can have their own configuration] | ||
# copy over simple or same and change the accordingly | ||
set(EXECUTABLES simple sfml_example) | ||
|
||
|
||
# setting the output path to executable | ||
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/executable) | ||
|
||
|
||
# moving assets to build | ||
file(COPY ./assets DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
|
||
# Configure SFML | ||
set(SFML_SRC_DIR third_party/SFML) | ||
set(SFML_BUILD_DIR sfml_build) | ||
set(MAIN_SOURCE_DIR ./) | ||
add_subdirectory(${SFML_SRC_DIR} ${SFML_BUILD_DIR}) | ||
|
||
|
||
foreach(EXECUTABLE ${EXECUTABLES}) | ||
set(SOURCES source/${EXECUTABLE}_main.cpp) | ||
add_executable(${EXECUTABLE} ${SOURCES}) | ||
target_include_directories(${EXECUTABLE} | ||
PRIVATE ${MAIN_SOURCE_DIR} | ||
) | ||
target_link_libraries(${EXECUTABLE} | ||
PRIVATE sfml-window sfml-audio sfml-graphics | ||
) | ||
endforeach() | ||
|
||
|
||
add_subdirectory(tests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# How to Compile | ||
|
||
First you'll need to clone the repo _with submodules_. | ||
|
||
If you haven't yet cloned the repo, run: | ||
``` | ||
git clone https://github.com/MSU-CSE491/cse_491_fall_2023.git --recursive | ||
``` | ||
|
||
If you _have_ already cloned the repo, but you need to download the submodules, run the following inside the repo's directory: | ||
``` | ||
git submodule init | ||
git submodule update | ||
``` | ||
|
||
Now jump to the section for your operating system. | ||
|
||
## Compiling under Linux | ||
|
||
If you're on a Linux machine, you first need to download some dependencies for SFML. | ||
Specifically, you need: | ||
- freetype | ||
- x11 | ||
- xrandr | ||
- udev | ||
- opengl | ||
- flac | ||
- ogg | ||
- vorbis | ||
- vorbisenc | ||
- vorbisfile | ||
- openal | ||
- pthread | ||
|
||
If you're on Ubuntu or other similar Debian distro, you can run the following: | ||
``` | ||
sudo apt install libX-dev | ||
``` | ||
For library X. | ||
|
||
Once you have all dependencies downloaded, navigate to the root of the repo and run the following to build: | ||
``` | ||
mkdir build | ||
cd build | ||
cmake .. | ||
cmake --build . | ||
``` | ||
All compiled executables should be in the `/build/executables/` directory. | ||
|
||
## Compiling under MacOS | ||
|
||
Mac shouldn't require any additional dependencies, so simply run the following, starting at the root of the repo: | ||
``` | ||
mkdir build | ||
cd build | ||
cmake .. | ||
cmake --build . | ||
``` | ||
All compiled executables should be in the `/build/executables/` directory. | ||
|
||
## Compiling under Windows with MinGW | ||
|
||
After you have the repo and submodules downloaded, we need to ensure you have MinGW and CMake. | ||
In a command line window, try running `g++` and `cmake`, if either give a "command not found" message, then we need to install them. | ||
|
||
MinGW gives us g++, and can be downloaded here: https://winlibs.com/ | ||
|
||
CMake can be downloaded from here: https://cmake.org/download/ | ||
|
||
***Note:*** You'll likely need to add both MinGW's and CMake's `bin` folder to your path (I think CMake has a `bin` directory, otherwise add whatever directory contains the executable). | ||
To add a directory to your path, follow these instructions: https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/ | ||
Note that you may run into issues if the directories you're adding have spaces in their paths (e.g., "C:\Program Files\..." was giving me issues). If you run into this, I'd recommend creating a new directory on your `C:\` drive, like `C:\bin\` and then add CMake and MinGW as subdirectories there. | ||
|
||
Once you have CMake and MinGW working in your terminal (note you'll have to restart cmd/VSCode/whatever to get the path changes to take effect), run the following from the root of your repo: | ||
``` | ||
mkdir build | ||
cd build | ||
cmake -G "MinGW Makefiles" .. | ||
cmake --build . | ||
``` | ||
|
||
All compiled executables should be in the `/build/executables/` directory. | ||
|
||
Note that if you tried to build using CMake before, it likely tried to use MSVC as a compiler. If so, just wipe the build folder and start fresh. | ||
|
||
## How to compile in debug mode | ||
|
||
To compile in debug mode, simply add `-DCMAKE_BUILD_TYPE=Debug` to the first cmake command. | ||
|
||
This would normally look like: | ||
``` | ||
cmake -DCMAKE_BUILD_TYPE=Debug .. | ||
``` | ||
Unless you're on Windows, which would be: | ||
|
||
``` | ||
cmake -DCMAKE_BUILD_TYPE=Debug -G "MinGW Makefiles" .. | ||
``` | ||
|
||
You can then build like normal. | ||
|
||
Note that you can also replace `Debug` with `Release` to compile with optimizations. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,3 +36,4 @@ FILES_generated = *.o $(EXECUTABLES) | |
|
||
clean: | ||
rm -rf $(FILES_backup) $(FILES_generated) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include <iostream> | ||
|
||
#include "SFML/Graphics.hpp" | ||
|
||
int main(){ | ||
|
||
// Create the window | ||
sf::RenderWindow window(sf::VideoMode({800, 600}), "SFML works!"); | ||
window.setFramerateLimit(60); | ||
// Create our tile and its properties | ||
const int tile_size = 20; | ||
sf::RectangleShape rect(sf::Vector2f(tile_size, tile_size)); | ||
rect.setFillColor(sf::Color(200, 50, 0)); | ||
sf::Vector2f rect_pos(window.getSize().x / 2, window.getSize().y / 2); | ||
sf::Vector2f rect_vel(200,200); | ||
|
||
sf::Clock clock; // Create a clock to help calculate delta time | ||
while(window.isOpen()){ | ||
auto delta_time = clock.restart().asSeconds(); | ||
|
||
// Handle input | ||
sf::Event event; | ||
while (window.pollEvent(event)) | ||
{ | ||
if (event.type == sf::Event::Closed) break; | ||
} | ||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape) | ||
|| sf::Keyboard::isKeyPressed(sf::Keyboard::Q)){ | ||
break; | ||
} | ||
|
||
// Update rectangle, including collision | ||
rect_pos += rect_vel * delta_time; | ||
if(rect_pos.x + rect.getSize().x > window.getSize().x){ | ||
rect_pos.x = window.getSize().x - rect.getSize().x; | ||
rect_vel.x *= -1; | ||
} | ||
else if(rect_pos.x < 0){ | ||
rect_pos.x = 0; | ||
rect_vel.x *= -1; | ||
} | ||
if(rect_pos.y + rect.getSize().y > window.getSize().y){ | ||
rect_pos.y = window.getSize().y - rect.getSize().y; | ||
rect_vel.y *= -1; | ||
} | ||
else if(rect_pos.y < 0){ | ||
rect_pos.y = 0; | ||
rect_vel.y *= -1; | ||
} | ||
|
||
// Render! | ||
window.clear(sf::Color::Black); | ||
rect.setPosition(rect_pos); | ||
window.draw(rect); | ||
window.display(); | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters