A* pathfinding and Line of Sight Detection

A 2D Demo

Development

Result

Key Details

Made using C++ and SDL.

2nd year University Assignment - Graded as a 1st.

Uses Line-Line intersections in a tile based map to detect Line of Sight.

Has A* path-finding using the Manhattan method for the node heuristic.

Source code on GitHub

Online version of the documentation

About

This was my first AI Games Programming assignment at Bournemouth University. For this assignment I had to create a game in C++ that contained 2 Bots and a player. Both bots would run away from the player if within its line of sight. If Bot B can see Bot A but not the player it will move towards it. Neither the Bots nor the Player is should be able to walk through walls on the map. The way that I decided to create this was using SDL to create the window, graphics and the general backend for the game. I decided to use bounding boxes to perform the collision detection and line-line intersections for the line of sight detection. The map is loaded in from a text file and works with a tile based system. I also decided that in order to make the bots flee accurately I would use A* pathfinding to make the bot run to a place that is not visible by the player. This assignment was a graded a 1st.





© 2024 Jamie Slowgrove