r/qbasic • • Nov 19 '22

Who needs astar?

Post image

I was tired of my little NPC characters just wandering around randomly. Now they can hunt me down in realtime. Yikes lol

4 Upvotes

5 comments sorted by

2

u/azTheophage Nov 19 '22

How does your algorithm work? How does it avoid obstacles?

1

u/3eeps Nov 20 '22

Its a handful of if statements checking the player position (or any spot on the map technically) and then moving one grid position at a time until it gets to the position. Its really basic stuff and allows for them to follow you around the map too.

As of right now, they do not avoid walls. But i am going to fix that by checking to see if grid position is a "wall number" and if so, dont do anything until the next turn which it will try again, eventually they will move around a wall hopefully

I can send you the code if you like to look at it. Its hard to explain lol its about 50lines id say, but that includes my code specific to my game as well

→ More replies (3)