Initial Commit
This commit is contained in:
commit
7de5a8a681
21
.gitignore
vendored
Normal file
21
.gitignore
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
# Ignore Build Directories
|
||||
build/
|
||||
build-vs/
|
||||
build-ninja/
|
||||
cmake-build-debug/
|
||||
|
||||
# IDE Generated Files
|
||||
.atom/
|
||||
.vscode/
|
||||
.jb/
|
||||
.idea/
|
||||
|
||||
# Editor Specific Files
|
||||
compile_commands.json
|
||||
|
||||
# Util Scripts
|
||||
venv/
|
||||
typer.py
|
||||
|
||||
# Cache Files
|
||||
.cache/
|
21
CMakeLists.txt
Normal file
21
CMakeLists.txt
Normal file
@ -0,0 +1,21 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(FarmFighter)
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
raylib
|
||||
URL https://github.com/raysan5/raylib/archive/refs/tags/4.5.0.tar.gz
|
||||
)
|
||||
FetchContent_MakeAvailable(raylib)
|
||||
|
||||
# Avoid building the examples and games from raylib
|
||||
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||
set(BUILD_GAMES OFF CACHE BOOL "" FORCE)
|
||||
|
||||
add_subdirectory(networking)
|
||||
add_subdirectory(engine)
|
||||
add_subdirectory(client)
|
||||
add_subdirectory(server)
|
106
README.md
Normal file
106
README.md
Normal file
@ -0,0 +1,106 @@
|
||||
# Farm Fighter
|
||||
|
||||
Welcome to **Farm Fighter**, a fun 2d multiplayer game where you can run around, explore the world, and start your farming empire! But don't forget to defend your crops from the locals!
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [About the Game](#about-the-game)
|
||||
- [Features](#features)
|
||||
- [Installation](#installation)
|
||||
- [Running the Game](#running-the-game)
|
||||
- [Controls](#controls)
|
||||
- [Game Mechanics](#game-mechanics)
|
||||
- [Cloning and Building](#cloning-and-building)
|
||||
- [Contributing](#contributing)
|
||||
- [License](#license)
|
||||
|
||||
## About the Game
|
||||
|
||||
**Farm Fighter** is a multiplayer game set on the planet, Lutum. In this (mostly) open world, you can run around, loot structures, gather seeds, and choose an area to build your base! Make sure you explore, as only certain resources can be found in certain bioms in the world.
|
||||
|
||||
## Features
|
||||
|
||||
- **Multiplayer Gameplay:** Just a server you play the game on.
|
||||
- **Weapons:** What if we had guns... that shoot spuds!
|
||||
- **Farm Raids:** Make sure you defend your crops, because at night the locals will come and attack your farm!
|
||||
|
||||
## Installation
|
||||
|
||||
To get started with **Farm Fighter**, follow these steps:
|
||||
|
||||
1. **Clone the Repository** (see [Cloning and Building](#cloning-and-building) section below).
|
||||
2. **Build the Project:** Use CMake to generate build files for your platform.
|
||||
3. **Run the Game:** Execute the compiled game binary to start playing.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- **CMake:** Ensure that CMake is installed on your system.
|
||||
- **Compiler:** A C++ compiler that supports C++23 or later.
|
||||
- **Libraries:** The game may require additional libraries, which will be listed in the `CMakeLists.txt` file (these libraries should be auto installed by cmake).
|
||||
|
||||
## Running the Game
|
||||
|
||||
Once you have built the project, you can run the game by executing the generated binary, usually in `./client/` (and `./server/` for the server binary)
|
||||
|
||||
## Controls
|
||||
|
||||
- **Movement:** WASD or Arrow Keys
|
||||
- **Attack:** Left Mouse Button or Spacebar
|
||||
- **Inventory:** I
|
||||
- **Pause Menu:** Escape
|
||||
|
||||
## Game Mechanics
|
||||
|
||||
- **Health and Damage:** Each character has a health bar that decreases when taking damage. The last player standing wins.
|
||||
- **Survivability:** You have a hunger and thirst meter, make sure they don't go to 0 or you'll start to die!
|
||||
|
||||
## Cloning and Building
|
||||
|
||||
To clone and build **Farm Fighter**, follow these instructions:
|
||||
|
||||
1. **Clone the Repository:**
|
||||
|
||||
```bash
|
||||
git clone https://proudcircle.xyz/illyum/FarmFighter.git
|
||||
cd FarmFighter
|
||||
```
|
||||
Create a Build Directory:
|
||||
|
||||
It's recommended to build in a separate directory from the source.
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
```
|
||||
|
||||
Generate Build Files with CMake:
|
||||
|
||||
Run the following command to generate the build files:
|
||||
|
||||
```bash
|
||||
cmake ..
|
||||
```
|
||||
|
||||
Build the Project:
|
||||
|
||||
After generating the build files, compile the project:
|
||||
|
||||
```bash
|
||||
cmake --build .
|
||||
```
|
||||
|
||||
Run the Game:
|
||||
|
||||
Once the build process completes, you can run the game executable found in the build directory.
|
||||
|
||||
```bash
|
||||
./client/client
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
As this is a solo project made for fun, contributions are currently not being accepted. However, feel free to fork the project and experiment on your own!
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the ??? License - see the LICENSE file for details.
|
75
client/CMakeLists.txt
Normal file
75
client/CMakeLists.txt
Normal file
@ -0,0 +1,75 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(Client)
|
||||
|
||||
set(FETCHCONTENT_QUIET OFF)
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
imgui
|
||||
GIT_REPOSITORY https://github.com/ocornut/imgui.git
|
||||
GIT_SHALLOW TRUE
|
||||
GIT_TAG master
|
||||
)
|
||||
FetchContent_MakeAvailable(imgui)
|
||||
|
||||
# Build ImGui as a static library
|
||||
add_library(ImGui STATIC
|
||||
${imgui_SOURCE_DIR}/imgui.cpp
|
||||
${imgui_SOURCE_DIR}/imgui_demo.cpp
|
||||
${imgui_SOURCE_DIR}/imgui_draw.cpp
|
||||
${imgui_SOURCE_DIR}/imgui_tables.cpp
|
||||
${imgui_SOURCE_DIR}/imgui_widgets.cpp
|
||||
)
|
||||
target_include_directories(ImGui PUBLIC ${imgui_SOURCE_DIR})
|
||||
|
||||
# rlImGui
|
||||
FetchContent_Declare(
|
||||
rlImGui
|
||||
GIT_REPOSITORY https://github.com/raylib-extras/rlImGui.git
|
||||
GIT_SHALLOW TRUE
|
||||
GIT_TAG main
|
||||
)
|
||||
FetchContent_MakeAvailable(rlImGui)
|
||||
|
||||
# Setup rlImGui to work with Raylib
|
||||
add_library(rlImGui STATIC ${rlimgui_SOURCE_DIR}/rlImGui.cpp)
|
||||
target_include_directories(rlImGui PUBLIC ${rlimgui_SOURCE_DIR} ${imgui_SOURCE_DIR})
|
||||
target_link_libraries(rlImGui PRIVATE raylib ImGui)
|
||||
|
||||
add_executable(client
|
||||
client.cpp
|
||||
game.cpp
|
||||
net_client.cpp
|
||||
)
|
||||
|
||||
target_include_directories(client PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../networking/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../engine/include
|
||||
)
|
||||
target_link_libraries(client raylib networking engine rlImGui ImGui)
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(client ws2_32)
|
||||
endif()
|
||||
|
||||
# Copy assets over
|
||||
set(ASSETS_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../assets)
|
||||
set(ASSETS_DST_DIR ${CMAKE_BINARY_DIR}/client)
|
||||
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/copy_assets.cmake
|
||||
"
|
||||
if(EXISTS \"${ASSETS_SRC_DIR}\")
|
||||
file(COPY \"${ASSETS_SRC_DIR}\" DESTINATION \"${ASSETS_DST_DIR}\")
|
||||
if(NOT EXISTS \"${ASSETS_DST_DIR}\")
|
||||
message(WARNING \"Failed to copy assets from ${ASSETS_SRC_DIR} to ${ASSETS_DST_DIR}\")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING \"Assets directory does not exist: ${ASSETS_SRC_DIR}\")
|
||||
endif()
|
||||
")
|
||||
|
||||
add_custom_command(TARGET client POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/copy_assets.cmake
|
||||
COMMENT "Copying assets to output directory"
|
||||
)
|
6
client/client.cpp
Normal file
6
client/client.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
printf("This is the farm fighter client!\n");
|
||||
return 0;
|
||||
}
|
0
client/game.cpp
Normal file
0
client/game.cpp
Normal file
0
client/net_client.cpp
Normal file
0
client/net_client.cpp
Normal file
29
docs/developers.md
Normal file
29
docs/developers.md
Normal file
@ -0,0 +1,29 @@
|
||||
We use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
|
||||
|
||||
```
|
||||
<type>[optional scope]: <description>
|
||||
|
||||
[optional body]
|
||||
|
||||
[optional footer(s)]
|
||||
```
|
||||
Examples
|
||||
Commit message with description and breaking change footer
|
||||
```
|
||||
feat: allow provided config object to extend other configs
|
||||
```
|
||||
BREAKING CHANGE: `extends` key in config file is now used for extending other config files
|
||||
|
||||
Commit message with ! to draw attention to breaking change
|
||||
```
|
||||
feat!: send an email to the customer when a product is shipped
|
||||
```
|
||||
Commit message with scope and ! to draw attention to breaking change
|
||||
```
|
||||
feat(api)!: send an email to the customer when a product is shipped
|
||||
```
|
||||
Commit message with both ! and BREAKING CHANGE footer
|
||||
```
|
||||
chore!: drop support for Node 6
|
||||
```
|
||||
BREAKING CHANGE: use JavaScript features not available in Node 6.
|
12
engine/CMakeLists.txt
Normal file
12
engine/CMakeLists.txt
Normal file
@ -0,0 +1,12 @@
|
||||
project(GameEngineLib)
|
||||
|
||||
add_library(engine STATIC
|
||||
engine.cpp
|
||||
)
|
||||
|
||||
target_include_directories(engine PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${raylib_SOURCE_DIR}/src
|
||||
)
|
||||
|
||||
target_include_directories(engine PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
0
engine/engine.cpp
Normal file
0
engine/engine.cpp
Normal file
0
engine/include/engine.h
Normal file
0
engine/include/engine.h
Normal file
12
networking/CMakeLists.txt
Normal file
12
networking/CMakeLists.txt
Normal file
@ -0,0 +1,12 @@
|
||||
project(NetworkingLib)
|
||||
|
||||
add_library(networking STATIC
|
||||
net_common.cpp
|
||||
)
|
||||
|
||||
target_include_directories(networking PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${raylib_SOURCE_DIR}/src
|
||||
)
|
||||
|
||||
target_include_directories(networking PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
6088
networking/include/enet.h
Normal file
6088
networking/include/enet.h
Normal file
File diff suppressed because it is too large
Load Diff
0
networking/include/net_common.h
Normal file
0
networking/include/net_common.h
Normal file
0
networking/net_common.cpp
Normal file
0
networking/net_common.cpp
Normal file
17
server/CMakeLists.txt
Normal file
17
server/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
||||
project(Server)
|
||||
|
||||
add_executable(server
|
||||
server.cpp
|
||||
)
|
||||
|
||||
target_include_directories(server PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../networking/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../engine/include
|
||||
)
|
||||
|
||||
target_link_libraries(server networking engine raylib)
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(server ws2_32)
|
||||
endif()
|
8
server/server.cpp
Normal file
8
server/server.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
printf("Server starting...\n");
|
||||
printf("Press any key to exit...\n");
|
||||
scanf_s("0");
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user