Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 15 May 2011
Offline Last Active Jan 21 2015 05:27 AM

Topics I've Started

Return value

30 November 2014 - 10:33 AM


   I am trying to convert a function. Working with pointers, my function is looks like this -

The container-

std::vector<COne*> m_OneContainer;

When I have to find something, I do like this -

COne* CScene::getOneFromId(int id)
   for(auto &it: m_OneContainer)
      if((*it)->getID() == id)
         return *it;
   return 0;

But when I work with reference -

std::vector<COne> m_OneContainer;

Function -

COne& CScene::getOneFromId(int id)
   for(auto &it: m_OneContainer)
      if(it.getID() == id)
         return it;
   return 0; // What do I return here??

My question is what do I return as NULL?


Thank you

Layer and Frame?

15 June 2014 - 01:30 PM


   I am making a small game, where, now I want to implement layer and frame. Something like timeline. Each scene will consists of some layer and each layer will have some frames. Each frame will be used as a level and each layer will decide which entity will be visible. If a layer is invisible, all the entity belongs to that layer will be invisible.

   I just need some idea how do I implement them! As a class, struct or vectors etc. I only need idea, nothing else.


Thank you.

Calculating healthbar percentage

29 May 2014 - 12:30 PM


   I am trying to draw a health bar when player get hit by enemy. The healthbar is a rect, like -

rect( x, y, w, h)

The width is 177 and height is 12. The maximum health of the player may bigger then 100. So when player get hit the width of the rect should decrease according to the damage. Since the width of the rect is not 100, I am having a little difficulties to calculate the actual healthbar parcent.

What I am doing is -

unsigned int health = (currentHealth / maxHealth) * 100;

This only works if the width is 100. If I multiply with 177 (actual width of the rect), it always returns 0.
So how do I increase/decrease the percentage of the healthbar according to the width of the rect?


Thanks in advance.

Failed to start!

04 November 2013 - 01:07 PM


   I am using code::block and angelscript 2.27.1. Just now I tried to compile my app with the new release 2.28 and found the script is not creating the engine.

engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
if( engine == 0 )
    printf("Failed to create script engine.\n");
    return -1;

It is returning -1 here.


It is working fine with 2.27.



Game Loop!

01 November 2013 - 09:21 AM


   I have to register a function which will loop continously to call the game update function from game loop. say -

void OnUpdate()
   // Update functions

Could someone kindly explain a little how to register it.


Thanks in advance.