What is a normalized Vector?
        Posted  
        
            by 
                draiden
            
        on Game Development
        
        See other posts from Game Development
        
            or by draiden
        
        
        
        Published on 2012-06-23T04:34:25Z
        Indexed on 
            2012/06/23
            9:26 UTC
        
        
        Read the original article
        Hit count: 277
        
Can someone explain the following code? I need to learn what each part means so I can turn it into enemy movement in a space shoot-em-up
Vec2d playerPos;
Vec2d direction; // always normalized
float velocity;
I get the above is naming two 2d Vector objects, and creating a variable called velocity. I'm not sure what the normalized comment is about, though.
update()
{
   direction = normalize(playerPos - enemyPos);
   playerPos = playerPos + direction * velocity;
}
© Game Development or respective owner