void FindTheSpotGameEngine::Prepare() { if (g_pTile) { delete g_pTile; g_pTile = NULL; } g_distance = 0; Utils::GetLocation(&g_startLocation); IwRandSeed(s3eTimerGetMs()); IGameHandler* pHandler = (IGameHandler*)g_pGameHandler; Region* pRegion = pHandler->GetBoundingRegion(); // Calculate a random location within a given radius int tryCount = 20; do { double angle = PI / 180.0 * IwRandMinMax(-180, 180); // 360 degree range int32 radius = IwRandMinMax(25, 50); // 50 meters LiveMaps::CalculateLatLongInDirection(&g_startLocation, radius, angle, &g_randLocation); if (pRegion->Contains(g_randLocation)) { break; } } while (tryCount-- > 0); int acx = LiveMaps::LongitudeToXAtZoom(g_randLocation.m_Longitude, LiveMaps::MaxZoom); int acy = LiveMaps::LatitudeToYAtZoom(g_randLocation.m_Latitude, LiveMaps::MaxZoom); int tx = acx / 256; int ty = acy / 256; int x = tx * 256; int y = ty * 256; g_tileLoc.x = (acx - x); g_tileLoc.y = (acy - y); char szQuad[20]; int server = 0; LiveMaps::TileToQuadKey(szQuad, tx, ty, LiveMaps::MaxZoom); char szImageUrl[256]; sprintf(szImageUrl, "http://r%i.ortho.tiles.virtualearth.net/tiles/%s%s.%s?g=22", server, "h", szQuad, "jpg"); g_topLeft.m_Longitude = LiveMaps::XToLongitudeAtZoom(x, LiveMaps::MaxZoom); g_topLeft.m_Latitude = LiveMaps::YToLatitudeAtZoom(y, LiveMaps::MaxZoom); g_botRight.m_Longitude = LiveMaps::XToLongitudeAtZoom(x+256, LiveMaps::MaxZoom); g_botRight.m_Latitude = LiveMaps::YToLatitudeAtZoom(y+256, LiveMaps::MaxZoom); Utils::DownloadMapTile(&g_pTile, szImageUrl); }
int main() { char animatingText[] = "... Some Animating Text ..."; uint64 animatingTextTimer; // seed RNG int32 ms = (int32)s3eTimerGetMs(); IwRandSeed(ms); // create our Marmalade UI interface ExampleUI *ui = new ExampleUI(); ui->Log("main()"); //ui->EnableAllButtons(false); // Attempt to start up the Store interface s3eAndroidGooglePlayBillingStart(publicKey); // register callbacks and pass in our UI pointer which the callback s3eAndroidGooglePlayBillingRegister(S3E_ANDROIDGOOGLEPLAYBILLING_LIST_PRODUCTS_CALLBACK,ListCallback,ui); s3eAndroidGooglePlayBillingRegister(S3E_ANDROIDGOOGLEPLAYBILLING_RESTORE_CALLBACK,RestoreCallback,ui); s3eAndroidGooglePlayBillingRegister(S3E_ANDROIDGOOGLEPLAYBILLING_PURCHASE_CALLBACK,PurchaseCallback,ui); s3eAndroidGooglePlayBillingRegister(S3E_ANDROIDGOOGLEPLAYBILLING_CONSUME_CALLBACK,ConsumeCallback,ui); ui->SetStatusText((s3eAndroidGooglePlayBillingIsSupported())?"Initialised":"Unitialised"); // create the Unit Test singleton //gTests = new UnitTests(ui); // DH: Not implemented for this extension yet animatingTextTimer = s3eTimerGetMs(); // run the app while (1) { //gTests->Update(); // update the tests if they're running //s3eAndroidGooglePlayBillingIsSupported() // animate the text if (s3eTimerGetMs() > animatingTextTimer + 20) { int len = strlen(animatingText); char c = animatingText[0]; memmove(animatingText,animatingText+1,len-1); animatingText[len-1] = c; ui->SetAnimatingText(animatingText); animatingTextTimer = s3eTimerGetMs(); } //ui->SetStatusText((s3eAndroidGooglePlayBillingIsSupported())?"Initialised":"Unitialised"); // annoying log spam ui->Update(); // update the UI s3eDeviceYield(); } return 0; }
void EggDropGameEngine::Start() { g_lastTimeAdd = -1000; g_lineGraph.Clear(); g_distance = 0; Utils::GetLocation(&g_startLocation); IwRandSeed(s3eTimerGetMs()); s3eAccelerometerStart(); g_bBroken = false; g_finalScore = 0; g_iCrackIter = 0; }
CameraDefend::CameraDefend() { IwRandSeed((int32)s3eTimerGetMs()); for (int i = 0; i < DEFEND_TOUCHES_MAX; i++) { touch[i] = new DefendTouch; touch[i]->drawing = false; } dotTextureGreen = Iw2DCreateImage("textures/defending_dot/defending_dot.png"); dotTextureRed = Iw2DCreateImage("textures/defending_dot/defending_dot_red.png"); dotTexture = dotTextureGreen; dotAngle = 0; animTexturePress = new CIwTexture; animTexturePress->LoadFromFile("textures/defending_dot/defending_anim.png"); animTexturePress->Upload(); animMat = new CIwMaterial; animMat->SetTexture(animTexturePress); animMat->CreateAnim(); animMat->SetAnimCelW((double)animTexturePress->GetWidth()/cells); animMat->SetAnimCelH((double)animTexturePress->GetHeight()/rows); animMat->SetAnimCelPeriod(2); animTextureSuccess = new CIwTexture; animTextureSuccess->LoadFromFile("textures/defending_dot/defending_success.png"); animTextureSuccess->Upload(); animMatSuccess = new CIwMaterial; animMatSuccess->SetTexture(animTextureSuccess); animMatSuccess->CreateAnim(); animMatSuccess->SetAnimCelW((double)animTexturePress->GetWidth()/cellsSuccess); animMatSuccess->SetAnimCelH((double)animTexturePress->GetHeight()/rowsSuccess); animMatSuccess->SetAnimCelPeriod(2); reinit(); active = false; defended = false; }
void CGame::GenerateRandomScore() { IwRandSeed((int32)s3eTimerGetMs()); m_score = IwRand(); ((CGUILabel *)m_guicontrols[0])->SetCaptioni(m_score); }
void CaptureGameEngine::Start() { Utils::GetLocation(&g_startLocation); IwRandSeed(s3eTimerGetMs()); // get the 9 tiles around our location int acx = LiveMaps::LongitudeToXAtZoom(g_startLocation.m_Longitude, LiveMaps::MaxZoom); int acy = LiveMaps::LatitudeToYAtZoom(g_startLocation.m_Latitude, LiveMaps::MaxZoom); int tx = acx / 256; int ty = acy / 256; int x = tx * 256; int y = ty * 256; g_tileLoc.x = (acx - x); g_tileLoc.y = (acy - y); char szQuad[20]; char szImageUrl[256]; g_topLeft.x = x;// + 128; g_topLeft.y = y;// + 128; for (int ttx = tx - 1; ttx <= tx + 1; ++ttx) { for (int tty = ty - 1; tty <= ty + 1; ++tty) { int server = 0; LiveMaps::TileToQuadKey(szQuad, ttx, tty, LiveMaps::MaxZoom); sprintf(szImageUrl, "http://r%i.ortho.tiles.virtualearth.net/tiles/%s%s.%s?g=22", server, "h", szQuad, "jpg"); g_pTiles[1 + (ttx-tx)][1 + (tty-ty)] = 0; Utils::DownloadMapTile(&g_pTiles[1 + (ttx-tx)][1 + (tty-ty)], szImageUrl); } } s3eLocation bottomRight, topLeft, topRight, bottomLeft, center; bottomRight.m_Latitude = LiveMaps::YToLatitudeAtZoom(y+512, LiveMaps::MaxZoom); bottomRight.m_Longitude = LiveMaps::XToLongitudeAtZoom(x+512, LiveMaps::MaxZoom); topLeft.m_Latitude = LiveMaps::YToLatitudeAtZoom(y-256, LiveMaps::MaxZoom); topLeft.m_Longitude = LiveMaps::XToLongitudeAtZoom(x-256, LiveMaps::MaxZoom); if (topLeft.m_Longitude > bottomRight.m_Longitude) { float longitude = bottomRight.m_Longitude; bottomRight.m_Longitude = topLeft.m_Longitude; topLeft.m_Longitude = longitude; } if (topLeft.m_Latitude > bottomRight.m_Latitude) { float latitude = bottomRight.m_Latitude; bottomRight.m_Latitude = topLeft.m_Latitude; topLeft.m_Latitude = latitude; } topRight.m_Longitude = topLeft.m_Longitude; topRight.m_Latitude = bottomRight.m_Latitude; center.m_Latitude = (bottomRight.m_Latitude + topLeft.m_Latitude) / 2; center.m_Longitude = (bottomRight.m_Longitude + topLeft.m_Longitude) / 2; float maxDir = LiveMaps::CalculateDistance(topLeft, topRight) / 2.1; IGameHandler* pHandler = (IGameHandler*)g_pGameHandler; Region* pRegion = pHandler->GetBoundingRegion(); for (int i = 0; i < 15; ++i) { s3eLocation* randLoc = new s3eLocation; // Calculate a random location within a given radius int tryCount = 20; do { double angle = PI / 180.0 * IwRandMinMax(-180, 180); // 360 degree range int32 radius = IwRandMinMax(5, maxDir); // 50 meters LiveMaps::CalculateLatLongInDirection(¢er, radius, angle, randLoc); s3eLocation testLoc = *randLoc; if (pRegion->Contains(testLoc) && (testLoc.m_Latitude >= topLeft.m_Latitude) && (testLoc.m_Latitude <= bottomRight.m_Latitude) && (testLoc.m_Longitude >= topLeft.m_Longitude) && (testLoc.m_Longitude <= bottomRight.m_Longitude)) { break; } } while (tryCount-- > 0); g_pCaptures.push_back(randLoc); } g_caughtAllTime = 0; }
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() )); }