I've been chopping away at an FPS that works a bit like Wolfenstein: 3D. The idea is that the level is represented by numerical values in an array. (You can see some images in game and of the editor on my website, link in signature)
I've come to a bit of a road block. Set up now is a routine for determining what position on the array the camera is by rounding the camera's actual value divided by 40, the unit size of each square on the grid. Doors are represented on the map as a 2, walls are 1s, and open space is a zero, or any other value not explicitly defined. To open the door, you would logically have to be within one array unit and facing toward the door. How could I check if the player is facing the door? Full source is available on request, I don't know what kind of snippet would help.
EDIT: I had an idea for a system based on checking whether the camera's object is colliding with the door's object, but with my function for drawing the level, the number of the door object is unknown.
EDIT: A code snippet that shows how a door is removed. With this code all doors around the player, within one block, are removed. Ideally, I'd like to remove the one the player is looking the most toward.
if((dbSpaceKey()==1)&&(lowLayer[playerPosition.x][playerPosition.y+1]==2)){
lowLayer[playerPosition.x][playerPosition.y+1]=0;
drawLevelFromArray();
}
if((dbSpaceKey()==1)&&(lowLayer[playerPosition.x][playerPosition.y-1]==2)){
lowLayer[playerPosition.x][playerPosition.y-1]=0;
drawLevelFromArray();
}
if((dbSpaceKey()==1)&&(lowLayer[playerPosition.x+1][playerPosition.y]==2)){
lowLayer[playerPosition.x+1][playerPosition.y]=0;
drawLevelFromArray();
}
if((dbSpaceKey()==1)&&(lowLayer[playerPosition.x-1][playerPosition.y]==2)){
lowLayer[playerPosition.x-1][playerPosition.y]=0;
drawLevelFromArray();
}
My site, for various stuff that I make.