News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Line Of Sight - (Clever Coders Challenge #10)

Started by kevin, January 26, 2008, 01:59:19 PM

Previous topic - Next topic

kevin

Quote

  ; *=-----------------------------------------------------------------=*
  ;         >>  Line Of Sight (LOS) - Clever Coders Challenge #10 <<
  ;
  ;                          By Kevin Picone
  ;
  ;                          26th, Jan, 2008
  ;
  ;        (c) copyright 2008 Kevin Picone, All Rights reserved    
   ; *=-----------------------------------------------------------------=*
  ;
  ;   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.

  ;   Actors use this world definition to calculate the visibility of the
  ; player 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 will attempt to move
  ; towards it.  However is the ray hits the world,  the target has gone
  ; out of view and the actor will 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.  
  ;
   ; *=------------------------------------------------------------------=*



This example was written in PlayBASIC V1.63r.


Related Examples

Movement Path Library Example
Field Of Vision
Character(s) Avoiding Player
Clever Coder Challenges