//-------------------------------------------------------------------------- // Main global function //-------------------------------------------------------------------------- S3E_MAIN_DECL void IwMain() { #ifdef EXAMPLE_DEBUG_ONLY // Test for Debug only examples #endif // Example main loop ExampleInit(); uint64 timeOld = s3eTimerGetMs(); while (1) { s3eDeviceYield(0); s3eKeyboardUpdate(); s3ePointerUpdate(); uint64 timeNew = s3eTimerGetMs(); float dt = (timeNew - timeOld) * 0.001f; timeOld = timeNew; bool result = ExampleUpdate(dt); if ( (result == false) || (s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_DOWN)|| (s3eKeyboardGetState(s3eKeyLSK) & S3E_KEY_STATE_DOWN)|| (s3eDeviceCheckQuitRequest()) ) break; ExampleRender(); //s3eSurfaceShow(); } ExampleShutDown(); }
void endOfGame() { SplashInit(); SplashUpdate("continue"); SplashRender(); IwGxLightingOn(); gameFinalRender(); IwGxFlush(); IwGxSwapBuffers(); while(!s3eDeviceCheckQuitRequest()) { int64 start = s3eTimerGetMs(); while ((s3eTimerGetMs() - start) < MS_PER_FRAME) { int32 yield = (int32) (MS_PER_FRAME - (s3eTimerGetMs() - start)); if (yield<0) break; s3eDeviceYield(yield); } if (g_Input.getTouchCount() != 0) { s3eResult g_result = s3eOSExecExecute("http://www.facebook.com/Baconbb10", true); } } }
int main() { Iw2DInit(); CIw2DImage* g_AirplayLogo = Iw2DCreateImage("largeAirplayLogo.bmp"); while (1) { int64 start = s3eTimerGetMs(); if (s3eDeviceCheckQuitRequest()) break; // Clear the screen Iw2DSurfaceClear(0xffffffff); CIwSVec2 topLeft = CIwSVec2((int16)(Iw2DGetSurfaceWidth() / 2 - g_AirplayLogo->GetWidth() / 2), (int16)(Iw2DGetSurfaceHeight() / 2 - g_AirplayLogo->GetHeight() / 2)); CIwSVec2 size = CIwSVec2((int16)g_AirplayLogo->GetWidth(), (int16)g_AirplayLogo->GetHeight()); Iw2DDrawImage(g_AirplayLogo, topLeft, size); Iw2DSurfaceShow(); // Attempt frame rate while ((s3eTimerGetMs() - start) < MS_PER_FRAME) { int32 yield = (int32) (MS_PER_FRAME - (s3eTimerGetMs() - start)); if (yield<0) break; s3eDeviceYield(yield); } } delete g_AirplayLogo; Iw2DTerminate(); return 0; }
void Sounds::startMusicGameplay() { if(Settings::getInstance()->musicEnabled == false) return; if(s3eIOSBackgroundMusicAvailable() == S3E_TRUE) if(s3eIOSBackgroundMusicGetInt(S3E_IOSBACKGROUNDMUSIC_PLAYBACK_STATE) == S3E_IOSBACKGROUNDMUSIC_PLAYBACK_PLAYING) return; IGLog("Sounds starting gameplay music"); // if gameplay music is already playing, only change song if it's been playing for a full minute if(gameplayPlaying) { if(s3eTimerGetMs() - gameplayStart <= 60000) return; } gameplayPlaying = true; gameplayStart = s3eTimerGetMs(); stopMusic(); char buffer[100]; int randomSong = gameplayMusicNum; while(randomSong == gameplayMusicNum) randomSong = rand()%3; switch(randomSong) { default: case 0: sprintf(buffer, "gameplay1.mp3"); break; case 1: sprintf(buffer, "gameplay2.mp3"); break; case 2: sprintf(buffer, "gameplay3.mp3"); break; } if(s3eAudioIsCodecSupported(S3E_AUDIO_CODEC_MP3)) s3eAudioPlay(buffer, 0); }
int CCApplication::Run() { IW_CALLSTACK("CCApplication::Run"); if ( ! initInstance() || !applicationDidFinishLaunching() ) { return 0; } int64 updateTime = s3eTimerGetMs(); while (!s3eDeviceCheckQuitRequest()) { int64 currentTime = s3eTimerGetMs(); if (currentTime - updateTime > m_nAnimationInterval) { updateTime = currentTime; s3eDeviceYield(0); s3eKeyboardUpdate(); s3ePointerUpdate(); ccAccelerationUpdate(); CCDirector::sharedDirector()->mainLoop(); } else { s3eDeviceYield(0); } } return -1; }
void MatrixManager::Star::MoveStar(int dx) { if (enabled <= 0) return; // fx = fx + (dx * multiplier); // if (fx < 0) { fx = FIELD_RES - 1; fy = (rand() % FIELD_RES); time_appeared = (int)s3eTimerGetMs() - 1000; timeout = 2000 + (rand() % 10000); rot_inc = (rand() % 64); star_hue = (rand() % 16); size_frame = 0; } if (fx >= FIELD_RES) { fx = 0; fy = (rand() % FIELD_RES); time_appeared = (int)s3eTimerGetMs() - 1000; timeout = 2000 + (rand() % 10000); rot_inc = (rand() % 64); star_hue = (rand() % 16); size_frame = 0; } }
//----------------------------------------------------------------------------- // Main global function //----------------------------------------------------------------------------- int main() { #ifdef EXAMPLE_DEBUG_ONLY // Test for Debug only examples #ifndef IW_DEBUG DisplayMessage("This example is designed to run from a Debug build. Please build the example in Debug mode and run it again."); return 0; #endif #endif //IwGx can be initialised in a number of different configurations to help the linker eliminate unused code. //Normally, using IwGxInit() is sufficient. //To only include some configurations, see the documentation for IwGxInit_Base(), IwGxInit_GLRender() etc. IwGxInit(); // Example main loop ExampleInit(); // Set screen clear colour IwGxSetColClear(0xff, 0xff, 0xff, 0xff); IwGxPrintSetColour(128, 128, 128); while (1) { s3eDeviceYield(0); s3eKeyboardUpdate(); s3ePointerUpdate(); int64 start = s3eTimerGetMs(); bool result = ExampleUpdate(); if ( (result == false) || (s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_DOWN) || (s3eKeyboardGetState(s3eKeyAbsBSK) & S3E_KEY_STATE_DOWN) || (s3eDeviceCheckQuitRequest()) ) break; // Clear the screen IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F); RenderButtons(); RenderSoftkeys(); ExampleRender(); // Attempt frame rate while ((s3eTimerGetMs() - start) < MS_PER_FRAME) { int32 yield = (int32) (MS_PER_FRAME - (s3eTimerGetMs() - start)); if (yield<0) break; s3eDeviceYield(yield); } } ExampleShutDown(); DeleteButtons(); IwGxTerminate(); return 0; }
int redisContextConnectTcpS3E(redisContext *c, const char *addr, int port) { int32 counter = 0; s3eInetAddress s3eaddr; uint64 testStartTime; memset(&s3eaddr, 0, sizeof(s3eaddr)); c->socket = s3eSocketCreate(S3E_SOCKET_TCP, 0); if (c->socket == NULL) return REDIS_ERR; c->flags &= ~REDIS_CONNECTED; if (s3eInetLookup(addr, &s3eaddr, NULL, NULL) == S3E_RESULT_ERROR) return REDIS_ERR; s3eaddr.m_Port = s3eInetHtons(port); if (s3eSocketConnect(c->socket, &s3eaddr, &redisContextConnectTcpS3ECB, c) != S3E_RESULT_SUCCESS) { switch (s3eSocketGetError()) { // These errors are 'OK', because they mean, // that a connect is in progress case S3E_SOCKET_ERR_INPROGRESS: case S3E_SOCKET_ERR_ALREADY: case S3E_SOCKET_ERR_WOULDBLOCK: break; default: return REDIS_ERR; } testStartTime = s3eTimerGetMs(); while (!s3eDeviceCheckQuitRequest() && s3eTimerGetMs()-testStartTime < 30000) { // Stop waiting since socket is now connected if (c->flags & REDIS_CONNECTED) break; // trying to connect ... s3eDeviceYield(30); } } if (c->flags & REDIS_CONNECTED) { s3eSocketSetOpt(c->socket,S3E_SOCKET_NODELAY,0,0); return REDIS_OK; } else { s3eSocketClose(c->socket); c->socket=NULL; return REDIS_ERR; } }
void PlayerCar::updateSpine() { float dt = (float)(s3eTimerGetMs() - lastFrameTime); lastFrameTime = s3eTimerGetMs(); animationTime += dt / 500.f; // ms to s animation->apply(skeleton, animationTime, true); skeleton->updateWorldTransform(); }
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; }
int CCApplication::Run() { IW_CALLSTACK("CCApplication::Run"); s3eBool quitRequested = 0; bool bNeedQuit = false; if (!applicationDidFinishLaunching() ) { return 0; } uint64 updateTime = 0 ; while (true) { updateTime = s3eTimerGetMs(); s3eDeviceYield(0); s3eKeyboardUpdate(); s3ePointerUpdate(); ccAccelerationUpdate(); quitRequested = s3eDeviceCheckQuitRequest(); if( quitRequested) { CCDirector* pDirector = CCDirector::sharedDirector(); // if opengl view has been released, delete the director. if (pDirector->getOpenGLView() == NULL) { CC_SAFE_DELETE(pDirector); bNeedQuit = true; } else { pDirector->end(); } } if( bNeedQuit ) { break; } CCDirector::sharedDirector()->mainLoop(); while ((s3eTimerGetMs() - updateTime) < m_nAnimationInterval) { int32 yield = (int32) (m_nAnimationInterval - (s3eTimerGetMs() - updateTime)); if (yield<0) break; s3eDeviceYield(yield); } } return -1; }
void GameTimeLabel::update() { if(stop) return; if(s3eTimerGetMs() - start >= 1000) { start = s3eTimerGetMs(); sec++; if(sec == 60) { sec = 0; min++; } updateString(); } }
//----------------------------------------------------------------------------- // Main global function //----------------------------------------------------------------------------- int main() { #ifdef EXAMPLE_DEBUG_ONLY // Test for Debug only examples #ifndef IW_DEBUG DisplayMessage("This example is designed to run from a Debug build. Please build the example in Debug mode and run it again."); return 0; #endif #endif Iw2DInit(); // Example main loop ExampleInit(); // Set screen clear colour while (1) { s3eDeviceYield(0); s3eKeyboardUpdate(); s3ePointerUpdate(); int64 start = s3eTimerGetMs(); bool result = ExampleUpdate(); if ( (result == false) || (s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_DOWN) || (s3eKeyboardGetState(s3eKeyAbsBSK) & S3E_KEY_STATE_DOWN) || (s3eDeviceCheckQuitRequest()) ) break; // Clear the screen Iw2DSurfaceClear(0xffffffff); RenderSoftkeys(); ExampleRender(); // Attempt frame rate while ((s3eTimerGetMs() - start) < MS_PER_FRAME) { int32 yield = (int32) (MS_PER_FRAME - (s3eTimerGetMs() - start)); if (yield<0) break; s3eDeviceYield(yield); } } ExampleShutDown(); Iw2DTerminate(); return 0; }
// time label GameTimeLabel::GameTimeLabel(int _min, int _sec) { switch(Settings::getInstance()->theme) { case SettingsThemeHacker: fontName = std::string("FontCourierNew16"); font = IGResourceManager::getInstance()->getFont(fontName); set(IGPoint(240,15), IGRect(180,30)); setColor(107,247,100,255); break; case SettingsThemeDetective: fontName = std::string("FontCourierNew14"); font = IGResourceManager::getInstance()->getFont(fontName); set(IGPoint(400,15), IGRect(100,30)); setColor(0,0,0,196); break; case SettingsThemeEspionage: fontName = std::string("FontCourierNew18"); font = IGResourceManager::getInstance()->getFont(fontName); set(IGPoint(290,18), IGRect(120,24)); setColor(72,72,72,196); break; } z = 2; tag = SceneGameTagTimeLabel; // time min = _min; sec = _sec; updateString(); // start start = s3eTimerGetMs(); stop = false; }
// Add request the back of the queue void CIwHTTPQueue::Post(const char* pURL, char* szBuffer, int bufferLen, void* pArgument, pCallback Callback, pCallbackError CallbackError, int timeout) { Request addRequest; char * newURL = new char [strlen(pURL)+1]; strcpy(newURL, pURL); addRequest.pURL = newURL; addRequest.pArgument = pArgument; addRequest.Callback = Callback; addRequest.CallbackError = CallbackError; addRequest.usePost = true; addRequest.szBuffer = szBuffer; addRequest.bufferLen = bufferLen; addRequest.timeout = timeout; m_Request.push_back(addRequest); if (m_Request.size() == 1) { m_HTTP.Cancel(); m_timeout = timeout; m_requestStart = s3eTimerGetMs(); m_HTTP.Post(pURL, szBuffer, bufferLen, GotHeaders, NULL); } }
bool CIwMapGame::GetLocation(s3eLocation& location) { uint64 timer = s3eTimerGetMs(); if (g_lastGpsLookup == 0 || (timer - g_lastGpsLookup) > 500) { if (S3E_RESULT_SUCCESS != s3eLocationGet(&location)) { return false; } s3eFilePrintf(g_pFile, "%lld\t%lld\t%4.9f\t%4.9f\t%4.9f\t%4.9f\t%4.9f\r\n", timer, location.m_TimeStampUTC, location.m_Longitude, location.m_Latitude, location.m_Altitude, location.m_HorizontalAccuracy, location.m_VerticalAccuracy); s3eFileFlush(g_pFile); if (g_bTrackingDistance) { g_distanceTravelled += LiveMaps::CalculateDistance(g_lastLocation, location); } g_lastLocation = location; g_lastGpsLookup = timer; return true; } else { if (g_lastGpsLookup) { location = g_lastLocation; return true; } return false; } }
int CCApplication::Run() { IW_CALLSTACK("CCApplication::Run"); s3eBool quitRequested = 0; if ( ! initInstance() || !applicationDidFinishLaunching() ) { return 0; } int64 updateTime = s3eTimerGetMs(); while (true) { int64 currentTime = s3eTimerGetMs(); if (currentTime - updateTime > m_nAnimationInterval) { updateTime = currentTime; s3eDeviceYield(0); s3eKeyboardUpdate(); s3ePointerUpdate(); ccAccelerationUpdate(); quitRequested = s3eDeviceCheckQuitRequest() ; if( quitRequested && CCDirector::sharedDirector()->getOpenGLView() != NULL ) { CCDirector::sharedDirector()->end() ; // end status will be processed in CCDirector::sharedDirector()->mainLoop(); } CCDirector::sharedDirector()->mainLoop(); if( quitRequested ) { break ; } } else { s3eDeviceYield(0); } } return -1; }
void SmoothScroll::StartScroll( const unsigned int direction, const double distance, const uint64 duration ) { m_direction = direction; m_duration = duration; m_isActive = true; m_distance = distance; m_startTime = s3eTimerGetMs(); }
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(int argc, char * argv[]) { std::srand((int)(s3eTimerGetMs() / 1000)); Graphics::init(); Input input; ResourceManager::getInstance().loadTexture("shark.png"); Game game; game.init(); int dt = 0; bool running; do { int64 timeStart = s3eTimerGetMs(); running = s3eDeviceCheckQuitRequest() == S3E_FALSE; Graphics::prepareFrame(); input.update(); if (input.pressed()) game.touch(input.getPointerX(), input.getPointerY()); else if (input.clicked()) game.release(input.getPointerX(), input.getPointerY()); game.update(dt); Graphics::redraw(); dt = s3eTimerGetMs() - timeStart; while (dt < MS_PER_FRAME) { int pause = (int)(MS_PER_FRAME - (s3eTimerGetMs() - timeStart)); if (pause < 0) break; s3eDeviceYield(pause); } dt = s3eTimerGetMs() - timeStart; } while (running); ResourceManager::getInstance().destoryTextures(); Graphics::destroy(); }
bool ExamplesMainUpdate() { s3eDeviceYield(0); s3eKeyboardUpdate(); s3ePointerUpdate(); int64 start = s3eTimerGetMs(); if (!ExampleUpdate() || ExampleCheckQuit()) { s3eDebugTracePrintf("ExampleUpdate returned false, exiting.."); return false; } // Clear the screen if (g_ClearScreen) IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F); ButtonsRender(); if (g_DrawCursor) CursorRender(); SoftkeysRender(); // User code render ExampleRender(); // Attempt frame rate while ((s3eTimerGetMs() - start) < MS_PER_FRAME) { int32 yield = (int32) (MS_PER_FRAME - (s3eTimerGetMs() - start)); if (yield<0) break; s3eDeviceYield(yield); } IwGxFlush(); IwGxSwapBuffers(); return true; }
void SmoothScroll::Update() { if( m_touchManager->GetSwipeDirection() != TouchManager::SD_NONE ) { const double distance = m_touchManager->GetSwipe()->m_delta.GetLength() * s_lengthFactor; const uint64 duration = static_cast< uint64 >( distance * s_durationFactor ); StartScroll( m_touchManager->GetSwipeDirection(), distance * s_distanceDecrease * s_timeCoef, duration ); m_touchManager->ResetSwipeDirection(); } if( m_isActive ) { const uint64 currentTime = s3eTimerGetMs() - m_startTime; if( currentTime <= m_duration ) { if( currentTime >= m_duration * s_percentOfSmoothingStart ) { m_distance = ( m_duration - currentTime ) * s_distanceDecrease; } switch( m_direction ) { case TouchManager::SD_LEFT: { m_stepX = m_distance; } break; case TouchManager::SD_RIGHT: { m_stepX = -m_distance; } break; case TouchManager::SD_UP: { m_stepY = m_distance; } break; case TouchManager::SD_DOWN: { m_stepY = -m_distance; } break; } } else { StopScroll(); } } }
void ciclo() { if (g_Input.getSound()) g_Input.playSong(); while (!s3eDeviceCheckQuitRequest()) { if (g_Input.getLifes()<1) { gameOver(); } if (menuB) break; s3eDeviceBacklightOn(); g_Input.updateSound(); s3eDeviceYield(0); int64 start = s3eTimerGetMs(); bool result = BaconUpdate(); bool result2 = FondoUpdate(); IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F); IwGxLightingOff(); FondoRender(); LifeStatusRender(); BaconRender(); insertaObstaculos(); spriteManager->render(); chuletas->render(); tank->render(); IwGxLightingOn(); FontLifeRender(); FontCoinsRender(); IwGxFlush(); IwGxSwapBuffers(); //g_Input.setScore(g_Input.getScore()+1); // Attempt frame rate /*while ((s3eTimerGetMs() - start) < MS_PER_FRAME) { int32 yield = (int32) (MS_PER_FRAME - (s3eTimerGetMs() - start)); if (yield<0) break; s3eDeviceYield(yield); }*/ } }
S3E_MAIN_DECL void IwMain() { Init(); // Set screen clear colour IwGxSetColClear(0, 0, 0, 0xff); IwGxPrintSetColour(128, 128, 128); while (1) { s3eDeviceYield(0); s3eKeyboardUpdate(); s3ePointerUpdate(); int64 start = s3eTimerGetMs(); bool result = Update(); if ( ((result == false) || (s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_DOWN) || (s3eKeyboardGetState(s3eKeyAbsBSK) & S3E_KEY_STATE_DOWN) || (s3eDeviceCheckQuitRequest())) ) break; Render(); // Attempt frame rate while ((s3eTimerGetMs() - start) < MS_PER_FRAME) { int32 yield = (int32) (MS_PER_FRAME - (s3eTimerGetMs() - start)); if (yield<0) break; s3eDeviceYield(yield); } } ShutDown(); }
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; }
void Game::Run() { uint64 now = s3eTimerGetMs(); while( true ) { s3eDeviceYield( 0 ); s3eKeyboardUpdate(); m_touchManager->Update(); m_accelerometerManager->Update(); m_webManager->Update(); if( ( s3eKeyboardGetState( s3eKeyEsc ) & S3E_KEY_STATE_DOWN ) || ( s3eKeyboardGetState( s3eKeyAbsBSK ) & S3E_KEY_STATE_DOWN ) || ( s3eDeviceCheckQuitRequest() ) ) { break; } const uint64 newTime = s3eTimerGetMs(); const uint64 deltaTime = newTime - now; now = newTime; Update( deltaTime ); Render(); while( ( s3eTimerGetMs() - newTime) < s_msPerFrame ) { const int32 yield = static_cast<int32>( s_msPerFrame - ( s3eTimerGetMs() - newTime ) ); if( yield < 0 ) { break; } s3eDeviceYield( yield ); } } }
void MatrixManager::Star::UpdateStar() { if (enabled <= 0) return; // if (((int)s3eTimerGetMs() - time_appeared) < 1000) { size_frame = ((1000 - (int)s3eTimerGetMs() + time_appeared) * 15) / 1000; } else if (((int)s3eTimerGetMs() - time_appeared) >= (timeout - 1000)) { size_frame = (((int)s3eTimerGetMs() - time_appeared - timeout + 1000) * 15) / 1000; } else { size_frame = 0; } rot = rot + rot_inc; rot = rot & 0x0fff; // if (((int)s3eTimerGetMs() - time_appeared) > timeout) enabled = 0; }
void MatrixManager::Star::SetStar() { { enabled = 1; multiplier = 8 + (rand() % 24); rot_inc = (rand() % 128) - 64; star_hue = (rand() % 16); rot = 0; time_appeared = (int)s3eTimerGetMs(); timeout = 2000 + (rand() % 10000); fx = (rand() % FIELD_RES); fy = (rand() % FIELD_RES); size_frame = 15; } }
//----------------------------------------------------------------------------- void ExampleInit() { Iw2DInit(); Iw2DSetColour(0xffffffff); g_Image = Iw2DCreateImage("Image.png"); // g_accumulator = 0.0f; g_prevTime = s3eTimerGetMs(); // create a box2d world if( !(g_world = new b2World(g_gravity)) ) { /*error*/ } // add a boundary at the edge of the screen b2BodyDef bodyDef; bodyDef.type = b2_staticBody; bodyDef.position.Set(0, 0); b2Body* boundaryBody = g_world->CreateBody(&bodyDef); const float hw = (float)Iw2DGetSurfaceWidth() * 0.5f / 8; const float hh = (float)Iw2DGetSurfaceHeight() * 0.5f / 8; b2Vec2 list[] = { b2Vec2(-hw, -hh), b2Vec2(hw, -hh), b2Vec2(hw, hh), b2Vec2(-hw, hh) }; const int numVerts = sizeof(list) / sizeof(b2Vec2); b2ChainShape loopShape; loopShape.CreateLoop(list, numVerts); boundaryBody->CreateFixture(&loopShape, 0.0f); // add a dynamic body // b2BodyDef bodyDef; bodyDef.type = b2_dynamicBody; bodyDef.position.Set(0, 0); g_body = g_world->CreateBody(&bodyDef); g_body->SetLinearDamping(0.1f); b2PolygonShape polygonShape; polygonShape.SetAsBox(0.5f * (8/2), 0.5f * (8/2)); b2FixtureDef fd; fd.shape = &polygonShape; fd.friction = 0.5f; fd.density = 10.0f; fd.restitution = 0.5f; g_body->CreateFixture(&fd); g_body->SetAngularVelocity(2.15f); // set the dynamic object initially spinning, so that it bounces more interestingly on the 'ground' }
bool CIwGameAds::ExtractAdMillennialMedia(CIwGameAd& ad, CIwGameString& ad_body) { ad.isHtml = false; ad.isText = false; ad.ImageURI = ""; ad.LinkURI = ""; ad.Text = ""; ad.AdTime = s3eTimerGetMs(); ExtractLinkAndImageFromtHTML(ad, ad_body); if (ad.LinkURI.IsEmpty() || ad.ImageURI.IsEmpty()) return false; return true; }