Esempio n. 1
0
void CScores::Render()
{
	if (m_loaded)
	{
		Iw2DSetColour(0xffffffff);
		int32 dw = Iw2DGetSurfaceWidth();
		int32 dh = Iw2DGetSurfaceHeight();

		Iw2DFillRect(CIwSVec2(0, 0), CIwSVec2((int16)dw, (int16)dh));
		for (uint32 i = 0; i < m_guicontrols.size(); i++)
			m_guicontrols[i]->Render();
		if (m_closing)
		{
			int32 clr = 255 * (MAX_CLOSETIME - m_closetime) / MAX_CLOSETIME;
			clr = clr << 24;
			//clr += 0xffffff;
			Iw2DSetColour(clr);
			Iw2DFillRect(CIwSVec2(0, 0), CIwSVec2((int16)dw, (int16)dh));
		}
		if (m_showing)
		{
			int32 clr = 255 * (m_showtime) / MAX_SHOWTIME;
			clr = clr << 24;
		//	clr += 0xffffff;
			Iw2DSetColour(clr);
			Iw2DFillRect(CIwSVec2(0, 0), CIwSVec2((int16)dw, (int16)dh));
		}
	}
}
Esempio n. 2
0
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 DrawGround()
{
	for (int i = 0; i < NUM_BUILDINGS; i++) {
		Iw2DSetColour(0xff000000);
		Iw2DFillRect(CIwFVec2(GAME_WIDTH - buildings_pos[i].x, GAME_HEIGHT - buildings_pos[i].y),
					 CIwFVec2(buildings_dim[i].x, buildings_dim[i].y));
		Iw2DSetColour(0xffffffff);
		Iw2DDrawRect(CIwFVec2(GAME_WIDTH - buildings_pos[i].x, GAME_HEIGHT - buildings_pos[i].y),
					 CIwFVec2(buildings_dim[i].x, buildings_dim[i].y));
	}
}
Esempio n. 4
0
void Character::Render(CIwFVec2 mapPos)
{
	//character
	Iw2DDrawImage(_image, CIwSVec2(iwsfixed(m_ScreenCenter.x-_Size.x/2.0f), iwsfixed(m_ScreenCenter.y-_Size.y/2.0f-_Size.y/4.0f)));
	//target
	Iw2DSetColour(C_GREEN);
	Iw2DFillRect(CIwSVec2(iwsfixed(m_TargetOnScreen.x),iwsfixed(m_TargetOnScreen.y)) - CIwSVec2(2,2), CIwSVec2(4,4));
	//character collision box
	//Iw2DSetColour(C_BLACK);
	//Iw2DDrawRect(CIwSVec2(iwsfixed(m_Position.x-mapPos.x), iwsfixed(m_Position.y-mapPos.y)) - m_CollisionBox/IW_FIXED(2), m_CollisionBox);
	Iw2DSetColour(C_WHITE);
}
Esempio n. 5
0
void TextSprite::RenderImage(uint32 gameTime)
{
    if(textColorSource != null) textColor = textColorSource->GetColor(gameTime);
    if(borderColorSource != null) borderColor = borderColorSource->GetColor(gameTime);
    if(backgroundColorSource != null) backgroundColor = backgroundColorSource->GetColor(gameTime);
    if(marginXSource != null) margin = SCREEN_TO_SUBPIXEL(CIwVec2(marginXSource->GetInt(gameTime), marginYSource->GetInt(gameTime)));
    if(paddingXSource != null) padding = SCREEN_TO_SUBPIXEL(CIwVec2(paddingXSource->GetInt(gameTime), paddingYSource->GetInt(gameTime)));
    if(borderXSource != null) borderThickness = SCREEN_TO_SUBPIXEL(CIwVec2(borderXSource->GetInt(gameTime), borderYSource->GetInt(gameTime)));

    if(marginXSource != null || paddingXSource != null || borderXSource != null)
    {
        UpdatePositionData();
    }

    CIw2DFont *prevFont = null;
    CIwColour prevColor = Iw2DGetColour();

    if(textFont != null)
    {
        prevFont = Iw2DGetFont();
        Iw2DSetFont(textFont);
    }

    if(backgroundColor.a > 0)
    {
        Iw2DSetColour(backgroundColor);
        Iw2DFillRect(CIwSVec2(backgroundPosition), CIwSVec2(backgroundSize));
    }

    if(borderColor.a > 0)
    {
        Iw2DSetColour(borderColor);
        Iw2DFillRect(CIwSVec2(borderPosition), CIwSVec2(borderSize));

        Iw2DSetColour(backgroundColor);
        Iw2DFillRect(CIwSVec2(innerBorderPosition), CIwSVec2(innerBorderSize));
    }

    Iw2DSetColour(textColor);
    
    const char *textPtr = text.c_str();

    Iw2DDrawString(textPtr, CIwSVec2(textPosition), CIwSVec2(textSize), horizontalAlignment, IW_2D_FONT_ALIGN_TOP);

    Iw2DSetColour(prevColor);

    if(prevFont != null)
    {
        Iw2DSetFont(prevFont);
    }
}
Esempio n. 6
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 Scythe::draw()
{
   IW_CALLSTACK("Scythe::draw");

   if(this->bDrawn) return;

   // TODO: Add some colors to ropes, if we want to keep the ropes like this at all
   this->DarkGreen.Set(0 , this->green, 127, 255 );
   this->LightGreen.Set( 0, 255 - this->green, 127, 255);
   for(int i = -ROPETHICKNESS; i < ROPETHICKNESS; ++i)
   {
      if(i == -ROPETHICKNESS || i == ROPETHICKNESS || i == ROPETHICKNESS / 2)
      {
         Iw2DSetColour(this->LightGreen);
      }
      else Iw2DSetColour(this->DarkGreen);

      Iw2DDrawLine(this->getRotatedCoords(CIwSVec2(this->i2Position.x + this->i2Size.x/2, this->i2Position.y - i)), CIwSVec2(this->rotAxis.x, this->rotAxis.y - i/2));
   }
   Iw2DSetColour(0xFFFFFFFF);


   if ( this->iTimePassed > 32)
   {
      if ( this->up )
      {
         ++this->green;
      }
      else
      {
         --this->green;

      }

      if ( this->green >= 255 || this->green <= 0)
      {
         this->up = !this->up;
      }

      this->iTimePassed = 0;
   }

   Iw2DSetTransformMatrix(mRot); //pushmatrix
   Unit::draw();
   Iw2DSetTransformMatrix(CIwMat2D::g_Identity); //popmatrix
}
Esempio n. 8
0
// Main entry point for the application
int main()
{
	// Initialise Iw2D
	Iw2DInit();

	// Get surface width and height
	int surface_width = Iw2DGetSurfaceWidth();
	int surface_height = Iw2DGetSurfaceHeight();

	// Rotation angle of rectangle
	float angle = 0;
	
	// Wait for a quit request from the host OS
	while (!s3eDeviceCheckQuitRequest())
	{
		// Clear background to blue
		Iw2DSurfaceClear(0xff8080);

		// Set up a transform
		CIwFMat2D mat;
		mat.SetRot(angle);
		mat.ScaleRot(2.0f);
		mat.SetTrans(CIwFVec2((float)surface_width / 2, (float)surface_height / 2));
		Iw2DSetTransformMatrix(mat);
		angle += 0.01f;

		// Render filled rectangle
		Iw2DSetColour(0xff00ffff);
		Iw2DFillRect(CIwFVec2(-50.0f, -100.0f), CIwFVec2(100.0f, 200.0f));

		// Render filled arc
		Iw2DSetColour(0xffff00ff);
		Iw2DFillArc(CIwFVec2(0, 0), CIwFVec2(100.0f, 100.0f), 0, 1.8 * PI);
		
		// Flip the surface buffer to screen
		Iw2DSurfaceShow();

		// Sleep to allow the OS to process events etc.
		s3eDeviceYield(0);
	}
	
	// Shut down Iw2D
	Iw2DTerminate();
	
	return 0;
}
void DrawGameOverScreen()
{
	int border = 10;
	CIwFVec2 dialogDim(480.f, 120.f);

	CIwFVec2 outerTopLeft((screen.x - dialogDim.x)/2, (screen.y - dialogDim.y)/2);
	CIwFVec2 innerTopLeft((screen.x - dialogDim.x)/2 + border, (screen.y - dialogDim.y)/2 + border);

	Iw2DSetColour(0xffffffff);
	Iw2DFillRect(outerTopLeft, dialogDim);
	Iw2DSetColour(0xff000000);
	Iw2DFillRect(innerTopLeft, CIwFVec2(dialogDim.x - 2 * border, dialogDim.y - 2 * border));

	Iw2DSetColour(0xffffffff);
	Iw2DSetFont(fontLarge);

	Iw2DDrawString("G A M E   O V E R", outerTopLeft, dialogDim, IW_2D_FONT_ALIGN_CENTRE, IW_2D_FONT_ALIGN_CENTRE);
}
Esempio n. 10
0
/**
* 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);
}
Esempio n. 11
0
void IGSprite::display() {
	if(image != NULL) {
		// set the opacity
		Iw2DSetColour(color);
		
		// display the image
		Iw2DDrawImage(image,
			CIwSVec2((int16)((position.x-size.width/2)+IGDistorter::getInstance()->offsetX), 
				(int16)((position.y-size.height/2)+IGDistorter::getInstance()->offsetY)),
			CIwSVec2((int16)size.width, (int16)size.height));
	}
}
void DrawTitleScreen(TitleScreen *title)
{
	int border = 10;

	Iw2DSetColour(0xffffffff);
	Iw2DFillRect(title->btnTopLeft, title->btnDim);

	Iw2DSetColour(0xff000000);
	Iw2DFillRect(CIwFVec2(title->btnTopLeft.x + border, title->btnTopLeft.y + border),
				 CIwFVec2(title->btnDim.x - 2 * border, title->btnDim.y - 2 * border));
	
	Iw2DSetFont(fontLarge);
	int fh = fontLarge->GetHeight();
	int sw = Iw2DGetStringWidth("P L A Y");

	Iw2DSetColour(0xffffffff);
	Iw2DDrawString("P L A Y", CIwFVec2(title->btnTopLeft.x + border, title->btnTopLeft.y + border),
		CIwFVec2(title->btnDim.x - 2 * border, title->btnDim.y - 2 * border), IW_2D_FONT_ALIGN_CENTRE, IW_2D_FONT_ALIGN_TOP);
	Iw2DDrawString("Patriot Missile Defense", CIwFVec2(0.f, 0.f), CIwFVec2(screen.x, screen.y / 2),
		IW_2D_FONT_ALIGN_CENTRE, IW_2D_FONT_ALIGN_CENTRE);
}
Esempio n. 13
0
void Scene::drawBackgroundBox(int x, int y, int width, int height){
    //Most awful method in whole game :D
    //Draws many rectangles, each of them is smaller than previous, that is how frame is faked.
    
    int cyanWidth = 5;
    int orangeWidth = 8;
    int borderWidth = 2;
    int offsetCord = cyanWidth + borderWidth*2 + orangeWidth;
    int offsetSize = cyanWidth*2 + borderWidth*4 + orangeWidth*2;


    Iw2DSetColour(g_ColorManager.getBorderColor()); //border
    Iw2DFillRect(CIwSVec2(x - offsetCord, y - offsetCord), CIwSVec2(width + offsetSize, height + offsetSize));
    
    offsetCord-=borderWidth;
    offsetSize-=borderWidth*2;
    
    Iw2DSetColour(g_ColorManager.getOrangeColor()); //orange
    Iw2DFillRect(CIwSVec2(x - offsetCord, y - offsetCord), CIwSVec2(width + offsetSize, height + offsetSize));
    
    offsetCord-=orangeWidth;
    offsetSize-=orangeWidth*2;
    
    
    Iw2DSetColour(g_ColorManager.getBorderColor()); //border
    Iw2DFillRect(CIwSVec2(x - cyanWidth - borderWidth, y - cyanWidth - borderWidth), CIwSVec2(width + cyanWidth*2 + borderWidth*2, height + cyanWidth*2 + borderWidth*2));
    
    offsetCord-=borderWidth;
    offsetSize-=borderWidth*2;
    
    Iw2DSetColour(g_ColorManager.getCyanColor()); //cyan
    Iw2DFillRect(CIwSVec2(x - cyanWidth, y - cyanWidth), CIwSVec2(width + cyanWidth*2, height + cyanWidth*2));
    
    
    offsetCord-=cyanWidth;
    offsetSize-=cyanWidth*2;
    
    Iw2DSetColour(g_ColorManager.getGeneralBackgroundColor());
    Iw2DFillRect(CIwSVec2(x, y), CIwSVec2(width, height));
}
Esempio n. 14
0
void CGame::Render()
{
	if (m_loaded)
	{
		int16 dw = (int16)Iw2DGetSurfaceWidth();
		int16 dh = (int16)Iw2DGetSurfaceHeight();
		Iw2DSetColour(0xff000000);
		Iw2DFillRect(CIwSVec2(0, 0), CIwSVec2(dw, dh));
		Iw2DSetColour(0xffffffff);

	
		for (uint32 i = 0; i < m_guicontrols.size(); i++)
			m_guicontrols[i]->Render();

		if (m_lvlFinishDialog->Get_Visible())
			m_lvlFinishDialog->Render();

		if (m_keyboard->GetVisible())
			m_keyboard->Render();

		if (m_closing)
		{
			int32 clr = 255 * (MAX_CLOSETIME - m_closetime) / MAX_CLOSETIME;
			clr = clr << 24;
			//clr += 0xffffff;
			Iw2DSetColour(clr);
			Iw2DFillRect(CIwSVec2(0, 0), CIwSVec2(dw, dh));
		}
		if (m_showing)
		{
			int32 clr = 255 * (m_showtime) / MAX_SHOWTIME;
			clr = clr << 24;
		//	clr += 0xffffff;
			Iw2DSetColour(clr);
			Iw2DFillRect(CIwSVec2(0, 0), CIwSVec2((int16)dw, (int16)dh));
		}
	}
}
Esempio n. 15
0
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 DrawBootSequence()
{
	Iw2DSetFont(font);

	int h = font->GetHeight();

	for (unsigned i = 0; i < g_Current_Line; i++) {
		int w = Iw2DGetStringWidth(g_Bootup_Sequence[i]);

		Iw2DSetColour(0xffffffff);
		Iw2DDrawString(g_Bootup_Sequence[i], CIwFVec2(0, i*h),
			CIwFVec2(w, h), IW_2D_FONT_ALIGN_LEFT, IW_2D_FONT_ALIGN_TOP);
	}
}
Esempio n. 17
0
//-----------------------------------------------------------------------------
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'
}
void DrawScale(CIwFVec2 aim)
{
	Iw2DSetColour(0xffffffff);

	for (int i = RANGE_X.x; i <= RANGE_X.y; i += 10)
	{
		if ((i - RANGE_X.x) % 100 == 0) {
			Iw2DDrawLine(CIwFVec2(i, GAME_HEIGHT + 10), CIwFVec2(i, GAME_HEIGHT + 50));
		}
		else {
			Iw2DDrawLine(CIwFVec2(i, GAME_HEIGHT + 20), CIwFVec2(i, GAME_HEIGHT + 40));
		}
	}

	for (int i = RANGE_Y.x; i <= RANGE_Y.y; i += 10)
	{
		if ((i - RANGE_Y.x) % 100 == 0) {
			Iw2DDrawLine(CIwFVec2(GAME_WIDTH + 10, i), CIwFVec2(GAME_WIDTH + 50, i));
		}
		else {
			Iw2DDrawLine(CIwFVec2(GAME_WIDTH + 20, i), CIwFVec2(GAME_WIDTH + 40, i));
		}
	}

	CIwFVec2 triangle_x[] = {
		CIwFVec2(aim.x, GAME_HEIGHT + 20),
		CIwFVec2(aim.x + 10, GAME_HEIGHT + 40),
		CIwFVec2(aim.x - 10, GAME_HEIGHT + 40)
	};

	CIwFVec2 triangle_y[] = {
		CIwFVec2(GAME_WIDTH + 20, aim.y),
		CIwFVec2(GAME_WIDTH + 40, aim.y - 10),
		CIwFVec2(GAME_WIDTH + 40, aim.y + 10)
	};

	Iw2DFillPolygon(triangle_x, 3);
	Iw2DFillPolygon(triangle_y, 3);
	
	Iw2DDrawLine(CIwFVec2(aim.x - 10, aim.y), CIwFVec2(aim.x + 10, aim.y));
	Iw2DDrawLine(CIwFVec2(aim.x, aim.y - 10), CIwFVec2(aim.x, aim.y + 10));

	Iw2DDrawLine(CIwFVec2(aim.x - 5, aim.y - 10), CIwFVec2(aim.x + 5, aim.y - 10));
	Iw2DDrawLine(CIwFVec2(aim.x - 5, aim.y + 10), CIwFVec2(aim.x + 5, aim.y + 10));

	Iw2DDrawLine(CIwFVec2(aim.x - 10, aim.y - 5), CIwFVec2(aim.x - 10, aim.y + 5));
	Iw2DDrawLine(CIwFVec2(aim.x + 10, aim.y - 5), CIwFVec2(aim.x + 10, aim.y + 5));
}
Esempio n. 19
0
void CGame::Render()
{
    // game render goes here

    // for example, clear to black (the order of components is ABGR)
    Iw2DSurfaceClear(0xff000000);

    // draw a red square
    Iw2DSetColour(0xff0000ff);
    
    // note conversion to pixel coordinates
    Iw2DFillRect(CIwSVec2((iwsfixed)m_Position.x, (iwsfixed)m_Position.y) - m_Size/IW_FIXED(2), m_Size);

    // show the surface
    Iw2DSurfaceShow();
}
Esempio n. 20
0
void CInventory::Draw()
{
	// Only display inventory in certain game states
	if (g_Game.getGameState() == GS_Playing || g_Game.getGameState() == GS_Paused || g_Game.getGameState() == GS_LevelCompletedFailure || g_Game.getGameState() == GS_LevelCompletedSuccess)
	{
		// Set the current font
		Iw2DSetFont(g_Game.getFont());

		// Reset the visual transform
		Iw2DSetTransformMatrix(CIwMat2D::g_Identity);

		// Set the texts colour to black
		//Iw2DSetColour(0xff000000);
		// HASAN - switched to white since there's a background now
		Iw2DSetColour(0xffffffff);

		// Convert the atom count number to text
		char str[32];
		for (int i = 0; i < inventoryCount; i++)
		{
			// skip to the next if count is zero - and atom is hidden (i.e. - it was originally in the inventory, but now is fully used and no longer available)
			if (atomCount[i] <= 0)
				continue;

			snprintf(str, 32, "%d", atomCount[i]);

			// horizontal center, same as inventory graphic
			int posX = (Iw2DGetSurfaceWidth() / 2) - ( IMAGE_SIZE_WIDTH / 2 ) + 19;
			int posY = Iw2DGetSurfaceHeight() - ( IMAGE_SIZE_HEIGHT / 2);

			// offset inventory vertically to fit in the container
			posX = posX + (10 + (64 / 2));  // NOTE: 64 = atom size, 10 = border + spacing
			if (i > 0)
			{
				posX = posX + (i * (64 + 15));  // NOTE: 64 = atom size, 15 = spacing + border + spacing
			}

			// Draw the atom count in the appropriate location
			Iw2DDrawString(str, CIwSVec2(posX, posY), CIwSVec2(30, 30), IW_2D_FONT_ALIGN_LEFT, IW_2D_FONT_ALIGN_TOP);
		}
	}
}
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);
	}
}
Esempio n. 22
0
void Sprite::Render()
{
	// set the values for interpolating translation
	if( interpolateTranslation == true )
	{
		// debug
		// printf("interpolating...\n");
		bool interpolateX = true;
		bool interpolateY = true;

		
		// increment position
		if( position != endingPosition )
		{			
			position += velocity;

			/* debug
			printf("position is %d, %d \n", position.x, position.y );
			printf("velocity is %d, %d \n", velocity.x, velocity.y );
			printf("acceleration is %d, %d \n", acceleration.x, acceleration.y );
			*/

			if( mode == DECELERATING )
			{
				if( interpolateX == true && (sqrt( pow( endingPosition.x-position.x, 2) + pow( endingPosition.y-position.y, 2)) < decelerationLimit ) )
				{				
					velocity.x += acceleration.x;
				}

				if( interpolateY == true && (sqrt( pow( endingPosition.x-position.x, 2) + pow( endingPosition.y-position.y, 2)) < decelerationLimit ) )
				{
					velocity.y += acceleration.y;
				}
			}
			else if( mode == ACCELERATING )
			{
				velocity += acceleration;
				/*
				if( sqrt( pow( endingPosition.x-position.x, 2) + pow( endingPosition.y-position.y, 2)) < accelerationLimit  )
				{
					// do nothing if limit is reached
				}
				else
				{
					velocity += acceleration;
				}*/
			}
		}

		// Clamp position if endingPosition reached
		if( velocity.x <= 0 )
		{
			if( position.x <= endingPosition.x ) // if final x position reached
			{
				position.x = endingPosition.x;
				interpolateX = false;
			}
		}
		else if( velocity.x > 0 )
		{
			if( position.x >= endingPosition.x )
			{
				position.x = endingPosition.x;
				interpolateX = false;
			}
		}

		if( velocity.y <= 0 )
		{
			if( position.y <= endingPosition.y ) // if final y position reached
			{
				position.y = endingPosition.y;
				interpolateY = false;
			}
		}
		else if( velocity.y > 0 )
		{
			if( position.y >= endingPosition.y )
			{
				position.y = endingPosition.y;
				interpolateY = false;
			}
		}

		// shuts off interpolation
		if( interpolateX == false && interpolateY == false )
		{
			interpolateTranslation = false;
			// debug
			// printf("done interpolating. \n");
		}
	}

	if( interpolateAlpha == true )
	{
		// do nothing if alpha limit reached
		currentAlpha += deltaAlpha;
		if( endingAlpha > startingAlpha )
		{
			if( currentAlpha >= endingAlpha )
			{
				currentAlpha = endingAlpha;
			}
		}
		else if( startingAlpha > endingAlpha )
		{
			if( currentAlpha <= endingAlpha )
			{
				currentAlpha = endingAlpha;
			}
		}

		externalColor = Iw2DGetColour();
		CIwColour color = { 255, 255, 255, currentAlpha };
		Iw2DSetColour( color );
	}


	if( playAnimation == true )
	{
		// Set the topleft coordinate based on Sprite's center position and size to be drawn
		topLeft.x = position.x - size.x / 2;
		topLeft.y = position.y - size.y / 2;

		// just in case uHeight was not set, it means it's a square
		if( uHeight == 0 )
			uHeight = uWidth;

		// set the region size to be drawn on the screen. uWidth and uHeight are # of pixels
		regionSize.x = uWidth;
		regionSize.y = uHeight;

		// Calculate the pixel offset for region to be drawn
		int16 totalPixelWidth = image->GetWidth(); // the pixel width of the original image
		int16 totalPixelHeight = image->GetHeight(); // the pixel height of the original image
		int16 totalColumns = totalPixelWidth / uWidth; // the number of columns of entire image based on uwidth
		int16 totalRows = totalPixelHeight / uHeight; // the number of rows of entire image based on uheight

		int16 columnNumber = frameCounter % totalColumns; // column number is f % c. This works. Where framecounter starts at zero. x/y offsets also start at zero
		int16 rowNumber = frameCounter / totalColumns; // row number is f / c. This also works. Where frameCounter starts at zero. x/y offsets also start at zero 

		regionOffset.x = columnNumber * uWidth;
		regionOffset.y = rowNumber * uHeight;

		// DRAW THE IMAGE
		if( repeatCount != 0 ) // if there's a repeat count set
		{
			if( loopCount < repeatCount )
			{
				Iw2DDrawImageRegion( image, topLeft, size, regionOffset, regionSize );
			}
		}
		else // if no repeat count, render and animate indefinitely
		{
			Iw2DDrawImageRegion( image, topLeft, size, regionOffset, regionSize );
		}

		// allows for slowing fps.
		if( fpsDelayTime == 0 ) // if a delay time was not set, the frame does not increment and sprite does not animate
		{
			// no animation
			frameCounter = 0;
		}
		else if( fpsDelayTime == 1 ) // if delay time is 1, that means it animates at 1 frame per iteration. 
		{
			frameCounter++; // this is incrementing what frame is being rendered

			// WRAP the frame counter. END OF ANIMATION LOOP
			if( totalFrames != 0 )
			{
				if( frameCounter == totalFrames )
				{
					frameCounter = 0;
					loopCount++;
				}
			}		
			else if( frameCounter == totalColumns * totalRows ) // if frame counter reaches the lastFrame+1, set equal to first frame; lastFrame+1 = (totalC * totalR) because frameCounter starts at Zero													   
			{
				frameCounter = 0;
				loopCount++;
			}
			
		}
		else if( fpsDelayCounter % fpsDelayTime == 0 && fpsDelayCounter != 0 ) // if the loop has been delayed long enough to equal the delay time, increment frame
		{
			frameCounter++; // this is incrementing what frame is being rendered
		
			// WRAP the frame counter. END OF ANIMATION LOOP
			if( totalFrames != 0 )
			{
				if( frameCounter == totalFrames )
				{
					frameCounter = 0;
					loopCount++;
				}
			}		
			else if( frameCounter == totalColumns * totalRows ) // if frame counter reaches the lastFrame+1, set equal to first frame; lastFrame+1 = (totalC * totalR) because frameCounter starts at Zero													   
			{
				frameCounter = 0;
				loopCount++;
			}

			// WRAP the delay counter to prevent overflow
			fpsDelayCounter = 0;

			// CLAMP the loop count to prevent overflow
			if( loopCount >= 15000 )
			{
				loopCount = 15000;
			}

		}

		// SKIP A FRAME
		fpsDelayCounter++; // this ONLY affects the 3rd condition of the above if-statement
	} // end of if playAnimation == true

	if( interpolateAlpha == true )
	{
		Iw2DSetColour( externalColor );
	}
}
Esempio n. 23
0
int main(int argc, char* argv[])
{
	g_pointerdown = false;
	FillDefaultLocalScores();
	// Initialisation of Airplay Studio modules
	Iw2DInit();			// Initialise support for rendering with the standard SW renderer
	IwGxLightingOff();
	IwResManagerInit();
	Load();

	int16 sw = (int16)Iw2DGetSurfaceWidth();
	int16 sh = (int16)Iw2DGetSurfaceHeight();

	PAL_InitData_t palInitData;
	SC_Error_t retCode = SC_Client_New(&g_client, &palInitData, SC_TEST_GAME_ID,
			SC_TEST_GAME_SECRET, "AIW");

	if (retCode != SC_OK) 
		s3eDebugAssertShow(S3E_MESSAGE_CONTINUE_STOP, "Failed to create SC_Client");
	
	IwGetResManager()->LoadGroup("fonts.group");
	LoadGlobalImages();

	LoadMainControls();
	game = new CGame();
	mainmenu = new CMainMenu();
	profile = new CProfile();
	scores = new CScores();


	mainmenu->Load();
	game->Load();
	profile->Load();
	scores->Load();
	CBaseScene *curscene = (CBaseScene *)mainmenu;
	g_curSceneType = stMainMenu;


	uint32 timer = (uint32)s3eTimerGetMs();

	g_AccelerometerEnabled = (s3eAccelerometerStart() == S3E_RESULT_SUCCESS);

	

	while(curscene)
	{

		s3eDeviceYield(0);


		//// Check for user quit
		if (s3eDeviceCheckQuitRequest())
			break;


		int delta = uint32(s3eTimerGetMs()) - timer;
		timer += delta;

		// Make sure the delta-time value is safe
		if (delta < 0)
			delta = 0;
		if (delta > 100)
			delta = 100;

		if (g_AccelerometerEnabled)
		{

			if (!g_waiting)
			{
				if (g_errorDialog->Get_Visible())
				{
					if (UpdatePointer() == petDown)
						CloseErrorDlg();
					else
						g_errorDialog->Update(delta);
				}
				else
				{
					switch (UpdatePointer())
					{
						case petNone: break;
						case petDown: curscene->PointerDown(g_pointerx, g_pointery); break;
						case petUp: curscene->PointerUp(g_pointerx, g_pointery); break;
						case petMove: curscene->PointerMove(g_pointerx, g_pointery); break;
					}
					curscene->Update(delta);
				}
			}
			curscene->Render();
			if (g_waiting)
			{
				Iw2DSetColour(0xeeffffff);
				Iw2DFillRect(CIwSVec2(0, 0), CIwSVec2(sw, sh));

				Iw2DSetColour(0xff000000);
		
				Iw2DSetFont(g_font);
				Iw2DDrawString(g_waitcaption, CIwSVec2(0, 0), CIwSVec2(sw, sh), IW_2D_FONT_ALIGN_CENTRE, IW_2D_FONT_ALIGN_CENTRE);
			}
			if (g_errorDialog->Get_Visible())
			{
				g_errorDialog->Render();
			}
		}


		Iw2DSurfaceShow();

		switch (g_curSceneType)
		{
			case stNone: curscene = 0; break;
			case stMainMenu: 
			{
				if (curscene != (CBaseScene *)mainmenu)
				{
					curscene = (CBaseScene *)mainmenu; 
					curscene->Show();
				}
			}	break;
			case stGame: 
			{
				if (curscene != (CBaseScene *)game)
				{
					curscene = (CBaseScene *)game;
					curscene->Show();
				}
			}break;

			case stProfile: 
			{
				if (curscene != (CBaseScene *)profile)
				{
					curscene = (CBaseScene *)profile;
					curscene->Show();
				}
			}break;
			case stScores: 
			{
				if (curscene != (CBaseScene *)scores)
				{
					curscene = (CBaseScene *)scores;
					curscene->Show();
				}
			}break;
		}
	}
	Save();
	delete game;
	delete mainmenu;
	delete profile;
	delete scores;

	SC_Client_Release(g_client);
	UnloadGlobalImages();
	UnloadMainControls();
	if (g_AccelerometerEnabled)
		s3eAccelerometerStop();
	// Terminate system modules
	IwResManagerTerminate();
	Iw2DTerminate();

	return 0;
}
void DrawGameBackground()
{
	Iw2DSetColour(0xffffffff);
	Iw2DDrawRect(CIwFVec2(0,0), CIwFVec2(GAME_WIDTH, GAME_HEIGHT));
}