Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 08 Apr 2010
Offline Last Active May 27 2013 02:21 PM

Topics I've Started

how to do this in c++

16 May 2013 - 08:03 PM


i've been using this simple OO approach with rather simple code of determining if buildings have access between each other, in my game. But the problem is that it's quite clumsy way of doing OO and i think there's better solution in doing this in c++ but i can't remember what? The problem with this code is that there's possibility of infinite loop if i make some mistake in adding more classes that need this check.


so can you make a better OO solution for this check (code below)? 



class Bridge: public BaseBuilding
// return true if This building can be accessed from building b
bool canAccessFrom(BaseBuilding & b)
 if(b.canAccessFrom(*this)) // use the code in the other class if any...
return true;

return false;


class House: public BaseBuilding

bool canAccessFrom(BaseBuilding & b)
 return this->isOnSameLevel(b);



thanks. i hoipe i was able to explain what the problem is.

c++ syntax error

03 April 2013 - 07:54 AM


i ran to this problem that I cannot figure out what's causing it. I'm using visual studio 2010 express (C++) and first this code seeme'd to work but running clean-build ends up in error.




template<class Archive,class EntClass> inline 
void loadEntityConstructData(Archive & ar, EntClass * obj, const unsigned int version)

 Point2F pos;
 F32 angle;
 std::string data;

 EntityData *entData = 0;





Gives error:
Error 220 error C2061: syntax error : identifier 'obj'

the code above is called from another template function:



template<class Archive> inline void load_construct_data(Archive & ar, classname * t, const unsigned int version) 
{ loadEntityConstructData(ar,t,version); }  


maybe someone knows what's wrong?




Point To Polygon

01 September 2012 - 12:03 PM

does anyone know how to create a polygon from points? i tried googling and looking through my graphics programming books but found nothing.... I can't use any library to do this need the algorithm it self.

array of hex to Number in C++

11 July 2012 - 02:09 PM

can any one tell why doesnt this print 9282798 which is the hexedecimal value in the buffer?

BYTE * buffer = new BYTE[4];
buffer[0] = 0;
buffer[1] = 0x8D;
buffer[2] = 0xA4;  
buffer[3] = 0xEE;

// 9282798

  DWORD *p = (DWORD*)buffer; // Convert pointer
  cout  << ((*p)==9282798) << "  number: " << ( (DWORD) (*p) ) << endl; // print buffer as DWORD

I thought the buffer (array) could be converted to DWORD with type conversion alone because the memory has same region (4 bytes) but I guess i was wrong.

what am I doing wrong?


sorting edge detected points

16 June 2012 - 06:29 PM

how do you find in which order are the points in the result of edge detection?

i need to run iteration on the result of edge detected points but the result doesnt have the points in linear order.

so is there a better way to detect edge inorder to have them in linear order, or some good logic to put the points in order?