Skip to content

Commit

Permalink
refactor: rename project and remove boilerplate projects
Browse files Browse the repository at this point in the history
  • Loading branch information
developer239 committed Dec 3, 2023
1 parent e936121 commit f4893b8
Show file tree
Hide file tree
Showing 40 changed files with 4 additions and 621 deletions.
89 changes: 1 addition & 88 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CPP Starter
# AoC Day 3 Visual

![master](https://github.com/developer239/cpp-starter/actions/workflows/ci.yml/badge.svg)

Expand Down Expand Up @@ -32,90 +32,3 @@ $ ctest
$ cd build/src/apps/pong
$ ./AppPong
```

## Project Structure

The project is structured into various directories, each serving a specific purpose:

- `src`: The main source directory.
- `apps`: Contains individual applications. Example: `pong`.
- `packages`: Contains shared libraries or modules. Examples: `core`, `ecs`, `events`.

### App Structure

- Each app, like `pong`, contains its source code, assets, and CMake configurations.
- Structure inside an app:
- `src`: Source files for the application.
- `assets`: Game assets like fonts and images.

### Package Structure

- Shared functionalities are grouped into packages under `packages`.
- Examples include `core` for core functionalities, `ecs` for entity-component systems.

## Creating New Apps and Packages

### Apps

1. To create a new app, add a directory under `src/apps`.
2. Include a `CMakeLists.txt` in your app directory for build configurations.
3. Organize your app's source code, assets, and tests within this directory.
4. Include new app in the src `CMakeLists.txt`.

Example:

```cmake
set(APP_NAME AppPong)
set(APP_FOLDER_NAME pong)
set(SOURCES
src/main.cpp
src/entities/GameObject.h
src/strategies/MinimalLoopStrategy.h
)
add_executable(${APP_NAME} ${SOURCES})
# Copy assets
file(COPY assets DESTINATION ${CMAKE_BINARY_DIR}/src/apps/${APP_FOLDER_NAME})
target_link_libraries(${APP_NAME} Core)
```

### Packages

1. Create a new package under `packages` for shared functionalities.
2. Each package should have its own `CMakeLists.txt`.
3. Include the package in src `CMakeLists.txt`.

## Writing Tests

- Tests are written using GoogleTest and GoogleMock.
- Each app or package should contain its test files, e.g., `GameObject.test.cpp`.
- Use `add_test` in `CMakeLists.txt` to include tests in the build process.

If you want to include tests for your app, add the following to your `CMakeLists.txt`:

```cmake
set(APP_NAME_TEST ${LIB_NAME}Test)
add_test(AllTests${LIB_NAME} ${APP_NAME_TEST})
set(SOURCES_TEST
src/entities/GameObject.h
src/strategies/MinimalLoopStrategy.h
src/entities/GameObject.test.cpp
src/strategies/MinimalLoopStrategy.test.cpp)
add_executable(${APP_NAME_TEST} ${SOURCES_TEST})
target_link_libraries(${APP_NAME_TEST} PRIVATE
gtest
gmock
gmock_main
Core
SDL2::SDL2
)
```

![test-preview](./e2e-test-preview.gif)
Binary file removed e2e-test-preview.gif
Binary file not shown.
4 changes: 1 addition & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
add_subdirectory(apps/pong)
add_subdirectory(apps/pong-e2e)
add_subdirectory(apps/pong-ecs)
add_subdirectory(apps/day3)

add_subdirectory(packages/core)
add_subdirectory(packages/core-imgui)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set(APP_NAME AppPongECS)
set(APP_FOLDER_NAME pong-ecs)
set(APP_NAME Day3)
set(APP_FOLDER_NAME day3)

set(APP_NAME_TEST ${LIB_NAME}Test)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ class PuzzleSolverSystem : public ECS::System {
partEntities.clear();
}

int GetSum() const { return sumOfParts; }

private:
std::unordered_set<ECS::Entity> partEntities;
int sumOfParts = 0;
Expand Down
25 changes: 0 additions & 25 deletions src/apps/pong-e2e/CMakeLists.txt

This file was deleted.

28 changes: 0 additions & 28 deletions src/apps/pong-e2e/src/PongE2ETest.cpp

This file was deleted.

25 changes: 0 additions & 25 deletions src/apps/pong-e2e/src/PongE2ETest.h

This file was deleted.

9 changes: 0 additions & 9 deletions src/apps/pong-e2e/src/main.cpp

This file was deleted.

78 changes: 0 additions & 78 deletions src/apps/pong-e2e/src/tests/collision.test.cpp

This file was deleted.

62 changes: 0 additions & 62 deletions src/apps/pong-e2e/src/tests/paddle.test.cpp

This file was deleted.

38 changes: 0 additions & 38 deletions src/apps/pong/CMakeLists.txt

This file was deleted.

Binary file removed src/apps/pong/assets/fonts/pico8.ttf
Binary file not shown.
Loading

0 comments on commit f4893b8

Please sign in to comment.