void CInventory::AddAtoms(char* i_strAtomSymbol, int i_nCount) { bool bMatchFound = false; int matchIndex = -1; if (inventoryCount == 0) { // HASAN - debug //s3eDebugOutputString("Adding inventory sprite to sprite manager."); // add the inventory to the sprite manager when the first atom is added g_Game.getSpriteManager()->addSprite(inventory_sprite); } if (inventoryCount > 0) { for (int i = 0; i < MAX_COUNT; i++) { if (!strcmp(atoms[i], i_strAtomSymbol)) { bMatchFound = true; matchIndex = i; break; } } } if (!bMatchFound) { // match strcpy(atoms[inventoryCount], i_strAtomSymbol); atomCount[inventoryCount] += i_nCount; CAtom* atom = new CAtom(); atom->Init(i_strAtomSymbol); // horizontal center, same as inventory graphic int posX = (Iw2DGetSurfaceWidth() / 2) - (IMAGE_SIZE_WIDTH / 2); int posY = Iw2DGetSurfaceHeight() - (IMAGE_SIZE_HEIGHT / 2); // offset inventory horizontally to fit in the container posX = posX + (10 + (64 / 2)); // NOTE: 64 = atom size, 10 = border + spacing if (inventoryCount > 0) { posX = posX + (inventoryCount * (64 + 15)); // NOTE: 64 = atom size, 15 = spacing + border + spacing } atom->setPosAngScale(posX, posY, 0, IW_GEOM_ONE); atom->setVelocity(0,0); // HASAN - new to create/show the inventory count images CIw2DImage* inventoryCountImage = Iw2DCreateImageResource("inventory_number"); CSprite* inventoryCountSprite = new CSprite(); inventoryCountSprite->setImage(inventoryCountImage, "inventory_number"); // NOTE: image width & height = 25 & font width & height = 30 inventoryCountSprite->setPosition(posX + 13 + (30 / 2), posY + (30 / 2) + 3); inventoryCountSprite->setDestSize(30, 30); // make larger than source to fit behind the text properly g_Game.getSpriteManager()->addSprite(inventoryCountSprite); atomCountImages[inventoryCount] = inventoryCountSprite; atomObjs[inventoryCount] = atom; inventoryCount++; } else { atomCount[matchIndex] += i_nCount; } }