/Enemy2D-Navigation

Navigating enemy to find player and chase him

Primary LanguageC++

Enemy2D-Navigation

This project is made for learning purposes

The engine used belongs to javidx9 please refer to the engine's github page for info about the license and the engine.

Objective

The player's goal to move from one point to another point and the enemy's goal to stop the player from reaching its destination and the enemy can only move if the enemy detected the player

Tasks

  • Move the player
  • Find a path to the player
    • AStar
  • Move the enemy on the path
  • Add Physics
    • Collisions
  • Limit the area that the Enemy can see

Algorithms

  • DFS
  • BFS
  • AStar

Controls

  • Up - Down - Right - Left : Move Player
  • q - w : Change Enemy Speed
  • n : Revert game to normal mode
  • r - t : Change World Size will also need to revert to normal mode after using it for performance
  • m : Move or Stop Player
  • v : To connect nodes Diagonally
  • a : Use A star algorithm
  • d : Use DFS algorithm
  • Shift + d : Use DFS Improved algorithm
  • b : Use BFS algorithm
  • Shift + b : Use BFS Improved algorithm
  • Left Mouse Click : Make a wall at a specified node
  • Shift + Left Mouse Click : Move Enemy to a specified node
  • Ctrl + Left Mouse Click : Move Player to a specified node

Project Modes

Debug Mode

Will show a visual representation of the 2d-space nodes that the enemy uses to navigate and identify the nodes that enemy needed to visit before reaching the player

Release Mode

Will disable the visual representation

Compiling

Architecture support

  • x64

Platform support

  • Windows
  • Linux (It should work but not tested)

Premake is already included in the project no need to download it

This project uses premake to generate project files.

Premake is a command line utility which reads a scripted definition of a software project and, most commonly, uses it to generate project files for toolsets like Visual Studio, Xcode, or GNU Make. Built-in and Third-Party Modules add support for even more toolsets.

Run on Windows

Run using Visual Studio

  • Test Compile
  • Test running the project

Use premake to generate visual studio 2022 files by running the script provided GenerateProjectForVS22.bat

Then open the project and run the application the main one is "FollowPlayer"

Run on Linux

  • Test Compile
  • Test running the project

The minimum required version of gcc and g++ will be updated soon with the libraries that might be missing for some machines

Make sure you have make installed

To make the project files go to the root directory of the project then

.\vendor\bin\linux\premake\premake5 gmake

To Compile the project in debug mode

make config=debug

To Compile the project in release mode

make config=release