void Game::Initialize() { IMAGE_CACHE.push_back(Iw2DCreateImage("question.png")); IMAGE_CACHE.push_back(Iw2DCreateImage("one.png")); IMAGE_CACHE.push_back(Iw2DCreateImage("moon.png")); IMAGE_CACHE.push_back(Iw2DCreateImage("begin.png")); }
//Visualize clicks void Brixpath::customAnimation(){ CIwArray<clickAnimation*> toRemove; IW_ARRAY_ITERATE_INT(i, _clicksToAnimate) { clickAnimation* ca = &_clicksToAnimate[i]; if(ca->currentWidth > _animationOptions.limit) //if rectangle is bigger than limit, animation should be stopped toRemove.push_back(&_clicksToAnimate[i]); else { _clicksToAnimate[i].currentWidth += _animationOptions.step; //increase rectangle size and draw it. Iw2DDrawRect(CIwSVec2((int)(ca->x - (ca->currentWidth/2)), (int)(ca->y - (ca->currentWidth/2))), CIwSVec2(ca->currentWidth, ca->currentWidth)); } }
// maps pages number to its background for the levelnavigation // these values will eventually need to be changed void BackgroundManager::loadBackground(int pageNum) { IW_CALLSTACK("BackgroundManager::LoadBackground"); string backgroundName =""; CIwArray<string> extras = CIwArray<string>(); switch (pageNum) { case 0: backgroundName = "mountains"; extras.push_back("cloud"); extras.push_back("bird"); extras.push_back("bird"); extras.push_back("bird"); extras.push_back("bird"); break; case 1: backgroundName = "industrial"; extras.push_back("gear"); break; case 2: backgroundName = "demoneyes"; extras.push_back("spiral"); break; } this->loadBackground(backgroundName, extras); }
CIwArray<int16> DecompressIT16(s3eFile* pFile, uint32 dstSize) { CIwArray<int16> res; int16 last = 0; int32 x,y,needbits,havebits,new_count=0; uint16 bits = 17; uint16 bufbits = 0; uint8 buf; uint16 incnt; s3eFileRead(&incnt,sizeof(incnt),1,pFile); while (res.size() < dstSize) { needbits=new_count?4:bits; x=havebits=0; while (needbits) { // feed buffer if (!bufbits) { if(incnt) { if (s3eFileRead(&buf,sizeof(buf),1,pFile) != 1) buf = 0; incnt--; } else { buf = 0; return res; } bufbits=8; } // get as many bits as necessary y = needbits<bufbits?needbits:bufbits; x|= (buf & ((1<<y)- 1))<<havebits; buf>>=y; bufbits-=(uint16)y; needbits-=(uint16)y; havebits+=(uint16)y; } if (new_count) { new_count = 0; if (++x >= bits) x++; bits = (uint16)x; continue; } if (bits<7) { if (x==(1<<(bits-1))) { new_count = 1; continue; } } else if (bits<17) { y=(0xffff>>(17-bits))-8; if ((x>y)&&(x<=y+16)) { if ((x-=y)>=bits) x++; bits = (uint16)x; continue; } } else if (bits<18) {
void BackgroundManager::loadBackground(string backgroundName, CIwArray<string> extras) { IW_CALLSTACK("BackgroundManager::loadBackground"); this->units.clear(); if ( extras.size() != 0) { for ( int x = 0; x < (int)extras.size(); ++x) { if (extras[x].compare("cloud") == 0) { IwRandSeed ( time(NULL) ); int num = IwRandMinMax(1, 6); // how many clouds should be made for ( int i = 0; i < num ; ++i) { CIwSVec2 pos = CIwSVec2( IwRandMinMax(-Screen::getBOXSIZE().x, Screen::getSCREENSIZE().x), IwRandMinMax(0, (int)(Screen::getSCREENSIZE().y * 0.33f))); float velocity = (float) IwRandMinMax(500 ,2000) / 1000.0f; int type = IwRandMinMax(1, 10); // the number of cloud pictures we have Cloud * cloud = new Cloud(pos, velocity, type); this->units.push_back(cloud); } } else if (extras[x].compare("bird") == 0 ) { CIwSVec2 pos = CIwSVec2(IwRandMinMax(0, Screen::getSCREENSIZE().x), IwRandMinMax(0, (int)(Screen::getSCREENSIZE().y * 0.4f))); float velocity = IwRandMinMax(1000, 4000)/100.0f; Bird * bird = new Bird(pos, velocity); this->units.push_back(bird); } else if (extras[x].compare("gear") == 0 ) { CIwSVec2 pos = CIwSVec2((int)(Screen::getSCREENSIZE().x * 0.3f), (int)(Screen::getSCREENSIZE().y * 0.4f)); float velocity = (float)IwRandMinMax(1, 1000) / 10.0f; Gear * gear = new Gear(0); Gear * gear1 = new Gear(1); Gear * gear2 = new Gear(2); this->units.push_back(gear); this->units.push_back(gear1); this->units.push_back(gear2); } else if (extras[x].compare("spiral") == 0) { this->units.push_back(new Spiral(CIwSVec2(Screen::getSCREENSIZE().x * 0.5 - 268/2, Screen::getSCREENSIZE().y * 0.5 - 268/2))); //this->units.push_back(new Spiral(CIwSVec2(Screen::getSCREENSIZE().x * 0.75 - 268/4, Screen::getSCREENSIZE().y * 0.5 - 272/4))); } } } this->backgroundSegments.clear(); //if background is undefined no background is shown if ( backgroundName.compare("") == 0) { return; } // format has to follow backgroundName + "piece number" this->backgroundSegments.push_back(ImageManager::getImage( (backgroundName+"0").c_str() )); this->backgroundSegments.push_back(ImageManager::getImage( (backgroundName+"1").c_str() )); this->backgroundSegments.push_back(ImageManager::getImage( (backgroundName+"2").c_str() )); this->backgroundSegments.push_back(ImageManager::getImage( (backgroundName+"3").c_str() )); }