Example #1
0
void renderMapHealth() {
	IwGxLightingOff();

	Iw2DSetAlphaMode(IW_2D_ALPHA_NONE);
	Iw2DSetTransformMatrix(CIwFMat2D::g_Identity);

	int16 w = (double)IwGxGetScreenWidth() * 0.09f;
	if (w > (int16)healthTexture->GetWidth()) w = (int16)healthTexture->GetWidth();

	float whScale = (float)((double)healthTexture->GetWidth() / healthTexture->GetHeight());
	int16 h = w * 1/whScale;

	int leftPadding = IwGxGetScreenWidth() * 0.10f;
	int topPadding = IwGxGetScreenHeight() * 0.02f;

	int leftMargin = IwGxGetScreenWidth() * 0.03f;
	int topMargin = IwGxGetScreenHeight() * 0.05f;

	CIwFVec2 size = CIwFVec2(w, h);
	int vitality = getGameState()->getPlayer()->getVitality();
	
	for (int i = 0; i < PLAYER_MAX_VITALITY; i++) {
		CIwFVec2 topLeft = CIwFVec2(leftPadding + (leftMargin+w)*i, topPadding);

		if (i < vitality) {
			Iw2DDrawImage(healthTexture, topLeft, size);
		} else {
			Iw2DDrawImage(healthLostTexture, topLeft, size);
		}
	}
}
Example #2
0
void cameraStreamInit(int camDataW, int camDataH) {
	double w = IwGxGetScreenWidth();
	double h = IwGxGetScreenHeight();

	IwTrace(GHOST_HUNTER, ("camDataW %d camDataH %d w %f h %f", camDataW, camDataH, w, h));
	{
		double whRatio = ((double)camDataW) / camDataH;

		if (whRatio > w/h) {
			w = h * whRatio;
		} else if (whRatio < w/h) {
			h = w * 1.f/whRatio;
		}
	}

	IwTrace(GHOST_HUNTER, ("w %f h %f", w, h));

	int16 x1 = (int16)(-abs(w - IwGxGetScreenWidth())/2); // Negative or 0
	int16 x2 = (int16)(IwGxGetScreenWidth()  - x1);
	int16 y1 = (int16)(-abs(h - IwGxGetScreenHeight())/2); // Negative or 0
	int16 y2 = (int16)(IwGxGetScreenHeight() - y1);

	cameraVert[0].x = x1, cameraVert[0].y = y1;
	cameraVert[1].x = x1, cameraVert[1].y = y2;
	cameraVert[2].x = x2, cameraVert[2].y = y2;
	cameraVert[3].x = x2, cameraVert[3].y = y1;

	cameraUvs[0] = CIwFVec2(1, 0);
    cameraUvs[1] = CIwFVec2(1, 1);
    cameraUvs[2] = CIwFVec2(0, 1);
    cameraUvs[3] = CIwFVec2(0, 0);
}
Example #3
0
void ghostInit() {
	mapGhost = new MapRoamingGhost("textures/map_ghost.png", 
		CIwFVec2(IwGxGetScreenWidth()/2, IwGxGetScreenHeight()/2));
	mapGhost->modifyCentreWithTexture(-0.18f, -0.13f);
	mapGhost->setNotice(true);

	mapGhost2 = new MapRoamingGhost("textures/map_ghost_xtra.png", 
		CIwFVec2(IwGxGetScreenWidth()*0.80f, IwGxGetScreenHeight()*0.70f));
}
Example #4
0
CIwSVec2* AllocClientScreenRectangle()
{
    CIwSVec2* pCoords = IW_GX_ALLOC(CIwSVec2, 4);
    pCoords[0].x = 0; pCoords[0].y = 0;
    pCoords[1].x = 0; pCoords[1].y = (int16)IwGxGetScreenHeight();
    pCoords[2].x = (int16)IwGxGetScreenWidth(); pCoords[2].y = 0;
    pCoords[3].x = (int16)IwGxGetScreenWidth(); pCoords[3].y = (int16)IwGxGetScreenHeight();

    return pCoords;
}
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);
}
Example #6
0
void MyWorld::Update()
{
    // Adjust perspective based on dimensions of screen to keep board in view
    int max = IwGxGetScreenHeight() > IwGxGetScreenWidth() ? IwGxGetScreenHeight() : IwGxGetScreenWidth();
    setPerspective(480.0f - (1024 - max) / 2);

    // Update camera swing
    if (CamSwing)
    {
        float d = CamSwingTime / CAM_SWING_TIME;
        LookFrom.x = StartCamSwingPos.x + (FinalCamSwingPos.x - StartCamSwingPos.x) * d;
        LookFrom.y = StartCamSwingPos.y + (FinalCamSwingPos.y - StartCamSwingPos.y) * d;
        LookFrom.z = StartCamSwingPos.z + (FinalCamSwingPos.z - StartCamSwingPos.z) * d;
        TransformDirty = true;
        CamSwingTime++;
        if (CamSwingTime > CAM_SWING_TIME)
        {
            CamSwing = false;
            CamSwingTime = 0;
        }
    }

    // TODO: Add world logic here
    World::Update();

    switch (GameState)
    {
    case eGameState_GameOver:
        if (GameOverTimer.HasTimedOut())
        {
            RestartGame();
        }
        break;
    case eGameState_Running:
        if (TurnsLeftChanged)
        {
            char str[64];
            snprintf(str, 64, "%u", TurnsLeft);
            TurnsLeftLabel->setText(str);
            TurnsLeftChanged = false;
        }
        if (RoundChanged)
        {
            char str[64];
            snprintf(str, 64, "%u", Round);
            RoundLabel->setText(str);
            RoundChanged = false;
        }
        break;
    }

}
Example #7
0
void MainMenu::Init()
{
    Scene::Init();

    Game* game = (Game*)g_pSceneManager->Find("game");

    // Create menu background
    CSprite* background = new CSprite();
    background->m_X = (float)IwGxGetScreenWidth() / 2;
    background->m_Y = (float)IwGxGetScreenHeight() / 2;
    background->SetImage(g_pResources->getMenuBG());
    background->m_W = background->GetImage()->GetWidth();
    background->m_H = background->GetImage()->GetHeight();
    background->m_AnchorX = 0.5;
    background->m_AnchorY = 0.5;
    // Fit background to screen size
    background->m_ScaleX = (float)IwGxGetScreenWidth() / background->GetImage()->GetWidth();
    background->m_ScaleY = (float)IwGxGetScreenHeight() / background->GetImage()->GetHeight();
    AddChild(background);

    // Create Start Game button
    float y_pos = (float)IwGxGetScreenHeight() * 0.66f;
    playButton = new CSprite();
    playButton->SetImage(g_pResources->getPlacard());
    playButton->m_X = IwGxGetScreenWidth() / 2.0f;
    playButton->m_Y = y_pos;
    playButton->m_W = playButton->GetImage()->GetWidth();
    playButton->m_H = playButton->GetImage()->GetHeight();
    playButton->m_AnchorX = 0.5f;
    playButton->m_AnchorY = 0.5f;
    playButton->m_ScaleX = game->getGraphicsScale() * 1.5f;
    playButton->m_ScaleY = game->getGraphicsScale() * 1.5f;
    AddChild(playButton);

    // Create Start Game button text
    playText = new CSprite();
    playText->SetImage(g_pResources->getPlayButton());
    playText->m_X = (float)IwGxGetScreenWidth() / 2;
    playText->m_Y = y_pos;
    playText->m_W = playText->GetImage()->GetWidth();
    playText->m_H = playText->GetImage()->GetHeight();
    playText->m_AnchorX = 0.5f;
    playText->m_AnchorY = 0.5f;
    playText->m_ScaleX = game->getGraphicsScale();
    playText->m_ScaleY = game->getGraphicsScale();
    AddChild(playText);

    // Start menu music
    Audio::PlayMusic("audio/frontend.mp3");

}
void TransitionObject::Initialize()
{
	color = WHITE;
	state = NO_TRANSITION;

	for( int i = 0; i < numOfOverlays; i++ )
	{
		
		transitionSprite[i].setUWidth( 480 );
		transitionSprite[i].setUHeight( 320 );
		transitionSprite[i].setSize( 480, 320 );

		switch( i )
		{
		case 0:
			transitionImage[i] = Iw2DCreateImage( "white.png" );
			break;
		case 1:
			transitionImage[i] = Iw2DCreateImage( "black.png" );
			break;
		case 2:
			break;
		}
		
		transitionSprite[i].setImage( transitionImage[i] );
		transitionSprite[i].setDelayTime( 1 );
		transitionSprite[i].setPosition( IwGxGetScreenWidth()/2, IwGxGetScreenHeight()/2 );
	}

}
Example #9
0
void HexMapTest::SetModelMatrix() {
	s_ModelMatrix.SetIdentity();
	CIwVec3 vectCenter = getWorldCoords(IwGxGetScreenWidth()/2, IwGxGetScreenHeight()/2);
	s_ModelMatrix.t.x = vectCenter.x;
	s_ModelMatrix.t.y = vectCenter.y;

	//Zoom
	s_ModelMatrix.Scale(IW_FIXED_FROM_FLOAT(zoom));
	CIwVec3 vect = getWorldCoords(0, 0);
	CIwVec3 vect2 = getWorldCoords(screenTranslationX, screenTranslationY);

	int32 dx = int32((vect2.x-vect.x) * zoom);
	int32 dy = int32((vect2.y-vect.y) * zoom);

	//s_ModelMatrix.t.x = -dx;
	//s_ModelMatrix.t.y = -dy;

	iwfixed sinTheta = IwGeomSin(IW_ANGLE_FROM_DEGREES(-rotation));
	iwfixed cosTheta = IwGeomCos(IW_ANGLE_FROM_DEGREES(-rotation));

	s_ModelMatrix.t.x = -vectCenter.x-(IW_FIXED_MUL(dx, cosTheta) - IW_FIXED_MUL(dy, sinTheta));
	s_ModelMatrix.t.y = -vectCenter.y-(IW_FIXED_MUL(dx, sinTheta) + IW_FIXED_MUL(dy, cosTheta));
	//Rotate
	CIwMat rotationMat = CIwMat::g_Identity;
	rotationMat.SetRotZ(IW_ANGLE_FROM_DEGREES(rotation), true, true);
	s_ModelMatrix *= rotationMat;

}
Example #10
0
void CRenderer::UpdateDeviceParams()
{
	mDeviceParams.screenWidth  = IwGxGetScreenWidth();
	mDeviceParams.screenHeight = IwGxGetScreenHeight();
	mDeviceParams.screenOrient = IW_GX_ORIENT_90;
	mDeviceParams.bkgColor.Set(0, 0, 0, 255);
	mDeviceParams.isClearBackground = true;
	mDeviceParams.virtualWidth = VIRTUAL_WIDTH;
	mDeviceParams.virtualHeight = VIRTUAL_HEIGHT;
	mDeviceParams.screenFactor = (float)mDeviceParams.screenWidth / (float)mDeviceParams.screenHeight;
	mDeviceParams.offsetX = 0;
	mDeviceParams.offsetY = 0;

	if (mDeviceParams.screenFactor >= 1.5)
	{
		mDeviceParams.scale = (float)mDeviceParams.screenHeight / mDeviceParams.virtualHeight;

		if (mDeviceParams.screenWidth != mDeviceParams.virtualWidth * mDeviceParams.scale)
		{
			mDeviceParams.offsetX = (uint32)(mDeviceParams.screenWidth - mDeviceParams.virtualWidth * mDeviceParams.scale)/2;
		}
	}

	if (mDeviceParams.screenFactor < 1.5)
	{
		mDeviceParams.scale = (float)mDeviceParams.screenWidth / mDeviceParams.virtualWidth;
		if (mDeviceParams.screenHeight != mDeviceParams.virtualHeight * mDeviceParams.scale)
		{
			mDeviceParams.offsetY = (uint32)(mDeviceParams.screenHeight - mDeviceParams.virtualHeight * mDeviceParams.scale)/2;
		}
	}
	 //IwGxSetScissorScreenSpace(mDeviceParams.offsetX, mDeviceParams.screenHeight, mDeviceParams.screenWidth - mDeviceParams.offsetX, mDeviceParams.screenHeight);

	//IwGxSetScissorScreenSpace(100, 100, 100, 100);
}
Example #11
0
void Map::Load(char * mapFileName)
{
	int temp[2]={0,0};
	memcpy(_StartPos,temp,sizeof(temp));
	memcpy(_EndPos,temp,sizeof(temp));
	showDialog=-1;
	screenHeight= IwGxGetScreenHeight();
	screenWidth=IwGxGetScreenWidth();
	_layer_base=new Layer;
	_layer_middle=new Layer;
	_layer_maze=new Layer;
	_tileset_map=new TileSet;
	_tileset_maze=new TileSet;
	_path=new Path;
	ReadJsonFile(mapFileName);
	_characterPreIndex=0;
	_NPC=new NPC;
	_NPC->m_Dialogs.append("Hello there!!!!");
	_NPC->m_Dialogs.append("How are you?");
	_NPC->m_Dialogs.append("This is World of MI. Welcome!");
	_NPC->Init();
	
	for(int i=0;i!=9;i++)
	{
		TileObstacle tileObs=TileObstacle();
		tileObs.InitialObstacle(CIwFVec2(0,0),CIwSVec2(_tileWidth,_tileHeight));
		_TileObstacles.append(tileObs);
	}
	//_EventBlock.append(4322);
}
Example #12
0
//
//
//
//	AdFonic specific implementation
//
//
//
bool CIwGameAds::RequestAdAdFonic()
{
	// Get device surface dimensions
	Width = IwGxGetScreenWidth();
	Height = IwGxGetScreenHeight();

	CIwGameString urlencoded;

	RequestURI = "http://adfonic.net/ad/";
	RequestURI += ApplicationID;
	RequestURI += "?";
	RequestURI += "r.id=";
	urlencoded.URLEncode(CIwGameString(UDID).c_str());
	RequestURI += urlencoded;
	RequestURI += "&s.test=0";
	RequestURI += "&t.format=xml";
	if (!ExtraInfo.IsEmpty())
	{
		RequestURI += ExtraInfo;
	}

	AdRequest.setGET();
	AdRequest.setURI(RequestURI.c_str());
	AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL);
	AdRequest.SetHeader("User-Agent", UserAgent.c_str());
	AdRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded");
	AdRequest.setBody("");
	IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT);

	return true;
}
Example #13
0
void renderMap() {
	IwGxLightingOff();
	
	CIwMaterial* pMat = IW_GX_ALLOC_MATERIAL();
    pMat->SetModulateMode(CIwMaterial::MODULATE_NONE);
    pMat->SetTexture(mapTexture);

	IwGxSetMaterial(pMat);

	IwGxSetScreenSpaceSlot(-1);

	float zoom = getMapZoom()->getZoom();

	int16 hScrW = (double)IwGxGetScreenWidth()*0.5f;
	int16 hScrH = (double)IwGxGetScreenHeight()*0.5f;
	int16 x1 = hScrW - hScrW*zoom;
	int16 x2 = hScrW + hScrW*zoom;
	int16 y1 = hScrH - hScrH*zoom;
	int16 y2 = hScrH + hScrH*zoom;

	mapVertZoom[0].x = x1, mapVertZoom[0].y = y1;
	mapVertZoom[1].x = x1, mapVertZoom[1].y = y2;
	mapVertZoom[2].x = x2, mapVertZoom[2].y = y2;
	mapVertZoom[3].x = x2, mapVertZoom[3].y = y1;

    IwGxSetUVStream(mapDefaultUvs);
    IwGxSetVertStreamScreenSpace(mapVertZoom, 4);

    IwGxDrawPrims(IW_GX_QUAD_LIST, NULL, 4);
}
Example #14
0
void ImGui_Marmalade_NewFrame()
{
    if (!g_FontTexture)
        ImGui_Marmalade_CreateDeviceObjects();

    ImGuiIO& io = ImGui::GetIO();

    // Setup display size (every frame to accommodate for window resizing)
    int w = IwGxGetScreenWidth(), h = IwGxGetScreenHeight();
    io.DisplaySize = ImVec2((float)w, (float)h);
     // For retina display or other situations where window coordinates are different from framebuffer coordinates. User storage only, presently not used by ImGui.
    io.DisplayFramebufferScale = g_scale;

    // Setup time step
    double current_time = s3eTimerGetUST() / 1000.0f;
    io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
    g_Time = current_time;

    double mouse_x, mouse_y;
    mouse_x = s3ePointerGetX();
    mouse_y = s3ePointerGetY();
    io.MousePos = ImVec2((float)mouse_x/g_scale.x, (float)mouse_y/g_scale.y);   // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)

    for (int i = 0; i < 3; i++)
    {
        io.MouseDown[i] = g_MousePressed[i] || s3ePointerGetState((s3ePointerButton)i) != S3E_POINTER_STATE_UP;    // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
        g_MousePressed[i] = false;
    }

    io.MouseWheel = g_MouseWheel;
    g_MouseWheel = 0.0f;

    // TODO: Hide OS mouse cursor if ImGui is drawing it
    // s3ePointerSetInt(S3E_POINTER_HIDE_CURSOR,(io.MouseDrawCursor ? 0 : 1));

    // Start the frame
    ImGui::NewFrame();

     // Show/hide OSD keyboard
    if (io.WantTextInput)
    {
        // Some text input widget is active?
        if (!g_osdKeyboardEnabled)
        {
            g_osdKeyboardEnabled = true;
            s3eKeyboardSetInt(S3E_KEYBOARD_GET_CHAR, 1);    // show OSD keyboard
        }
    }
    else
    {
        // No text input widget is active
        if (g_osdKeyboardEnabled)
        {
            g_osdKeyboardEnabled = false;
            s3eKeyboardSetInt(S3E_KEYBOARD_GET_CHAR, 0);    // hide OSD keyboard
        }
    }
}
PostEffect::PostEffect( const unsigned int id ) :
	m_id( id )
{
	const int height = IwGxGetScreenHeight();
	const int width = IwGxGetScreenWidth();

	m_surface = new CIwGxSurface();
	m_surface->CreateSurface( NULL, width, height, CIwGxSurface::EXACT_MATCH_F );
}
Example #16
0
void MainMenu::Init()
{
    Scene::Init();
	// Create menu background
	int w = IwGxGetScreenWidth();
	int h = IwGxGetScreenHeight();

	if (w > h)
	{
		int temp = w;
		w = h;
		h = temp;
	}

	CSprite* background = new CSprite();
	background->m_X = (float)w / 2;
	background->m_Y = (float)h / 2;
	background->SetImage(g_pResources->getMenuBG());
	background->m_W = background->GetImage()->GetWidth();
	background->m_H = background->GetImage()->GetHeight();
	background->m_AnchorX = 0.5;
	background->m_AnchorY = 0.5;
	// Fit background to screen size
	background->m_ScaleX = (float)w / background->GetImage()->GetWidth();
	background->m_ScaleY = (float)h / background->GetImage()->GetHeight();
	AddChild(background);

	playButton = new CSprite();
	playButton->SetImage(g_pResources->getPlayButton());
	playButton->m_X = w / 2.0f;
	playButton->m_Y = h / 2.0f;
	playButton->m_W = playButton->GetImage()->GetWidth();
	playButton->m_H = playButton->GetImage()->GetHeight();
	playButton->m_AnchorX = 0.5f;
	playButton->m_AnchorY = 0.5f;
	playButton->m_ScaleX = (float)(w * 0.4) / playButton->GetImage()->GetWidth();
	playButton->m_ScaleY = playButton->m_ScaleX;
	AddChild(playButton);


	// Create pause menu sprite (docked to top of screen)
	optionsSprite = new CSprite();
	optionsSprite->SetImage(g_pResources->getSettingsButton());
	optionsSprite->m_X = (int)IwGxGetDeviceWidth() * 0.9;
	optionsSprite->m_Y = (int)IwGxGetDeviceHeight() * 0.9;
	optionsSprite->m_W = optionsSprite->GetImage()->GetWidth();
	optionsSprite->m_H = optionsSprite->GetImage()->GetHeight();
	optionsSprite->m_AnchorX = 0.5;
	optionsSprite->m_ScaleX = (float)(IwGxGetDeviceWidth() * 0.13) / optionsSprite->GetImage()->GetWidth();
	optionsSprite->m_ScaleY = optionsSprite->m_ScaleX;
	AddChild(optionsSprite);


	// Start menu music
	//Audio::PlayMusic("audio/frontend.mp3");
}
Example #17
0
void EventsScene::Init()
{
    Scene::Init();

    // Create menu background
    CSprite* background = new CSprite();
    background->m_X = (float)IwGxGetScreenWidth() / 2;
    background->m_Y = (float)IwGxGetScreenHeight() / 2;
    background->SetImage(g_pResources->getbackground());
    background->m_W = background->GetImage()->GetWidth();
    background->m_H = background->GetImage()->GetHeight();
    background->m_AnchorX = 0.5;
    background->m_AnchorY = 0.5;
    // Fit background to screen size
    background->m_ScaleX = (float)IwGxGetScreenWidth() / background->GetImage()->GetWidth();
    background->m_ScaleY = (float)IwGxGetScreenHeight() / background->GetImage()->GetHeight();
    AddChild(background);
	hasFeed = false;
}
Example #18
0
void Enemy::Update(float pDt, float pAlphaMul)
{
	this->zEnemySprite->Update(pDt, pAlphaMul);

	//Move Enemy
	this->zEnemySprite->m_Y += this->zVelocity * pDt;
	if (this->zEnemySprite->m_Y > IwGxGetScreenHeight())
	{
		this->zEnemySprite->m_Y = 0;
	}
}
Example #19
0
void Desktop::init() {
    IwGxInit();
    IwGxLightingOff();
    width = IwGxGetScreenWidth();
    height = IwGxGetScreenHeight();
	IwGxSetColClear(0, 0, 0, 0);
    vSize = 0;
	duration = 1000 / 60;
	devices = new vector<Device>();
	defPath = NULL;
}
bool Physics::inbounds(Entity & e)
{
    if((e.pos.x < 0) || (e.pos.x + e.size.x > IwGxGetScreenWidth())){
        return false;
    }
    
    if((e.pos.y < 0) || (e.pos.y + e.size.y  > IwGxGetScreenHeight())){
        return false;
    }
    
    return true;
}
Example #21
0
void MyWorld::Update(float fElapsed)
{
    // Adjust perspective based on dimensions of screen to keep board in view
    int max = IwGxGetScreenHeight() > IwGxGetScreenWidth() ? IwGxGetScreenHeight() : IwGxGetScreenWidth();
    setPerspective(480.0f - (1024 - max) / 2);

    // TODO: Add world logic here
    World::Update(fElapsed);

	if ( fTimeSinceLastSpawn > fTimeUntilNextSpawn)
	{
		fTimeSinceLastSpawn -= fTimeUntilNextSpawn;
		SpawnCustomer();
	}
	fTimeSinceLastSpawn += fElapsed;
	fTimeUntilNextSpawn -= fElapsed * 0.01f;

	char buffer[16];
	snprintf(buffer, sizeof(char) * 16, "Score: %d", iScore);
	TurnsLeftLabel->setText(buffer);
}
Example #22
0
bool MapViewUpdate() {

	// Clear the screen
    IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F);

	renderMap();
	renderMapPlayer();
	renderMapXpBar();
	renderMapHealth();

	Player* player = getGameState()->getPlayer();
	IntroState introState = getGameState()->getIntroState();

	if (lastLoses < player->getLoseCount() ||
		lastWins < player->getWinCount()) {
		lastLoses = player->getLoseCount();
		lastWins = player->getWinCount();

		mapGhost2->setCentre(CIwFVec2(IwGxGetScreenWidth()*0.80f, IwGxGetScreenHeight()*0.70f));
		mapGhost2->setNotice(false);

		if (introState == INTRO_DEFEND) {
			mapGhost2->moveGhost(CIwFVec2(IwGxGetScreenWidth()/2, IwGxGetScreenHeight()/2), arrivalCallback);
		}
	}
	if (introState == INTRO_ATTACK) {
		mapGhost->Update();
		mapGhost->Render();
	}

	mapGhost2->Update();
	mapGhost2->Render();

	IwGxFlush();
    IwGxSwapBuffers();

	return true;
}
Example #23
0
CIwFVec2 worldify(int32 x, int32 y, float innerRadius, float rotation){
    int h = IwGxGetScreenHeight();
            
    int32 world_x = x + (innerRadius - 10);
    int32 world_y = h/2 - y;
    
    rotation = -rotation;
    
    // Rotates (world_x, world_y) around world origin (w/2 + radii.x - 20, h/2) by theta
    
    return CIwFVec2(world_x * cos(rotation) - world_y * sin(rotation),
                    world_x * sin(rotation) + world_y * cos(rotation));
    
}
Example #24
0
//
//
//
//	VServ specific implementation
//
//
//
bool CIwGameAds::RequestAdVServ()
{
	// Get device surface dimensions
	Width = IwGxGetScreenWidth();
	Height = IwGxGetScreenHeight();

	// Build M2M request URI string
	RequestURI = "http://a.vserv.mobi/delivery/adapi.php?";
	CIwGameString urlencoded;

	RequestURI += "zoneid=";
	RequestURI += ApplicationID;
	RequestURI += "&im=";
	RequestURI += CIwGameString(UDID);
	RequestURI += "&ic=";
	RequestURI += s3eDeviceGetString(S3E_DEVICE_LOCALE);
	RequestURI += "&app=1";
	RequestURI += "&ts=1";
	RequestURI += "&ua=";
	urlencoded.URLEncode(UserAgent.c_str());
	RequestURI += urlencoded;
	if (Width != 0)
	{
		RequestURI += "&sw=";
		RequestURI += CIwGameString(Width);
	}
	if (Height != 0)
	{
		RequestURI += "&sh=";
		RequestURI += CIwGameString(Height);
	}
	if (!ExtraInfo.IsEmpty())
	{
		RequestURI += ExtraInfo;
	}

	AdRequest.setGET();
	AdRequest.setURI(RequestURI.c_str());
	AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL);
	AdRequest.SetHeader("User-Agent", UserAgent.c_str());
	AdRequest.SetHeader("Accept", "application/xml");
	AdRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded");
	AdRequest.SetHeader("Content-Length", "0");
	AdRequest.setBody("");
	IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT);

	return true;
}
Example #25
0
void mapInit(int mapW, int mapH) {
	double w = IwGxGetScreenWidth();
	double h = IwGxGetScreenHeight();
	{
		double whRatio = ((double)mapW) / mapH;

		if (whRatio > w/h) {
			w = h * whRatio;
		} else if (whRatio < w/h) {
			h = w * 1/whRatio;
		}
	}

	// Full screen screenspace vertex coords
	int16 x1 = (int16)(-abs(w - IwGxGetScreenWidth())/2); // Negative or 0
	int16 x2 = (int16)(IwGxGetScreenWidth()  - x1);
	int16 y1 = (int16)(-abs(h - IwGxGetScreenHeight())/2); // Negative or 0
	int16 y2 = (int16)(IwGxGetScreenHeight() - y1);
	
	mapVert[0].x = x1, mapVert[0].y = y1;
	mapVert[1].x = x1, mapVert[1].y = y2;
	mapVert[2].x = x2, mapVert[2].y = y2;
	mapVert[3].x = x2, mapVert[3].y = y1;
}
void PauseMenu::Init()
{
	Game* game = (Game*)g_pSceneManager->Find("game");
	add = false;
	int width = IwGxGetScreenWidth();
	int height = IwGxGetScreenHeight();
	// Create menu background
	CSprite* background = new CSprite();
	background->m_X = (float) width / 2;
	background->m_Y = (float) height / 2;
	background->SetImage(g_pResources->getGameBGB());
	background->m_AnchorX = 0.5;
	background->m_AnchorY = 0.5;
	// Fit background to screen size
	background->m_ScaleX = (float)width / background->GetImage()->GetWidth();
	background->m_ScaleY = (float)height / background->GetImage()->GetHeight();
	AddChild(background);

	shown = false;

	// Create New  Game button
	infoButton = new CSprite();
	infoButton->SetImage(g_pResources->getInfoButton());
	infoButton->m_X = (float)(width * 0.15) + (width / (1.5 * 2));
	infoButton->m_Y = (float)height / 50;
	infoButton->m_W = infoButton->GetImage()->GetWidth();
	infoButton->m_H = infoButton->GetImage()->GetHeight();
	infoButton->m_AnchorX = 0.5f;
	infoButton->m_AnchorY = 0;
	infoButton->m_ScaleX = (float)width / infoButton->GetImage()->GetWidth() / 1.5;
	infoButton->m_ScaleY = infoButton->m_ScaleX;
	AddChild(infoButton);



	// Create New  Game button
	infoText = new CSprite();
	infoText->SetImage(g_pResources->getInfoText());
	infoText->m_X = (float)(width * 0.15) + ((width / (1.4 * 2)));
	infoText->m_W = infoText->GetImage()->GetWidth();
	infoText->m_H = infoText->GetImage()->GetHeight();
	infoText->m_AnchorX = 0.5f;
	infoText->m_AnchorY = 0.5f;
	infoText->m_ScaleX = (float)(width / infoText->GetImage()->GetWidth()) / 1.4;
	infoText->m_ScaleY = infoText->m_ScaleX;
	infoText->m_Y = (float)(infoText->GetImage()->GetHeight() * infoText->m_ScaleX)/ 2 + (height / 6);
	AddChild(infoText);
}
Example #27
0
// Initialise the Info Panel UI (Info panel shows information such as end of round score and round number)
void Game::initInfoPanelUI()
{
    // Create info panel
    infoPanel = new CSprite();
    infoPanel->SetImage(g_pResources->getInfoPanel());
    float panel_w = infoPanel->GetImage()->GetWidth();
    float panel_h = infoPanel->GetImage()->GetHeight();
    infoPanel->m_X = (float)IwGxGetScreenWidth();
    infoPanel->m_Y = (float)IwGxGetScreenHeight() / 2 - (panel_h / 2) * graphicsScale;
    infoPanel->m_W = panel_w;
    infoPanel->m_H = panel_h;
    infoPanel->m_ScaleX = graphicsScale;
    infoPanel->m_ScaleY = graphicsScale;
    AddChild(infoPanel);

    // Create info panel header
    infoPanelTitleLabel = new CLabel();
    infoPanelTitleLabel->m_X = panel_w / 2;
    infoPanelTitleLabel->m_Y = panel_h / 2 - 100,
    infoPanelTitleLabel->m_W = panel_w;
    infoPanelTitleLabel->m_H = panel_h;
    infoPanelTitleLabel->m_Text = "Round Complete",
    infoPanelTitleLabel->m_AlignHor = IW_2D_FONT_ALIGN_CENTRE;
    infoPanelTitleLabel->m_AlignVer = IW_2D_FONT_ALIGN_CENTRE;
    infoPanelTitleLabel->m_Font = g_pResources->getFont();
    infoPanelTitleLabel->m_AnchorX = 0.5f;
    infoPanelTitleLabel->m_AnchorY = 0.5f;
    infoPanelTitleLabel->m_ScaleX = fontScale / graphicsScale;
    infoPanelTitleLabel->m_ScaleY = fontScale / graphicsScale;
    infoPanel->AddChild(infoPanelTitleLabel);

    // Create info panel message
    infoPanelMessageLabel = new CLabel();
    infoPanelMessageLabel->m_X = panel_w / 2;
    infoPanelMessageLabel->m_Y = panel_h / 2 + 100,
    infoPanelMessageLabel->m_W = panel_w;
    infoPanelMessageLabel->m_H = panel_h;
    infoPanelMessageLabel->m_Text = "Score: 1000",
    infoPanelMessageLabel->m_AlignHor = IW_2D_FONT_ALIGN_CENTRE;
    infoPanelMessageLabel->m_AlignVer = IW_2D_FONT_ALIGN_CENTRE;
    infoPanelMessageLabel->m_Font = g_pResources->getFont();
    infoPanelMessageLabel->m_AnchorX = 0.5f;
    infoPanelMessageLabel->m_AnchorY = 0.5f;
    infoPanelMessageLabel->m_ScaleX = fontScale / graphicsScale;
    infoPanelMessageLabel->m_ScaleY = fontScale / graphicsScale;
    infoPanel->AddChild(infoPanelMessageLabel);
}
Example #28
0
bool CIwGameAds::Init()
{
	Mediator = NULL;
	AdAvailableCallback = NULL;
	Error = ErrorNone;
	ErrorString = "";
	ErrorString.setAutoHash(true);
	ClientID = "-1";
	HtmlAds = false;
	TextAds = false;
	UserAge = 0;
	UserGender = GenderInvalid;
	AdAvailable = false;
	UserAgent = IW_GAME_HTTP_MANAGER->getUserAgent();
    SlotSize = sDefault;

	Version = "Sm2m-1.5.3";

	// Get device UDID
	UDID = s3eDeviceGetInt(S3E_DEVICE_UNIQUE_ID);

	// Get device surface dimensions
	Width = IwGxGetScreenWidth();
	Height = IwGxGetScreenHeight();

	// Find our which portal ID we should be using
	PortalType = FindPortalType(TextAds);

	// Allocate string large enough to hold our largest request
	RequestURI.allocString(2048);

	// Get previous session client ID
/*	CIwGameFile file;
	if (file.Open("\\iwgameads.dat", "rb"))
	{
		int len = file.getFileSize();
		ClientID.allocString(len);
		ClientID.setLength(len);
		file.Read((void*)ClientID.c_str(), len);
	}*/

//	ClientID = CIwGameString(UDID);

	return true;			// Pointer support
}
Example #29
0
void Init()
{
	IwGxInit();
    IwGxLightingOff();

    gEffects = new MarmaladeEffectsLibrary();
    gEffects->Load("particles/data.xml");

    gPM = new MarmaladeParticleManager();
    gPM->SetScreenSize(IwGxGetScreenWidth(), IwGxGetScreenHeight());
    gPM->SetOrigin(0, 0);

    TLFX::Effect *eff = gEffects->GetEffect("Area Effects/Swirly Balls");
    TLFX::Effect *copy = new TLFX::Effect(*eff, gPM);

    copy->SetPosition(0.0f, 0.0f);
    gPM->AddEffect(copy);
}
Example #30
0
void CEndGameState::Render()
{
    IW_CALLSTACK("CEndGameState::Render");

    IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F);

    GetWorld().Render();

    IwGxLightingOff();
    IwGxSetScreenSpaceOrg( &CIwSVec2::g_Zero );

    CIwColour* cols = IW_GX_ALLOC(CIwColour, 4);
    memset(cols, 255, sizeof(CIwColour) * 4 );

    if (GetWorld().GetUICar()->GetPosition() == 1 )
    {
        CIwMaterial* mat = (CIwMaterial *)IwGetResManager()->GetGroupNamed("ui")->GetResNamed("youwin", IW_GX_RESTYPE_MATERIAL);
        IwGxSetMaterial(mat);
    }
    else
    {
        CIwMaterial* mat = (CIwMaterial *)IwGetResManager()->GetGroupNamed("ui")->GetResNamed("youlose", IW_GX_RESTYPE_MATERIAL);
        IwGxSetMaterial(mat);
    }


    const uint32 imageWidth  = 128;
    const uint32 imageHeight = 32;

    CIwSVec2 XY( (int16)((IwGxGetScreenWidth()/2) - (imageWidth/2)), (int16)(IwGxGetScreenHeight()/4) ),
            dXY( (int16)imageWidth, (int16)imageHeight );

    IwGxDrawRectScreenSpace(&XY, &dXY, cols);
    IwGxLightingOn();

    IwGxFlush();
    IwGxSwapBuffers();

#ifdef IW_DEBUG
    // Reset metrics for next frame
    IwGxMetricsReset();
#endif
}