Line of Sight Demo - (can I see the bad guy ?)

Post here your demos and examples with the source files.
Forum rules
Always post the games with a screenshot.
The file must have the ged and data files (complete game source)
Use the forum attachment to post the files.
It is always better to use the first post to put the game files

Line of Sight Demo - (can I see the bad guy ?)

Postby feral » Sat Aug 02, 2008 2:09 am

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
LOSgrab.jpg
screengrab
"player CANNOT see skull"

LOSDemo.zip
ged and data files
(105.44 KiB) Downloaded 240 times


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
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: Line of Sight Demo - (can I see the bad guy ?)

Postby DST » Sat Aug 02, 2008 3:15 am

i always send an actor from the looker to the target and ask what the actor collided with on the way. If the actor is the same size as whatever shot will be fired, it will give a very accurate reading.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: Line of Sight Demo - (can I see the bad guy ?)

Postby feral » Sat Aug 02, 2008 3:48 am

i always send an actor from the looker to the target and ask what the actor collided with on the way. If the actor is the same size as whatever shot will be fired, it will give a very accurate reading.


I agree :D that is the best way... but it takes quite a few frames to do ?? or did I make a boo-boo and miss something :oops:

:lol:
but yeah, the way you describe is definitely a good way to do it, unless you need to do a new check every screen draw

The only other way I could do it in a "single" screen draw, was with collision free , but then I don't know what I collided with :?

this was just a way to do a separate check on "every screen draw" for a fast moving enemy.. ....
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score


Return to Game Demos

Who is online

Users browsing this forum: No registered users and 1 guest

cron