CDiveSuit::CDiveSuit(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y, const int sprVar) : CGalaxySpriteObject(pmap, foeID, x, y, sprVar), taken(false) { sprite = 306; calcBoundingBoxes(); alignToTile(); }
CSpriteItem::CSpriteItem(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y, std::vector< SmartPointer<CGalaxySpriteObject> > &ObjectPtrs, Uint32 sprite) : CGalaxySpriteObject(pmap, foeID, x, y), m_ObjectPtrs(ObjectPtrs) { m_basesprite = sprite; m_timer = (y*256+x)%MAX_ANIMATION_TIMER; this->sprite = (m_timer%2 == 0) ? m_basesprite : m_basesprite+1; calcBoundingBoxes(); inhibitfall = true; }
CSpriteItem::CSpriteItem(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y, Uint32 sprite, const bool gravity) : CGalaxySpriteObject(pmap, foeID, x, y), mGravity(gravity) { m_basesprite = sprite; m_timer = (y*256+x)%MAX_ANIMATION_TIMER; this->sprite = (m_timer%2 == 0) ? m_basesprite : m_basesprite+1; calcBoundingBoxes(); inhibitfall = true; yinertia = -70; }
void CurveNode::calcVertexes(const VertexDataPtr& pVertexData, Pixel32 color) { updateLines(); calcBoundingBoxes(); pVertexData->appendPos(m_LeftCurve[0], glm::vec2(m_TC1,1), color); pVertexData->appendPos(m_RightCurve[0], glm::vec2(m_TC2,0), color); for (unsigned i = 0; i < m_LeftCurve.size()-1; ++i) { float ratio = (i+1)/(float(m_LeftCurve.size())); float tc = (1-ratio)*m_TC1+ratio*m_TC2; pVertexData->appendPos(m_LeftCurve[i+1], glm::vec2(tc,1), color); pVertexData->appendPos(m_RightCurve[i+1], glm::vec2(tc,0), color); pVertexData->appendQuadIndexes((i+1)*2, i*2, (i+1)*2+1, i*2+1); } }
CBullet::CBullet(CMap *pmap, const Uint16 foeID, const Uint32 x, const Uint32 y, const int xDir, const int yDir, const int sprVar) : CGalaxySpriteObject(pmap, foeID, x, y, sprVar), mReversed(false) { xDirection = xDir; yDirection = yDir; const size_t ep = g_pBehaviorEngine->getEpisode(); setupGalaxyObjectOnMap(bulletActionMap[ep-4], A_KEENSHOT_MOVING); setActionSprite(); calcBoundingBoxes(); playSound( SOUND_KEEN_FIRE ); }
CSlicestar::CSlicestar(CMap *pmap, const Uint16 foeID, const Uint32 x, const Uint32 y, const bool useBlocker, direction_t horDir, direction_t verDir) : CStunnable(pmap, foeID, x, y), mUseBlocker(useBlocker) { m_ActionBaseOffset = 0x23BC; xDirection = horDir; yDirection = verDir; setActionForce(A_SLICESTAR_MOVE); setActionSprite(); calcBoundingBoxes(); }
CRedShot::CRedShot(CMap* pmap, const Uint16 foeID, const Uint32 x, const Uint32 y, const int xDir, const int yDir) : CStunnable(pmap, foeID, x, y), mTimer(0) { xDirection = xDir; yDirection = yDir; mActionMap[A_REDSHOT_MOVE] = (GASOFctr) &CRedShot::processMove; mActionMap[A_REDSHOT_SMASH] = (GASOFctr) &CRedShot::smash; setupGalaxyObjectOnMap(0x27AC, A_REDSHOT_MOVE); setActionSprite(); calcBoundingBoxes(); }
CBullet::CBullet(CMap *pmap, const Uint16 foeID, const Uint32 x, const Uint32 y, const int xDir, const int yDir) : CGalaxySpriteObject(pmap, foeID, x, y) { xDirection = xDir; yDirection = yDir; const size_t ep = g_pBehaviorEngine->getEpisode(); setupGalaxyObjectOnMap(bulletActionMap[ep-4], A_KEENSHOT_MOVING); setActionSprite(); calcBoundingBoxes(); playSound( SOUND_KEEN_FIRE ); // For testing sounds. /*g_pSound->playStereosoundSlot(slot, PLAY_NOW, 0); printf("Sound %d played!\n", slot-64); slot++;*/ }
void CGalaxySpriteObject::setupGalaxyObjectOnMap(const size_t ActionBaseOffset, const size_t ActionNumber ) { m_ActionBaseOffset = ActionBaseOffset; m_climbing = false; m_jumped = false; setActionForce(ActionNumber); setActionSprite(); calcBoundingBoxes(); alignToTile(); performCollisions(); if(!processActionRoutine()) exists = false; }
CVarPlatform::CVarPlatform(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y, const direction_t horidir, const direction_t vertdir, const int actionOffset, const int sprVar) : CGalaxySpriteObject(pmap, foeID, x, y, sprVar), CPlatform(pmap, foeID, x, y), CMoveTarget(m_Pos, xDirection, yDirection) { m_ActionBaseOffset = actionOffset; setActionForce(A_PLATFORM_MOVE); setActionSprite(); xDirection = horidir; yDirection = vertdir; solid = false; // I think they must be false, because some plats like those in Keen6 // should only obey to the set markers calcBoundingBoxes(); }
ImageT<int> *relabelOutput (Image &Img, char *labelname, char *descr) { Image hist = Img.calcHistogram(0, 256, 256); int max = 255; while (hist.getInt (max, 0, 0) == 0 && max > 0) max--; if (!max) { cout << "no texture classes in output segmentation!" << endl; exit (-1); } else cout << "identified " << max << " texture classes in segmentation result" << endl; ImageT<int> *result_img = new ImageT<int>(Img.sizeX (), Img.sizeY ()); result_img->typeImage(_PFM_SINT); ImageT<int> tmp_img(Img.sizeX(), Img.sizeY()); tmp_img.typeImage(_PFM_SINT); cout << "neue Bilder angelegt" << endl; int *dest, *source; unsigned char *orig; int sumlabel[max + 1]; memset(sumlabel, 0, sizeof (int) * (max + 1)); cout << "memset Befehl" << endl; // sumlabel stores the number of labels found for each class, // labelling should start with 1 sumlabel[0] = 1; for (int i = 1; i <= max; i++) { dest = tmp_img.data(); orig = (unsigned char *) Img.data(); cout << "Schleife über i" << endl; // extract one class and prepare it for labelling for (int j = 0; j < Img.sizeImage (); ++j, ++dest, ++orig) if (*orig == i) *dest = 0; else *dest = 1; // label the current class and store the number of labels // label 0 and 1 are background and label border --> throw them away (-2)! sumlabel[i] = labelImage(tmp_img) - 2; // sum up the labelnumbers for fusion of the different classes sumlabel[i] += sumlabel[i - 1]; // shift the labels, so that they are unique (fusion) source = tmp_img.data(); dest = result_img->data(); for (int j = 0; j < tmp_img.sizeImage(); ++j, ++dest, ++source) { // if the label is not background or border (-2), add it to the result if (*source > 1) *dest = *source - 2 + sumlabel[i - 1]; } tmp_img.clear(); } cout << "image relabeled" << endl; // generate the label description ImageT<int> list; calcBoundingBoxes(list, *result_img, sumlabel[max]); FILE *fp = fopen (descr, "w"); if (!fp) { cout << "error opening file " << descr << " for writing." << endl; exit (-1); } // list only the labels with value greater than zero (0 is background) for (int i = 1, j = 0; i < sumlabel[max]; ++i) { if (i >= sumlabel[j + 1]) j ++; fprintf(fp, "<region class=\"class%i\" id=\"%d\" p=\"0.7\" file=\"%s\" llx=\"%d\" lly=\"%d\" urx=\"%d\" ury=\"%d\" />\n", j+1, i, labelname, list[0][i], list[1][i], list[2][i], list[3][i]); } cout << "Regionenbeschreibung erzeugt" << endl; fclose(fp); return (result_img); }