Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Isaac Paul

Member Since 13 Jan 2013
Offline Last Active Dec 17 2014 11:51 AM

#5176180 Distance formula in c++

Posted by Isaac Paul on 26 August 2014 - 06:17 AM

My favorite method for calculating approximate distance:

u32 approx_distance( s32 dx, s32 dy )
{
   u32 min, max, approx;

   if ( dx < 0 ) dx = -dx;
   if ( dy < 0 ) dy = -dy;

   if ( dx < dy )
   {
      min = dx;
      max = dy;
   } else {
      min = dy;
      max = dx;
   }

   approx = ( max * 1007 ) + ( min * 441 );
   if ( max < ( min << 4 ))
      approx -= ( max * 40 );

   // add 512 for proper rounding
   return (( approx + 512 ) >> 10 );
} 

http://www.flipcode.com/archives/Fast_Approximate_Distance_Functions.shtml

 

Its useful for pathfinding and AI.. though it might be weird for collision. I recommend storing everything collide-able inside of an array and iterating through them while checking to see if the edges of the objects over lap with each other via box collision or separating axis theorem. 

 

Box Collision:

bool DoBoxesIntersect(Box a, Box b) {
  return (abs(a.x - b.x) * 2 < (a.width + b.width)) &&
         (abs(a.y - b.y) * 2 < (a.height + b.height));
}

http://gamedev.stackexchange.com/questions/586/what-is-the-fastest-way-to-work-out-2d-bounding-box-intersection

 

Separating Axis Theorem:

http://www.metanetsoftware.com/technique/tutorialA.html 




#5174735 So... C++14 is done :O

Posted by Isaac Paul on 19 August 2014 - 08:31 AM

I'm all for readability more than anything. I wish they would make the language more DRY (Don't repeat yourself).

 

I'm sick and tired of having to update .h files when changing .cpp files and vice-versa.

 

Also, class scopes are annoying too. Wouldn't it be simple to do something like:

class MyClass {
    public:
    void hello() {

    }
}

instead of:

void MyClass::hello() {

}

MyClass:: is usually everywhere :/




#5165524 How do you get ideas for new games?

Posted by Isaac Paul on 08 July 2014 - 05:51 AM

I make the game I want to play. Ideas come to me as I play other games. Not only that video games are always on my mind, and I'm very analytical to the current games I play where I notice how different aspects of the game effect me.




#5136782 Copy protection system

Posted by Isaac Paul on 06 March 2014 - 07:12 AM

If you really want to add anti-piracy:

 

Release a purposefully 'cracked' and 'buggy' version of your dll to pirate websites (high-cpu usage, frequent crashes, ect). Several versions infact, make them seem as legit as possible. You can even add a time delay to make it seem like it works perfectly at first. Having an already released 'cracked' version of you software will also deter crackers from actually cracking it too since they think its already been done and if they do crack it.. it will be just be mixed in with your version.

 

This should really frustrate the pirate community. Though, I'm not sure if that will result in more sales for you :P




PARTNERS