Example #1
0
void SimpleMenu::smDrawSimpleMenuScrollbar(const CIwSVec2 & pos,const CIwSVec2 & size,const CIwSVec2 & spos,const CIwSVec2 & ssize)
{
	CIwMaterial* m = IW_GX_ALLOC_MATERIAL();
	CIwColour c;
	c.Set(0xFFFFFFFF);
	m->SetColAmbient(c);
	m->SetAlphaMode(CIwMaterial::ALPHA_BLEND);
	IwGxSetMaterial(m);
	CIwSVec2* points = IW_GX_ALLOC(CIwSVec2,8);
	CIwColour* cols = IW_GX_ALLOC(CIwColour,8);
	points[0] = pos+CIwSVec2(0,0);
	points[1] = pos+CIwSVec2(0,size.y);
	points[2] = pos+CIwSVec2(size.x,size.y);
	points[3] = pos+CIwSVec2(size.x,0);
	c.Set(0x20,0x20,0x20,0x20);
	cols[0] = cols[1] = cols[2] = cols[3] = c;
	points[4] = spos+CIwSVec2(0,0);
	points[5] = spos+CIwSVec2(0,ssize.y);
	points[6] = spos+CIwSVec2(ssize.x,ssize.y);
	points[7] = spos+CIwSVec2(ssize.x,0);
	c.Set(0xFF,0xFF,0xFF,0x80);
	cols[4] = cols[5] = cols[6] = cols[7] = c;
	IwGxSetVertStreamScreenSpace(points,8);
	IwGxSetColStream(cols);
	IwGxDrawPrims(IW_GX_QUAD_LIST,0,8);
}
Example #2
0
void SimpleMenu::smRenderLoading()
{
	IwGxClear(IW_GX_DEPTH_BUFFER_F);

	iwangle step = IW_GEOM_ONE/32;
	g_toeLoadingAngle = (g_toeLoadingAngle+step) %IW_GEOM_ONE;
	int32 h = (int32)IwGxGetScreenHeight();
	int32 w = (int32)IwGxGetScreenWidth();
	int32 x = w/2;
	int32 y = h/2;
	int r = (x<y)?(x/2):(y/2);
	int r2 = r*8/10;

	//iwfixed c = IwGeomCos(g_toeLoadingAngle);
	//iwfixed s = IwGeomCos(g_toeLoadingAngle);
	int32 vertices = 10*4;
	CIwSVec2* v = IW_GX_ALLOC(CIwSVec2,vertices);
	CIwColour* col = IW_GX_ALLOC(CIwColour,vertices);
	int index = 0;
	CIwColour c; c.Set(0xFFFFFFFF);
	col[index] = c;
	v[index++] = CIwSVec2(0,0);
	col[index] = c;
	v[index++] = CIwSVec2(0,h);
	col[index] = c;
	v[index++] = CIwSVec2(w,h);
	col[index] = c;
	v[index++] = CIwSVec2(w,0);
	iwangle a = g_toeLoadingAngle;
	int colS = 250/(vertices/4);
	for (int i=1; i<(vertices/4);++i)
	{
		iwfixed c1 = IwGeomCos(a);
		iwfixed s1 = IwGeomSin(a);
		a += step;
		iwfixed c2 = IwGeomCos(a);
		iwfixed s2 = IwGeomSin(a);
		c.r = c.g = c.b = 255-i*colS;
		col[index] = c;		v[index++] = CIwSVec2(x+c1*r/IW_GEOM_ONE,y+s1*r/IW_GEOM_ONE);
		col[index] = c;		v[index++] = CIwSVec2(x+c1*r2/IW_GEOM_ONE,y+s1*r2/IW_GEOM_ONE);
		c.r = c.g = c.b = 255-(i+1)*colS;
		col[index] = c;		v[index++] = CIwSVec2(x+c2*r2/IW_GEOM_ONE,y+s2*r2/IW_GEOM_ONE);
		col[index] = c;		v[index++] = CIwSVec2(x+c2*r/IW_GEOM_ONE,y+s2*r/IW_GEOM_ONE);

	}
	CIwMaterial* m = IW_GX_ALLOC_MATERIAL();
	m->SetColAmbient(255,255,255,255);
	IwGxClear(IW_GX_DEPTH_BUFFER_F);
	IwGxSetMaterial(m);
	IwGxLightingOff();
	IwGxSetVertStreamScreenSpace(v,vertices);
	IwGxSetUVStream(0);
	IwGxSetColStream(col);
	IwGxDrawPrims(IW_GX_QUAD_LIST, 0, index);
	IwGxFlush();
	IwGxSwapBuffers();
	IwGxClear(IW_GX_DEPTH_BUFFER_F);
}
/**
* Draws the enemy image
*/
void MeleeEnemy::draw() {

	if (mDrawDirection == 1) {
		Iw2DSetImageTransform(IW_2D_IMAGE_TRANSFORM_FLIP_X);
	}

	CIwSVec2 screenCentre = CIwSVec2((int16)Iw2DGetSurfaceWidth() >> 1, (int16)Iw2DGetSurfaceHeight() >> 1);

	b2Transform t = mBody->GetTransform();
	CIwSVec2 pos = screenCentre + (CIwSVec2(int16(t.p.x*8), -int16(t.p.y*8)));

	float normalRegionHeight = (52.0f/100.0f) * ((mHealth/mMaxHealth)*100.0f);
	float hurtRegionHeight = 52.0f - normalRegionHeight;

	CIwColour col;
	col.Set(255, 50, 50);
	Iw2DSetColour(col);
	Iw2DDrawImageRegion(mImg, pos - CIwSVec2((mFrameWidth/1.5)*mSpriteScale, ((52/2)*mSpriteScale)), CIwSVec2(mFrameWidth*1.5, hurtRegionHeight*mSpriteScale), CIwSVec2(mFrame, mVerFrame), CIwSVec2(mFrameWidth, hurtRegionHeight));

	col.Set(255, 255, 255);
	Iw2DSetColour(col);
	Iw2DDrawImageRegion(mImg, pos - CIwSVec2((mFrameWidth/1.5)*mSpriteScale, (((52/2)*mSpriteScale))-hurtRegionHeight), CIwSVec2(mFrameWidth*1.5, normalRegionHeight*mSpriteScale), CIwSVec2(mFrame, hurtRegionHeight+mVerFrame), CIwSVec2(mFrameWidth, normalRegionHeight));

	if(mFrameDelay <= 0) {
		mFrame += (mFrameWidth);

		if (mFrame > (mFrameCount*mFrameWidth)) {

			//setIdle();
			mFrame = 0;
			if(punching) {
				setIdle();
				mPunchTimer = 10.0f;
			}
		}
		mFrameDelay = 5;
	}

	mFrameDelay--;

	Iw2DSetImageTransform(IW_2D_IMAGE_TRANSFORM_NONE);
}
void FindTheSpotGameEngine::Render(CIwRect& bounds)
{
	CIwSVec2 imgBounds(bounds.x, bounds.y);
	Utils::AlphaRenderImage(g_pLogoTexture, imgBounds, 0xff);

	float tileSize = 160.0f;

	if (g_finalScore == 0)
	{
		CIwRect tileBounds(bounds.x + (bounds.w - tileSize) / 2, bounds.y + (bounds.h - tileSize) / 2, tileSize, tileSize);
		Utils::AlphaRenderImage(g_pTile, tileBounds, 255);

		CIwColour white;
		white.Set(0xff, 0xff, 0xff, 0x7f);

		float scale = tileSize / 256.0f;

		Iw2DSetColour(white);
		Iw2DDrawRect(CIwSVec2(tileBounds.x-1, tileBounds.y-1), CIwSVec2(tileBounds.w+2, tileBounds.h+2));
		CIwSVec2 spotLoc(tileBounds.x + (g_tileLoc.x * scale) - (g_pCursorTexture->GetWidth() / 2), tileBounds.y + (g_tileLoc.y * scale) - (g_pCursorTexture->GetHeight() / 2));
		Utils::AlphaRenderImage(g_pCursorTexture, spotLoc, 255);
		
		if (g_renderTemp == 1)
		{
			CIwSVec2 imgBounds(bounds.x, bounds.y + bounds.h - g_pColderTexture->GetHeight());
			Utils::AlphaRenderImage(g_pColderTexture, imgBounds, 255);
		}
		else if (g_renderTemp == 2)
		{
			CIwSVec2 imgBounds(bounds.x, bounds.y + bounds.h - g_pHotterTexture->GetHeight());
			Utils::AlphaRenderImage(g_pHotterTexture, imgBounds, 255);
		}
	}
	else
	{
		tileSize = g_pFoundTexture->GetWidth();
		CIwRect tileBounds(bounds.x + (bounds.w - tileSize) / 2, bounds.y + (bounds.h - tileSize) / 2, tileSize, tileSize);

		Utils::AlphaRenderImage(g_pFoundTexture, tileBounds, 255);
	}
}
Example #5
0
void DoSimpleTest(GameManager *mgr, uint32 marker_handle, uint32 width, uint32 height)
{
    StateManager *state = mgr->GetStateManager();

    StateVariable tmpVar;

    tmpVar.intValue = 21;
    INT_VAR_HANDLE = state->RegisterStateVariable("IntVar", tmpVar);

    tmpVar.floatValue = 3.1415f;
    FLOAT_VAR_HANDLE = state->RegisterStateVariable("FloatVar", tmpVar);

    tmpVar.stringValue = "Hello World!";
    STRING_VAR_HANDLE = state->RegisterStateVariable("StringVar", tmpVar);

    PathFollowingSprite *intPath = new PathFollowingSprite(mgr);
    intPath->AddSegment(new PathSegmentBezier(CIwVec2(100,100), CIwVec2(200, 900), CIwVec2(700, -50), CIwVec2(800,600)));
    intPath->SetTotalPathTimeMillis(5000);
    mgr->RegisterGameObject(intPath);

    CIwColour transparent;

    transparent.Set(0, 0, 0, 0);

    char buffer[1024];
    sprintf(buffer, "Int: %d", state->GetStateVar(INT_VAR_HANDLE).intValue);
    intSprite = new TextSprite(mgr, buffer);
    intSprite->SetBackgroundColor(g_IwGxColours[IW_GX_COLOUR_WHITE]);
    intSprite->SetBorderColor(g_IwGxColours[IW_GX_COLOUR_BLUE]);
    intSprite->SetBorderThickness(CIwVec2(3, 3));
    intSprite->SetPadding(CIwVec2(3, 3));
    intSprite->SetBaseLocation(CIwVec2(300, 100));
    //intSprite->AddTransformation(new AnchorToTransformation(intPath, CIwVec2(0,0)));
    //intSprite->AddTransformation(new OrbitTransformation(0, 5000));
    mgr->RegisterGameObject(intSprite);

    sprintf(buffer, "Float: %f", state->GetStateVar(FLOAT_VAR_HANDLE).floatValue);
    floatSprite = new TextSprite(mgr, buffer);
    floatSprite->SetBackgroundColor(g_IwGxColours[IW_GX_COLOUR_WHITE]);
    floatSprite->SetBorderColor(g_IwGxColours[IW_GX_COLOUR_GREEN]);
    floatSprite->SetBorderThickness(CIwVec2(3, 3));
    floatSprite->SetPadding(CIwVec2(3, 3));
    floatSprite->SetBaseLocation(CIwVec2(300, 200));
    mgr->RegisterGameObject(floatSprite);

    sprintf(buffer, "String: %s", state->GetStateVar(STRING_VAR_HANDLE).stringValue);
    stringSprite = new TextSprite(mgr, buffer);
    stringSprite->SetBackgroundColor(g_IwGxColours[IW_GX_COLOUR_WHITE]);
    stringSprite->SetBorderColor(g_IwGxColours[IW_GX_COLOUR_CYAN]);
    stringSprite->SetBorderThickness(CIwVec2(5, 5));
    stringSprite->SetPadding(CIwVec2(2, 2));
    stringSprite->SetBaseLocation(CIwVec2(300, 300));
    mgr->RegisterGameObject(stringSprite);

    sprintf(buffer, "Next string");
    stringSprite = new TextSprite(mgr, buffer);
    stringSprite->SetBackgroundColor(g_IwGxColours[IW_GX_COLOUR_WHITE]);
    stringSprite->SetBorderColor(g_IwGxColours[IW_GX_COLOUR_BLACK]);
    stringSprite->SetMargin(CIwVec2(4, 4));
    stringSprite->SetBorderThickness(CIwVec2(4, 4));
    stringSprite->SetPadding(CIwVec2(4, 4));
    stringSprite->SetBaseLocation(CIwVec2(400, 400));
    mgr->RegisterGameObject(stringSprite);

    state->SubscribeStateVarChange(INT_VAR_HANDLE, stateVarChanged, intSprite);
    state->SubscribeStateVarChange(FLOAT_VAR_HANDLE, stateVarChanged, floatSprite);

    state->SubscribeEvent("FloatChange", changeVarValue, NULL);

    state->PostFutureEvent("FloatChange", NULL, mgr->GetCurrentClockTime() + 3000);
}
Example #6
0
void renderGhost() {

	if (!getGameState()->getPlayer()->isReady()) {
		return;
	}

	IwGxLightingOff();

	Ghost *ghost = getGameState()->getGhost();

	CIwFVec3 ghostPosition(0, 0, ghost->getDistance());
	double ghostRotation = rad(ghost->getRotation());

    // Place the markers on the edge of the compass radius
    // rotated to their correct bearing to current location
	ghostMatrix->SetRotY(rad(ghost->getBearing()));
	ghostMatrix->SetTrans(ghostMatrix->RotateVec(ghostPosition));
	ghostMatrix->PostRotateY(ghostRotation);

    IwGxSetModelMatrix(ghostMatrix);

	if (ghost->pollAnimCaptured()) {
		ghost_Player->PlayAnim(ghost_Anims[GHOST_ANIM_CAPTURED], 1, 0, BLEND_DURATION);
	} else if (ghost->pollAnimAgro()) {
		ghost_Player->PlayAnim(ghost_Anims[GHOST_ANIM_AGRO], 1, 0, BLEND_DURATION);
	} else if (ghost->pollAnimDodge()) {
		ghost_Player->PlayAnim(ghost_Anims[GHOST_ANIM_DODGE], 1, 0, BLEND_DURATION);
	} else if (ghost->pollAnimAttack()) {
		ghost_Player->PlayAnim(ghost_Anims[GHOST_ANIM_ATTACK], 1, 0, BLEND_DURATION);
	}
	
	IwGxLightingAmbient(true);
	IwGxSetLightType(0, IW_GX_LIGHT_AMBIENT);
	
	int sinceHit = clock() - ghost->getHitTime();
	CIwColour colAmbient;

	if (sinceHit < GHOST_HIT_LENGTH) {
		int halfAnimation = GHOST_HIT_LENGTH/2;

		float animState = (float) sinceHit / halfAnimation;
		if (animState > 1) {
			animState = 2 - animState;
		}

		colAmbient.Set(0xff, 0xff*(1-animState), 0xff*(1-animState), 0xff);
	} else {
		// The default state that displays the image as it is
		colAmbient.Set(0xff, 0xff, 0xff, 0xff);
	}
	
	IwGxSetLightCol(0, &colAmbient);

	IwGxSetScreenSpaceSlot(1);
    IwAnimSetSkelContext(ghost_Player->GetSkel());
    IwAnimSetSkinContext(ghost_Skin);
    ghost_Model->Render();

	//outline the face under the cursor
	if (clickX > 0 && clickY > 0) {
		int32 faceID = ghostCollision->GetFaceUnderCursor(clickX, clickY);
		if (faceID != -1)
		{
			getGameState()->getGhost()->tapped();
			clickX = clickY = -1;
		} else {
			clickX = clickY = -1;
		}
	}

    // Tidier to reset these
    IwAnimSetSkelContext(NULL);
    IwAnimSetSkinContext(NULL);

	if (ghost->isFound() && !ghost->isDead()) {
		ghostCollision->RenderEctoplasmaBar((float)ghost->getEctoplasm() / GHOST_MAX_ECTOPLASM, ghostRotation);
	}
}
Example #7
0
void Player::setColor(CIwColour& col){
    color.Set(col.Get());
    colors[0] = colors[1] = colors[2] = colors[3] = color;
}
Example #8
0
void IGSprite::setColor(uint8 r, uint8 g, uint8 b, uint8 a) {
	CIwColour c = CIwColour();
	c.Set(r, g, b, a);
	color = c.Get();
}