Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Line Of Sight [PB SRC]

Author
Message
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 27th Jan 2008 07:26 Edited at: 12th Aug 2010 00:20
Clever Coders Challenge #10 - Line Of Sight (LOS)

The aim of this example is demonstrate an approach for performing line of sight calculations between game actors and the player within a world space.

The world space represents 'hard' or impassible areas by drawing the outlines of various simple shapes (boxes, circles) into playbasic world. Normally if you creating game you wouldn't build the collision world in code like this example, you'd write an editor. But ya get that

Actors use this world definition to calculate player visibility by running ray intersection between the actors current position and the target. If the ray reaches the target position without hitting the world, then the actor can see the target, and attempts to move towards it. However is the ray hits the world, the target has gone out of view and the actor will just sit still. Giving the actors the most basic "Follow Me" style behavior.

I really recommend carefully picking through this world command, it's not difficult, but often overlooked.


Download

playbasic source codes

Clever Coders Challenge Board


Related Posts
Field Of Vision \Field Of View

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-05-17 08:21:49
Your offset time is: 2024-05-17 08:21:49