void ExampleRender() { int y = 150; IwGxPrintString(30, y, g_UseSoundPool ? "Using Sound Pool" : "Using Sound Streaming"); y += 20; for (int i = 0; i < MAX_SAMPLES; i++) { if (!g_Buttons[i]) break; char buffer[0x100]; const char* pState; switch (g_SampleState[i]) { case 1: pState = "Playing"; break; case 2: pState = "Paused"; break; default: pState = "Stopped"; break; } sprintf(buffer, "Sample: %d State: %s", i, pState); IwGxPrintString(30, y, buffer); y += 20; } IwGxFlush(); IwGxSwapBuffers(); }
// Example showing how to use the s3eWwise extension int main() { IW_CALLSTACK("main"); s3eDebugOutputString("Booting s3eWwise example"); initWwise(); s3ePointerRegister(S3E_POINTER_BUTTON_EVENT, (s3eCallback)buttonEvent, NULL); s3ePointerRegister(S3E_POINTER_MOTION_EVENT, (s3eCallback)motionEvent, NULL); IwGxInit(); IwGxSetColClear(0, 0, 0, 0xff); while(!s3eDeviceCheckQuitRequest()) { std::stringstream str; s3eWwiseSoundEngineRenderAudio(); IwGxClear(); IwGxPrintString(100, 100, "s3eWwise"); IwGxPrintString(100, 300, "Touch to fire event"); str << "RPM = " << rpm; IwGxPrintString(100, 400, str.str().c_str()); str.str(std::string()); str << "TH = " << touchHeight; IwGxPrintString(100, 500, str.str().c_str()); str.str(std::string()); str << "Height = " << height; IwGxPrintString(100, 600, str.str().c_str()); str.str(std::string()); IwGxFlush(); IwGxSwapBuffers(); s3eDeviceYield(0); } IwGxTerminate(); s3ePointerUnRegister(S3E_POINTER_BUTTON_EVENT, (s3eCallback)buttonEvent); s3ePointerUnRegister(S3E_POINTER_MOTION_EVENT, (s3eCallback)motionEvent); shutdownWwise(); return 0; }
void CGame::Render() { // for example, clear to black (the order of components is ABGR) Iw2DSurfaceClear(0x00ecdeff); Iw2DSetColour(0xffffffff); std::string s; if(_currentLevel==0) s.append("Lobby"); else { s.append("Level "); std::ostringstream ss; ss << _currentLevel; s.append(ss.str()); } IwGxPrintSetScale(2); IwGxPrintString(630, 10, (char*)s.c_str()); currentMap->Render(_Character->m_CollisionBox); _Character->Render(currentMap->m_Position); _UI->Render(); if(_firstLaunch) Iw2DDrawImage(_imageTut[0],CIwSVec2(300,300)); if(_currentLevel==1&&_firstLaunchLevel1) Iw2DDrawImage(_imageTut[1],CIwSVec2(300,300)); if(_enterDoor) Iw2DDrawImage(_imageTut[2],CIwSVec2(300,300)); if(_mazeFinish) Iw2DDrawImage(_imageTut[3],CIwSVec2(300,300)); // show the surface Iw2DSurfaceShow(); }
void Button::Render() { if(btn_type==IMAGE) Iw2DDrawImage(_image, m_ImgPos); else { Iw2DSetColour(bg_color); if(btn_type==RECT||btn_type==TEXT) Iw2DFillRect(m_BGPos,m_BGSize); else if(btn_type==SPHERE) Iw2DFillArc(m_BGPos+CIwSVec2(m_BGSize.x/2,m_BGSize.y/2), m_BGSize, iwangle(0), iwangle(0x1600), 40); if(btn_type==TEXT) { uint8 rgb[4]; rgb[0]=(text_color & 0x000000ff);//A rgb[1]=(text_color & 0x0000ff00) >>8;//B rgb[2]=(text_color & 0x00ff0000) >>16;//G rgb[3]=(text_color & 0xff000000) >>24;//R IwGxPrintSetColour(rgb[3], rgb[2], rgb[1]); IwGxPrintSetScale(2); IwGxPrintString(m_TextPos.x, m_TextPos.y, m_text); } Iw2DSetColour(C_WHITE); }
void render() { IwGxClear(); for (int index = 0; index < 4; ++index) { m_controllers[index].Render(); } IwGxPrintString(300, 50, g_debugButtonEvent); IwGxPrintString(300, 75, g_debugKeyEvent); IwGxPrintString(300, 100, g_debugMotionEvent); IwGxPrintString(300, 125, g_debugTouchEvent); IwGxPrintString(300, 150, g_debugTouchMotionEvent); IwGxFlush(); IwGxSwapBuffers(); }
int main() { IwGxInit(); Iw2DInit(); AppWarp::Client* WarpClientRef; AppWarp::Client::initialize("b29f4030aba3b2bc7002c4eae6815a4130c862c386e43ae2a0a092b27de1c5af","bf45f27e826039754f8dda659166d59ffb7b9dce830ac51d6e6b576ae4b26f7e"); WarpClientRef = AppWarp::Client::getInstance(); MenuScreen *menu = new MenuScreen; GameScreen *game = new GameScreen(WarpClientRef); Game *gm = new Game; gm->AddScene("game",game); gm->AddScene("menu",menu); menu->game = game; menu->app = gm; Listener listener(WarpClientRef,game); WarpClientRef->setConnectionRequestListener(&listener); WarpClientRef->setRoomRequestListener(&listener); WarpClientRef->setNotificationListener(&listener); s3ePointerRegister(S3E_POINTER_BUTTON_EVENT,(s3eCallback)HandleSingleTouchButtonCB,gm); while(!s3eDeviceCheckQuitRequest()) { s3eKeyboardUpdate(); if(s3eKeyboardGetState(s3eKeyAbsBSK) & S3E_KEY_STATE_DOWN) break; WarpClientRef->update(); s3ePointerUpdate(); IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F); IwGxPrintSetScale(2); IwGxPrintString(0,0,game->msg.c_str()); gm->Move(); gm->Render(); Iw2DSurfaceShow(); s3eDeviceYield(); } s3ePointerUnRegister(S3E_POINTER_BUTTON_EVENT,(s3eCallback)HandleSingleTouchButtonCB); gm->CleanUp(); delete menu; delete game; delete gm; WarpClientRef->terminate(); Iw2DTerminate(); IwGxTerminate(); }
static void SoftkeyRender(const char* text, s3eDeviceSoftKeyPosition pos, void(*handler)()) { // TODO: Hardocoded font width and height (boo!) int width = 7; int height = 30; width *= strlen(text) * 2; int x = 0; int y = 0; switch (pos) { case S3E_DEVICE_SOFTKEY_BOTTOM_LEFT: y = IwGxGetScreenHeight() - height; x = 0; break; case S3E_DEVICE_SOFTKEY_BOTTOM_RIGHT: y = IwGxGetScreenHeight() - height; x = IwGxGetScreenWidth() - width; break; case S3E_DEVICE_SOFTKEY_TOP_RIGHT: y = 0; x = IwGxGetScreenWidth() - width; break; case S3E_DEVICE_SOFTKEY_TOP_LEFT: x = 0; y = 0; break; } CIwMaterial *fadeMat = IW_GX_ALLOC_MATERIAL(); fadeMat->SetAlphaMode(CIwMaterial::SUB); IwGxSetMaterial(fadeMat); IwGxPrintString(x + 10, y+10, text, false); CIwColour* cols = IW_GX_ALLOC(CIwColour, 4); memset(cols, 50, sizeof(CIwColour)*4); if (s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_PRESSED) { int pointerx = s3ePointerGetX(); int pointery = s3ePointerGetY(); if (pointerx >= x && pointerx <= x+width && pointery >=y && pointery <= y+height) { memset(cols, 15, sizeof(CIwColour)*4); handler(); } } // Draw button area CIwSVec2 XY(x, y-2), dXY(width, height); IwGxDrawRectScreenSpace(&XY, &dXY, cols); }
void HexMapTest::DebugPrint(int closestX, int closestY) { char string [180]; //sprintf(string, "`1`a 1 %03d, %03d",sprite1_pos_x_initial, sprite1_pos_y_initial); //IwGxPrintString(2, 16, string); //sprintf(string, "`1`a 2 %03d, %03d",sprite1_pos_x, sprite1_pos_y); //IwGxPrintString(2, 32, string); //sprintf(string, "`1`a c %03d", g_Input.getTouchCount()); //IwGxPrintString(2, 48, string); //if (g_Input.getTouchCount() > 0) { // CIwVec3 vect = getWorldCoords(sprite1_pos_x_initial, sprite1_pos_y_initial); // sprintf(string, "`1`a w1 %03d, %03d", vect.x, vect.y); // IwGxPrintString(2, 64, string); // CIwVec3 vect2 = getWorldCoords(sprite1_pos_x, sprite1_pos_y); // sprintf(string, "`1`a w2 %03d, %03d", vect2.x, vect2.y); // IwGxPrintString(2, 80, string); //} //sprintf(string, "`1`a o%03d, %03d",origin.x,origin.y); //IwGxPrintString(2, 38, string); //sprintf(string, "`1`a d%03d, %03d, %03d",dir.x,dir.y,dir.z); //IwGxPrintString(2, 54, string); sprintf(string, "`1`a hex %03d, %03d",closestX, closestY); IwGxPrintString(2, 16, string); //{ // int16 sprite1_pos_x,sprite1_pos_y,sprite1_pos_x_initial,sprite1_pos_y_initial; // if (g_Input.finger1MovedTo(sprite1_pos_x,sprite1_pos_y)) { // g_Input.finger1Initial(sprite1_pos_x_initial,sprite1_pos_y_initial); // sprintf(string, "`1`a ini %04d, %04d",sprite1_pos_x_initial,sprite1_pos_y_initial); // IwGxPrintString(2, 32, string); // sprintf(string, "`1`a cur %04d, %04d",sprite1_pos_x,sprite1_pos_y); // IwGxPrintString(2, 48, string); // } //} //{ // int16 sprite2_pos_x,sprite2_pos_y,sprite2_pos_x_initial,sprite2_pos_y_initial; // if (g_Input.finger2MovedTo(sprite2_pos_x,sprite2_pos_y)) { // g_Input.finger2Initial(sprite2_pos_x_initial,sprite2_pos_y_initial); // sprintf(string, "`1`a ini %04d, %04d",sprite2_pos_x_initial,sprite2_pos_y_initial); // IwGxPrintString(2, 64, string); // sprintf(string, "`1`a cur %04d, %04d",sprite2_pos_x,sprite2_pos_y); // IwGxPrintString(2, 80, string); // } //} //{ // int16 x, y; // CIwVec3 worldpos(0, 0, 0); // IwGxWorldToScreenXY(x, y, worldpos); // x = IwGxGetScreenWidth() - x; // y = IwGxGetScreenHeight() - y; // sprintf(string, "`1`a p%03d, %03d", x, y); // IwGxPrintString(2, 86, string); //} }
int main() { IwGxInit(); IwGxSetColClear(0, 0, 0xff, 0xff); while (!s3eDeviceCheckQuitRequest() && !(s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_DOWN) && !(s3eKeyboardGetState(s3eKeyAbsBSK) & S3E_KEY_STATE_DOWN)) { IwGxClear(); IwGxPrintString(120, 150, "Hello, World!"); IwGxFlush(); IwGxSwapBuffers(); s3eDeviceYield(0); } IwGxTerminate(); return 0; }
bool ExampleUpdate(float dt) { IW_PROFILE("update"); UpdateScreenOrientation(); m_pAnimator->Update(dt); m_pSplinePoly2Tri->SetSpline(m_pAnimator->GetCurrentSpline()); m_pSplinePoly2Tri->Generate(); m_pBall->Update(dt); if (s_Accelerometer) { //iAccX = iClamp(iAccX, 0, 70 m_pBall->SetAcceleration(Vector2i((int16)s3eAccelerometerGetX(), (int16)s3eAccelerometerGetY())); } // check collision //if (m_pSplineTriFan->IsPointWithin(m_pBall->GetPos())) //{ // IwGxPrintString(10, 10, "collision yes", true); //} //else //{ // IwGxPrintString(10, 10, "collision no", true); // g_fLife += -0.1f * dt; //} char strLife[50]; sprintf(strLife, "life left: %f", g_fLife); IwGxPrintString(10, 20, strLife, true); if (g_fLife <= 0.0f) { ResetGame(); } return true; }
void Panel::Render() { if(isDisplay){ if(m_images.size()>0) { Iw2DDrawImage(m_images[m_images.size()-1], m_BGPos); } else { Iw2DSetColour(bg_color); Iw2DFillRect(m_BGPos,m_BGSize); Iw2DSetColour(0xffffffff); } if(m_text!="") { IwGxPrintSetColour(text_color[3], text_color[2], text_color[1]); IwGxPrintSetScale(m_TextScale); IwGxPrintString(m_TextPos.x, m_TextPos.y, m_text); } for(int i=m_btns.size()-1;i!=-1;i--) m_btns[i]->Render(); } }
//----------------------------------------------------------------------------- void ExampleRender() { // Clear screen IwGxClear( IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F ); // Render text int sx = 10; int sy = 40; std::list<Request *>::const_iterator e = manager.get_queue().end(); std::list<Request *>::const_iterator i = manager.get_queue().begin(); int count = 0; for( ; i != e; i++ ) { char buf[1024]; const char *name = HTTPStatusName[(*i)->get_state()]; snprintf(buf, 1023, "%d) %s: %s/%d (%s)",count,(*i)->get_url().c_str(),name,(*i)->get_content_length(),(*i)->get_errmsg().c_str()); IwGxPrintString(sx, sy, buf, true); sy += 20; count++; } // Swap buffers IwGxFlush(); IwGxSwapBuffers(); }
void TextButton::Render() { IwGxPrintString(m_x, m_y, m_text.c_str()); }
extern "C" void RenderCursorskeys() { int height = 20; int width = 45; int lefty = IwGxGetScreenHeight() - (height * 2); int leftx = (IwGxGetScreenWidth() - 220) / 2; int upy = IwGxGetScreenHeight() - (height * 3); int upx = leftx+width + (width/2); int downy = IwGxGetScreenHeight() - height; int downx = upx; int righty = IwGxGetScreenHeight() - (height * 2); int rightx = downx + width + (width/2); CIwMaterial *fadeMat = IW_GX_ALLOC_MATERIAL(); fadeMat->SetAlphaMode(CIwMaterial::SUB); IwGxSetMaterial(fadeMat); g_Cursorkey = EXCURSOR_NONE; if ( (s3eKeyboardGetState(s3eKeyLeft) & S3E_KEY_STATE_DOWN) ) g_Cursorkey = EXCURSOR_LEFT; if ( (s3eKeyboardGetState(s3eKeyRight) & S3E_KEY_STATE_DOWN) ) g_Cursorkey = EXCURSOR_RIGHT; if ( (s3eKeyboardGetState(s3eKeyUp) & S3E_KEY_STATE_DOWN) ) g_Cursorkey = EXCURSOR_UP; if ( (s3eKeyboardGetState(s3eKeyDown) & S3E_KEY_STATE_DOWN) ) g_Cursorkey = EXCURSOR_DOWN; if(s3ePointerGetInt(S3E_POINTER_AVAILABLE)) { if (s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_DOWN) { int pointerx = s3ePointerGetX(); int pointery = s3ePointerGetY(); // Check left if (pointerx >= leftx && pointerx <= leftx+width && pointery >=lefty && pointery <= lefty+height) g_Cursorkey = EXCURSOR_LEFT; // Check right if (pointerx >= rightx && pointerx <= rightx+width && pointery >=righty && pointery <= righty+height) g_Cursorkey = EXCURSOR_RIGHT; // Check up if (pointerx >= upx && pointerx <= upx+width && pointery >=upy && pointery <= upy+height) g_Cursorkey = EXCURSOR_UP; // Check down if (pointerx >= downx && pointerx <= downx+width && pointery >=downy && pointery <= downy+height) g_Cursorkey = EXCURSOR_DOWN; } CIwColour* cols = IW_GX_ALLOC(CIwColour, 4); if((s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_DOWN) && (g_Cursorkey != EXCURSOR_NONE)) memset(cols, 10, sizeof(CIwColour)*4); else memset(cols, 50, sizeof(CIwColour)*4); // draw black rect covering screen CIwSVec2 rectdim(width, height); CIwSVec2 uXY(upx, upy-2); IwGxDrawRectScreenSpace(&uXY, &rectdim, cols); IwGxPrintString(upx + 10, upy + 5, "Up", false); CIwSVec2 dXY(downx, downy-2); IwGxDrawRectScreenSpace(&dXY, &rectdim, cols); IwGxPrintString(downx + 10, downy + 5, "Down", false); CIwSVec2 lXY(leftx, lefty-2); IwGxDrawRectScreenSpace(&lXY, &rectdim, cols); IwGxPrintString(leftx + 10, lefty + 5, "Left", false); CIwSVec2 rXY(rightx, righty-2); IwGxDrawRectScreenSpace(&rXY, &rectdim, cols); IwGxPrintString(rightx + 10, righty + 5, "Right", false); } }
extern "C" void RenderButtons() { ExButtons* pbutton = g_ButtonsHead; if(g_ButtonsHead) { pbutton = g_ButtonsHead; while(pbutton != NULL) { // Check the key and pointer states. pbutton->key_state = s3eKeyboardGetState(pbutton->key); if( s3eKeyboardGetState(pbutton->key) & S3E_KEY_STATE_DOWN ) { if(pbutton->handler) pbutton->handler(); } if (!(s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_UP)) { int pointerx = s3ePointerGetX(); int pointery = s3ePointerGetY(); if (pointerx >= pbutton->x && pointerx <= pbutton->x+pbutton->w && pointery >=pbutton->y && pointery <= pbutton->y+pbutton->h) { if (s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_DOWN) { pbutton->key_state = S3E_KEY_STATE_DOWN; } if (s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_PRESSED) { pbutton->key_state = S3E_KEY_STATE_PRESSED; } if(pbutton->handler) pbutton->handler(); } } // Draw the text IwGxSetScreenSpaceSlot(0); if(s3ePointerGetInt(S3E_POINTER_AVAILABLE)) { CIwMaterial *fadeMat = IW_GX_ALLOC_MATERIAL(); fadeMat->SetAlphaMode(CIwMaterial::SUB); IwGxSetMaterial(fadeMat); CIwColour* cols = IW_GX_ALLOC(CIwColour, 4); if(pbutton->key_state == S3E_KEY_STATE_DOWN) memset(cols, 15, sizeof(CIwColour)*4); else memset(cols, 50, sizeof(CIwColour)*4); // Draw button area CIwSVec2 XY(pbutton->x, pbutton->y-2), dXY(pbutton->w, pbutton->h); IwGxDrawRectScreenSpace(&XY, &dXY, cols); } IwGxPrintString(pbutton->x + 2, pbutton->y + ((pbutton->h - 10)/2), pbutton->name, false); pbutton = pbutton->next; } } }
void PrintfProperty(int16 x, int16 y, const char* str, float f) { char strstr[50]; sprintf(strstr, "%s: %f", str, f); IwGxPrintString(x, y, strstr, true); }
//----------------------------------------------------------------------------- bool HexMapTest::Update() { int16 sprite1_pos_x,sprite1_pos_y; int16 sprite2_pos_x,sprite2_pos_y; if (mouse_mode == MOUSE_MODE_CHECKING) mouse_mode = MOUSE_MODE_DOWN; // UI processing if (((s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_PRESSED)) && mouse_mode == MOUSE_MODE_IDLE) mouse_mode = MOUSE_MODE_IDLE; if ((s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_RELEASED)) mouse_mode = MOUSE_MODE_CHECKING; // UpdateKey(); IwGxSetViewMatrix(&s_viewMatrix); // Generate a ray pointing to the view plane from the camera CIwVec3 dir(s3ePointerGetX() - IwGxGetScreenWidth()/2, s3ePointerGetY() - IwGxGetScreenHeight()/2, IwGxGetPerspMul()); // Rotate into camera space dir = s_viewMatrix.RotateVec(dir); // Update pointer system g_Input.Update(); if (g_Input.finger1IsDown()) { if (g_Input.overThreshold()) { if (!g_Input.finger1Continuing()) { s_ModelMatrix_initial = s_ModelMatrix; CIwVec3 vectCenter = getWorldCoords(0, 0); zoom_initial = zoom; rotation_initial = rotation; screenTranslationX_initial = screenTranslationX; screenTranslationY_initial = screenTranslationY; if (!g_Input.isMultiTouch()) { if (g_Input.finger1MovedTo(sprite1_pos_x, sprite1_pos_y)) { if (sprite1_pos_x > int(IwGxGetScreenWidth()) - SCREEN_MARGIN) { zooming = true; } if (sprite1_pos_y > int(IwGxGetScreenHeight()) - SCREEN_MARGIN) { rotating = true; } } } } if (!g_Input.finger2IsDown() && g_Input.finger1MovedTo(sprite1_pos_x, sprite1_pos_y)) { if (g_Input.finger1Continuing()) { if (zooming) { if (sprite1_pos_x > int(IwGxGetScreenWidth()) - SCREEN_MARGIN) { int16 dsprite1_pos_x, dsprite1_pos_y; if (g_Input.finger1MovementDelta(dsprite1_pos_x, dsprite1_pos_y)) { float deltaZoom = 1.0f - 1.0f*(dsprite1_pos_y)/IwGxGetScreenHeight(); SetZoom(deltaZoom, 8); } } } else if (rotating) { if (sprite1_pos_y > int(IwGxGetScreenHeight()) - SCREEN_MARGIN) { int16 dsprite1_pos_x, dsprite1_pos_y; if (g_Input.finger1MovementDelta(dsprite1_pos_x, dsprite1_pos_y)) { float deltaRotation = 360.0f*(dsprite1_pos_x)/IwGxGetScreenWidth(); SetRotation(deltaRotation); } } } else { SetTranslation(); } } } else { if (g_Input.finger1MovedTo(sprite1_pos_x, sprite1_pos_y)) { if (g_Input.finger2MovedTo(sprite2_pos_x, sprite2_pos_y)) { if (!g_Input.finger2Continuing()) { screenTranslationX_initial = screenTranslationX; screenTranslationY_initial = screenTranslationY; g_Input.resetInitial(0); } else { int16 sprite1_pos_x_initial,sprite1_pos_y_initial,sprite2_pos_x_initial,sprite2_pos_y_initial; g_Input.finger1Initial(sprite1_pos_x_initial,sprite1_pos_y_initial); g_Input.finger2Initial(sprite2_pos_x_initial,sprite2_pos_y_initial); int d12x=sprite1_pos_x-sprite2_pos_x; int d12y=sprite1_pos_y-sprite2_pos_y; int d12x_initial=sprite1_pos_x_initial-sprite2_pos_x_initial; int d12y_initial=sprite1_pos_y_initial-sprite2_pos_y_initial; int Delta_initial = d12x_initial*d12x_initial+d12y_initial*d12y_initial; int Delta = d12x*d12x+d12y*d12y; float newZoom = float(sqrt(1.0*Delta)/sqrt(Delta_initial)); SetZoom(newZoom, 1); float oldRotation = float(atan2(float(d12y_initial), float(d12x_initial))); float newRotation = float(atan2(float(d12y), float(d12x))); SetRotation(180.0f*(oldRotation-newRotation)/PI); { char string[256]; //sprintf(string, "`1`a del %04d, %04d",d1x,d2x); //IwGxPrintString(2, 96, string); sprintf(string, "`1`a zoo %5.2f, %5.2f, %5.2f",newZoom,oldRotation,newRotation); IwGxPrintString(2, 96, string); } } } } } } } else { zooming = false; rotating = false; // s_ModelMatrix = CIwMat::g_Identity; } return true; }