This is a quick and dirty but easy way to create line of sight, for example - to test if your player can actually see an item/enemy
in the attached screen-grab the "blue" player "cannot " see the skull
it basically tests for the existence of walls between the player and whatever he needs to see.
It work by drawing on a canvas (hidden) and testing if the line intersects (collides) with a wall
you can see HOW it works, by deleting the actor "floorblock". (which hides the canvas)
restrictions:
1. it gets confused when used on "cloned" wall blocks.. for some reason it thinks it can sometimes see between them, even if they are stacked tight. so instead, I had to create a solid MAP overlay - see the file backdrop.png to see what I mean
to see the issue, delete or move the "backdrop" image off screen and leave only the original cloned wall sprites.
I have not tested it with tiles yet.. but it should work !?!?!? let us know if you test it...
if any one can fix this glitch ? let me know..
2. it uses canvas's so it is really only good for testing for 1 item or 1 enemy, but, it still should be useful in some games..
eg can my SAM missile actually see the helicopter to lock-on... or, hide and seek with a monster etc etc
I am planning a more complex version ( without canvas's ) soon
feral