It is currently Mon Apr 24, 2017 12:33 am

All times are UTC - 5 hours




 Page 1 of 1 [ 2 posts ] 
Author Message
 Post subject: Ghost VMK 25 - Radar Map
PostPosted: Wed Aug 05, 2009 5:40 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
In VMK25A I start work on the radar map unit by adding the graphic image to the resource file. This video focuses on making the radar map display in the top right hand corner of the screen and also animating it open and close based on the battery power.

In VMK25B I add the radar dots showing where things are located relative to the player. Blue dots for arrows, and yellow dots for batteries.

The arm that sweeps around in a circle is created in VMK25C. A new function is also added to the GeneralMath class.

The last part of the radar unit is added in VMK25D. Here I show how to make the dots appear when the arm sweeps by them, and slowly fade out of view when the arm moves away from the dot. New functions are added to the Vector2 and Math classes.


Offline
 Profile  
 
 Post subject:
PostPosted: Wed Sep 02, 2009 5:25 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
It is better to incorporate the getCosAngle function as shown below rather than as shown in the VMK.

//------------------------------------------------------------------------
// Name: getCosAngle(:)
// Desc: returns the cos(Angle) value between THIS vector and vector v2. 
//        This is less expensive than using getAngle
//
inline float Vector2::getCosAngle(const Vector2 v2, const bool bNormalized) {
   //a . b = |a||b|cos(angle)
   //-> (a . b)/(|a||b|)

   float fMagA = length();
   if (fMagA <= Math::ZERO) {
      //this (a) is an invalid vector
      return 0;
   }

   float fValue = 0;

   if (bNormalized) {
      //v2 is normalized already
      fValue = dot(v2) / fMagA;      
   }
   else {
      //v2 is not normalized
      float fMagB = v2.length();
      if (fMagB <= Math::ZERO) {
         //b is an invalid vector
         return 0;
      }

      fValue = dot(v2) / (fMagA * fMagB);      
   }

   //correct value due to rounding problems
   Math::constrain(-1.0f, 1.0f, fValue);

   return fValue;

} //getCosAngle


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron