예제 #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);
		}
	}
}
예제 #2
0
파일: game.cpp 프로젝트: felixiao/Demos
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();
}
예제 #3
0
void CGame::Render()
{
    // game render goes here

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

	Iw2DDrawImage(m_ImgBG, CIwSVec2(0,0));
	Iw2DDrawImage(m_ImgKey, CIwSVec2(m_Position.x, m_Position.y));

    // show the surface
    Iw2DSurfaceShow();
}
예제 #4
0
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;
}
예제 #5
0
파일: button.cpp 프로젝트: felixiao/Demos
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);
	}
예제 #6
0
void DrawOnRed()
{
	int w = Iw2DGetSurfaceWidth();
	int h = Iw2DGetSurfaceHeight();
	Iw2DSurfaceClear(0xFF0000FF);
	Iw2DDrawImage(image1, CIwSVec2(w / 2 - image1->GetWidth() / 2, h / 2 - image1->GetHeight() / 2));
}
예제 #7
0
void DrawOnBlue()
{
	int w = Iw2DGetSurfaceWidth();
	int h = Iw2DGetSurfaceHeight();
	Iw2DSurfaceClear(0xFFFF0000);
	Iw2DDrawImage(image2, CIwSVec2(w / 2 - image2->GetWidth() / 2, h / 2 - image2->GetHeight() / 2));
}
예제 #8
0
void DrawMap()
{
	Iw2DSurfaceClear(0x11550030);
	for(int i=0;i<10;i++)
	{
		for(int j=0;j<10;j++)
		{
			switch(Map[i][j])
			{
			case 0: Iw2DDrawImage(grass,CIwFVec2((i-j+9)*16,(i+j)*8)); break;
			case 1: Iw2DDrawImage(three,CIwFVec2((i-j+9)*16,(i+j)*8)); break;
			case 2: Iw2DDrawImage(grass,CIwFVec2((i-j+9)*16,(i+j)*8));
					Iw2DDrawImage(man,CIwFVec2((i-j+9)*16,(i+j)*8));
					break;
			}
		}
	}
	Iw2DSurfaceShow();
}
예제 #9
0
파일: map.cpp 프로젝트: felixiao/Demos
void Map::Render(CIwSVec2 characterBox)
{
	IW_CALLSTACK("MAP::Render()");
	if(_BGImage)
		Iw2DDrawImage(_BGImage,CIwSVec2(0,0));
	int index_Touched=-1;
	m_tileRotating=false;
	if(current_States==S3E_POINTER_STATE_DOWN)
	{
		CIwFVec2 touch=m_Position+GetTouches(S3E_POINTER_STATE_DOWN);
		int index_y=int(touch.y)/_tileset_map->GetSize().y;
		int index_x=int(touch.x)/_tileset_map->GetSize().x;
		index_Touched=index_y*_width+index_x;
		if(CheckNPC(index_Touched))
		{
			std::cout<<"NPC!!!"<<std::endl;
			showDialog++;
			if(showDialog>=_NPC->m_Dialogs.size())
				showDialog=-1;
		}
		if(_blocked&&(_layer_maze->m_TileIndex[index_Touched]-_tileset_maze->m_firstGid)>=0)
		{
			m_tileRotating=true;
			_TileDir[index_Touched]+=1;
			if(_TileDir[index_Touched]==4)
				_TileDir[index_Touched]=0;
		}
		std::cout<<"x:"<<index_x<<", y:"<<index_y<<", index: "<<index_Touched<<std::endl;

	}
	int index_start=(int)m_Position.x/_tileWidth+((int)m_Position.y/_tileHeight)*_width;
	if(index_start>=_width)
		index_start=index_start-_width;
	int index_end=((int)m_Position.x+screenWidth)/_tileWidth+(((int)m_Position.y+screenHeight)/_tileHeight)*_width+1;
	for(int i=index_start;i!=index_end;i++)
	{
		int index_x=i%_width;
		int index_y=i/_width;

		CIwSVec2 topleft = CIwSVec2(int(index_x * _tileWidth-m_Position.x), int(index_y * _tileHeight-m_Position.y));

		_tileset_map->Render(_layer_base->m_TileIndex[i],topleft,_layer_base->m_rotatable? _TileDir[i]:0);
		_tileset_map->Render(_layer_middle->m_TileIndex[i],topleft,_layer_middle->m_rotatable? _TileDir[i]:0);
		_tileset_maze->Render(_layer_maze->m_TileIndex[i],topleft,_layer_maze->m_rotatable? _TileDir[i]:0);
	}
	for(int i=0;i!=9;i++)
	{
		_TileObstacles[i].Render(m_Position,false,characterBox,i);
	}
	if(showDialog>=0)
	{
		_NPC->Dialog(showDialog);
	}
	
}
예제 #10
0
void DrawXm(int x)
{	
	float j=(manX+manY)*8;
	for(int i=(manX-manY+9)*16;i>=(x-manY+9)*16;i--)
	{
		DrawMap(manX,manY);
		Iw2DDrawImage(man,CIwFVec2(i,j));
		Iw2DSurfaceShow();
		j=j-0.5;
	}
}
예제 #11
0
파일: ig_sprite.cpp 프로젝트: 9cat/Cryptose
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));
	}
}
예제 #12
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);
}
예제 #13
0
void DrawYp(int y)
{
	int i=(manX-manY+9)*16;
	for(float j=(manX+manY)*8;j<=(manX+y)*8;j++)
	{
		j=j-0.5;
		DrawMap(manX,manY);
		Iw2DDrawImage(man,CIwFVec2(i,j));
		Iw2DSurfaceShow();
		i--;
	}
}
예제 #14
0
void DrawYm(int y)
{
	int i=(manX-manY+9)*16;
	for(float j=(manX+manY)*8;j>=(manX+y)*8;j--)
	{
		j=j+0.5;
		DrawMap(manX,manY);
		Iw2DDrawImage(man,CIwFVec2(i,j));
		Iw2DSurfaceShow();
		i++;
	}
}
예제 #15
0
void DrawMap(int x,int y)
{
	for(int i=x-1;i<x+1;i++)
	{
		if(i<0) i++;
 
		for(int j=y-1;j<y+1;j++)
		{
			if(j<0) j++;

			switch(Map[i][j])
			{
				case 0: Iw2DDrawImage(grass,CIwFVec2((i-j+9)*16,(i+j)*8)); break;
				case 1: Iw2DDrawImage(three,CIwFVec2((i-j+9)*16,(i+j)*8)); break;
				case 2: 
					Iw2DDrawImage(grass,CIwFVec2((i-j+9)*16,(i+j)*8));
					Iw2DDrawImage(man,CIwFVec2((i-j+9)*16,(i+j)*8));
					break;
				default:break;
			}
		}
	}
}
예제 #16
0
파일: main.cpp 프로젝트: tmowyang/words
int main()
{
	// Initialise the 2D graphics system
	Iw2DInit();

	// Set up input systems
	g_pInput = new Input();

	// Create an image from a PNG file
	CIw2DImage* image = Iw2DCreateImage("textures/letter_A.png");
	CIwFVec2    image_position = CIwFVec2::g_Zero;

	// Loop forever, until the user or the OS performs some action to quit the app
	while (!s3eDeviceCheckQuitRequest())
	{
		// Update input system
		g_pInput->Update();

		// Clear the drawing surface
		Iw2DSurfaceClear(0xff000000);

		// Draw an image
		CIwFVec2 sz = CIwFVec2(50, 50);
		Iw2DDrawImage(image, image_position, sz);

		// Check for user tapping screen
		if (!g_pInput->m_Touched && g_pInput->m_PrevTouched)
		{
			// Move image to touched position
			image_position.x = (float)g_pInput->m_X - 25;
			image_position.y = (float)g_pInput->m_Y - 25;

			// Reset input
			g_pInput->Reset();
		}

		// Show the drawing surface
		Iw2DSurfaceShow();

		// Yield to the OS
		s3eDeviceYield(0);
	}

	// Clean-up
	delete image;
	delete g_pInput;
	Iw2DTerminate();

	return 0;
}
예제 #17
0
void N2F::Iw3D::Image::draw(int64 delta, CIwFVec2 offset)
{
	CIwFVec2 p = CIwFVec2(
		((this->pos.x * this->scaleFactor.scale) + this->scaleFactor.offset.x + offset.x),
		((this->pos.y * this->scaleFactor.scale) + this->scaleFactor.offset.y + offset.y)
	);
	CIwFVec2 s = CIwFVec2(
		(this->size.x * this->scaleFactor.scale),
		(this->size.y * this->scaleFactor.scale)
	);

	Iw2DDrawImage(this->img, p, s);

	return;
}
예제 #18
0
void Brixpath::drawBackgroundPattern(){
    double width = Iw2DGetSurfaceWidth();
    double height = Iw2DGetSurfaceHeight();
    
    double backgroundImageWidth = _backgroundImage->GetWidth();
    double backgroundImageHeight = _backgroundImage->GetHeight();
    
    int timesX = ceil(width / backgroundImageWidth);
    
    int timesY = ceil(height / backgroundImageHeight);
    
    for(int y = 0; y < timesY; y++){
        for(int x = 0; x < timesX; x++){
            Iw2DDrawImage(_backgroundImage, CIwSVec2(x*backgroundImageWidth, y*backgroundImageHeight));
        }
    }
};
예제 #19
0
void renderMapXpBar() {
	IwGxLightingOff();

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

	int16 w = (double)IwGxGetScreenWidth() * 0.40f;
	if (w > (double)xpBarTexture->GetWidth() * 1.80f) w = (double)xpBarTexture->GetWidth() * 1.80f;

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

	int rightPadding = IwGxGetScreenWidth() * 0.10f;
	int topPadding  = IwGxGetScreenHeight() * 0.015f;

	CIwFVec2 size = CIwFVec2(w, h);
	CIwFVec2 topLeft = CIwFVec2(IwGxGetScreenWidth() - rightPadding - w, topPadding);

	Iw2DDrawImage(xpBarTexture, topLeft, size);
}
예제 #20
0
//-----------------------------------------------------------------------------
void ExampleRender()
{
	static const CIwSVec2 imageSize(g_Image->GetWidth() >> 3, g_Image->GetHeight() >> 3);
	static const CIwSVec2 halfImageSize = imageSize >> 1;

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

	const b2Transform t = g_body->GetTransform();
	const CIwSVec2 pos = screenCentre + (CIwSVec2(int16(t.p.x*8), -int16(t.p.y*8)));
	const float angle = -t.q.GetAngle() * (180.0f/3.14159f);	// reverse angle as our screen-Y coord is reversed

	CIwMat2D rot;
	rot.SetRot(iwangle(angle * 1024 / 90), CIwVec2(pos) << 3);
	Iw2DSetTransformMatrixSubPixel(rot);

	Iw2DDrawImage(g_Image, pos - halfImageSize, imageSize);

    //
    Iw2DSetTransformMatrix(CIwMat2D::g_Identity);
    Iw2DSurfaceShow();
}
예제 #21
0
파일: panel.cpp 프로젝트: felixiao/Demos
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();
	}
}
예제 #22
0
void N2F::Iw3D::Image::draw(int64 delta, CIwFVec2 offset, float angle, float scale)
{
	CIwFVec2 p = CIwFVec2(
		((this->pos.x * this->scaleFactor.scale) + this->scaleFactor.offset.x + offset.x),
		((this->pos.y * this->scaleFactor.scale) + this->scaleFactor.offset.y + offset.y)
	);
	CIwFVec2 s = CIwFVec2(
		(this->size.x * scale),
		(this->size.y * scale)
	);

	CIwFMat2D m = CIwFMat2D::g_Identity;
	m.Scale(scale);
	m.SetRot(angle);
	m.ScaleRot(scale);
	m.SetTrans(CIwFVec2((p.x + (s.x / 2)), (p.y + (s.y / 2))));

	Iw2DSetTransformMatrix(m);
	Iw2DDrawImage(this->img, CIwFVec2(-(s.x / 2), -(s.y / 2)), s);
	Iw2DSetTransformMatrix(CIwFMat2D::g_Identity);

	return;
}
예제 #23
0
void renderMapPlayer() {
	IwGxLightingOff();

	int16 w = IwGxGetScreenWidth()*0.085f;

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

	Iw2DSetAlphaMode(IW_2D_ALPHA_NONE);
	double angle = rad(getGameState()->getPlayer()->getHeading());

	Iw2DSetTransformMatrix(CIwFMat2D::g_Identity);
	CIwFVec2 centre =
			CIwFVec2((int16)Iw2DGetSurfaceWidth()/2,
					 (int16)Iw2DGetSurfaceHeight()/2);
	CIwFMat2D rot;
	rot.SetRot(angle, (CIwFVec2)centre);
	Iw2DSetTransformMatrix(rot);

	CIwFVec2 size = CIwFVec2(w, h);
	CIwFVec2 topLeft = CIwFVec2(centre.x-size.x/2, centre.y-size.y/2);

	Iw2DDrawImage(playerTexture, topLeft, size);
}
예제 #24
0
void Sprite::Draw()
{
	Iw2DDrawImage(image, *position, *size);
}
예제 #25
0
void CameraDefend::Render() {
	if (defended) {
		IwGxLightingOff();

		animMatSuccess->SetModulateMode(CIwMaterial::MODULATE_NONE);
		animMatSuccess->SetAlphaMode(CIwMaterial::ALPHA_BLEND);

		IwGxSetMaterial(animMatSuccess);
		IwGxSetUVStream(anim_uvs_success);

		IwGxSetVertStreamScreenSpace(animVertsLeftSuccess, 4);
		IwGxDrawPrims(IW_GX_QUAD_LIST, NULL, 4);

		IwGxSetVertStreamScreenSpace(animVertsRightSuccess, 4);
		IwGxDrawPrims(IW_GX_QUAD_LIST, NULL, 4);

		if (animMatSuccess->GetAnimCelID() == animMatSuccess->GetAnimCelNum() - 1) {
			defended = false;
		}
	} else {
		animMatSuccess->SetAnimCelID(0);
	}

	if (!isActive()) return;

	{
		Ghost* ghost = getGameState()->getGhost();
		GhostAttack* attack = (ghost != NULL) ? ghost->getAttack() : NULL;

		if (attack != NULL && 
			((attack->getInterval() <  750 && attack->getInterval() > 600) ||
			 (attack->getInterval() <  400 && attack->getInterval() > 250))) {
			dotTexture = dotTextureRed;
		} else {
			dotTexture = dotTextureGreen;
		}
	}

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

	CIwFMat2D rot;
	rot.SetRot(rad(dotAngle), CIwFVec2(
		dotVertsTopLeftLeft.x + dotVertsSizeLeft.x/2, 
		dotVertsTopLeftLeft.y + dotVertsSizeLeft.y/2));
	Iw2DSetTransformMatrix(rot);
	Iw2DDrawImage(dotTexture, dotVertsTopLeftLeft, dotVertsSizeLeft);

	rot.SetRot(rad(dotAngle), CIwFVec2(
		dotVertsTopLeftRight.x + dotVertsSizeRight.x/2, 
		dotVertsTopLeftRight.y + dotVertsSizeRight.y/2));
	Iw2DSetTransformMatrix(rot);
	Iw2DDrawImage(dotTexture, dotVertsTopLeftRight, dotVertsSizeRight);

	bool isDrwaing = true;
	for (int i = 0; i < DEFEND_TOUCHES_MAX; i++) {
		// Is any touch drawing?
		if (touch[i]->drawing) break;

		if (i == DEFEND_TOUCHES_MAX - 1) {
			isDrwaing = false;
			animMat->SetAnimCelID(0);
		}
	}

	if (isDrwaing) {
		IwGxLightingOff();

		animMat->SetModulateMode(CIwMaterial::MODULATE_NONE);
		animMat->SetAlphaMode(CIwMaterial::ALPHA_BLEND);

		IwGxSetMaterial(animMat);
		IwGxSetUVStream(anim_uvs);

		IwGxSetVertStreamScreenSpace(animVertsLeft, 4);
		IwGxDrawPrims(IW_GX_QUAD_LIST, NULL, 4);

		IwGxSetVertStreamScreenSpace(animVertsRight, 4);
		IwGxDrawPrims(IW_GX_QUAD_LIST, NULL, 4);
	}
}
예제 #26
0
파일: Ground.cpp 프로젝트: brizee/honours
void Ground::Render(){	
	Iw2DDrawImage(Background,CIwSVec2(0,0),CIwSVec2(mWidth, mHeight));	// Render background

}
예제 #27
0
void OpponentCar::Draw()
{
	Iw2DDrawImage(m_image,CIwFVec2(m_x1,m_y1));
}