So I'm working on a project with a good friend of mine for our Programming IV class. We have all quarter to complete a project of out choice. We chose to make an arcade style survival game. Basically we want randomely generated rooms, Halo style weapons pickups and quake style power ups all with the goal of obtaining a high score, that we will record into a database and send to a web site.
We're on Christmas break for the next two weeks. We decided he was going to write the code for the room generation, and I was going to get a basi enemy AI done by the time we get back. I've been doing alright so far but I didn't consider everything else I would have to put in place to get this working.
I generated a few NPC's on screen, a player, and a wall, and wrote the movement code for the player, now I want to have the NPC's move to the player, but only if they have a line of sight to him.
I'm thinking drawing an actual line between the two, and then doing a collision test on the line and the wall (which will eventually be an array of walls) is the easiest way. The hitTest function of AS3 uses the whole bounding box of the line, so it's useless. I found a method of using bitmap data to text each individual pixel, but its confusing me pretty well and I can't imagine it's very efficient.
Does anyone know the easiest way to determine collisions in AS3 or even an easier way to determine line of sight?
Project here if you want to look at it (the code is for the bitmap method and is buggy):
This is the Bitmap method I was trying to implement: