void GameplayState::SpawnCharacters()
{
	// Dave (big), Nigel (small), Mandy (girl)
	characters[DAVE] = new Sprite("dave_anim", true, CIwFVec2(6,1));
	characters[DAVE]->SetCenter(CIwSVec2((int16)characters[DAVE]->GetWidth() /2 , (int16)characters[DAVE]->GetHeight() /2));
	characters[DAVE]->SetPosition(m_Level->GetSpawnPositions().at(DAVE));
	characters[DAVE]->SetMovSpeed(CIwFVec2(1.5,5)); // Moves 1.5 units fast in the x axis (slow)
	
	characters[NIGEL] = new Sprite("nigel_anim", true, CIwFVec2(6,1));
	characters[NIGEL]->SetCenter(CIwSVec2((int16)characters[NIGEL]->GetWidth() /2, (int16)characters[NIGEL]->GetHeight() /2));
	characters[NIGEL]->SetPosition(m_Level->GetSpawnPositions().at(NIGEL));
	characters[NIGEL]->SetMovSpeed(CIwFVec2(3,3)); // Moves 3 units fast in the x axis (fastest)

	characters[MANDY] = new Sprite("mandy_anim", true, CIwFVec2(6,1));
	characters[MANDY]->SetCenter(CIwSVec2((int16)characters[MANDY]->GetWidth() /2, (int16)characters[MANDY]->GetHeight() /2));
	characters[MANDY]->SetPosition(m_Level->GetSpawnPositions().at(MANDY));
	characters[MANDY]->SetMovSpeed(CIwFVec2(2,2)); // Moves 2 units fast in the x axis (faster than dave, slower than nigel)

	m_PortraitSounds[DAVE] = static_cast<CIwSoundSpec*>(IwGetResManager()->GetResNamed("dave_selected", "CIwSoundSpec"));
	m_PortraitSounds[NIGEL] = static_cast<CIwSoundSpec*>(IwGetResManager()->GetResNamed("nigel_selected", "CIwSoundSpec"));
	m_PortraitSounds[MANDY] = static_cast<CIwSoundSpec*>(IwGetResManager()->GetResNamed("mandy_selected", "CIwSoundSpec"));

	for (int i = 0; i < 3; i++)
	{
//		characters[i]->ShowColliderPos = true;
	}

	characters[DAVE]->Debug_PrintPos();

}
Esempio n. 2
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;
}
Esempio n. 3
0
Sprite::Sprite(void)
{
	image = NULL;
	uWidth = 0;
	uHeight = 0;
	frameCounter = 0;

	fpsDelayCounter= 0;
	fpsDelayTime = 0;
	totalFrames = 0;

	loopCount = 0;
	repeatCount = 0;

	playAnimation = true;

	interpolateTranslation = false;

	velocity = CIwSVec2(0, 0);
	acceleration = CIwSVec2(0, 0);

	mode = DECELERATING;

	interpolateAlpha = false;
	startingAlpha = 0;
	endingAlpha = 0;
}
Esempio n. 4
0
void MapBackground::RenderElement(CIwUIGraphics& parentGraphics)
{
	// Render tiles for the background
	std::list<MapTile*>::iterator iter = gVectorImageUrls.begin();

	int i = 0;
	while (iter != gVectorImageUrls.end())
	{
		MapTile* pTile = *iter;

		if (pTile->pTexture)
		{
			//Calculate the top left of the map image
			CIwSVec2 topLeft, bottomRight;
			topLeft.x = pTile->location.x;
			topLeft.y = pTile->location.y;
			CIwUIRect rect(CIwVec2(topLeft.x, topLeft.y), CIwVec2(pTile->pTexture->GetWidth(), pTile->pTexture->GetHeight()));

			CIwUIColour c(0xff,0xff,0xff,0xff);
			CIwColour* wtf = IW_GX_ALLOC(CIwColour, 4);

			CIwMaterial* pMat = IW_GX_ALLOC_MATERIAL();
			pMat->SetModulateMode(CIwMaterial::MODULATE_NONE);
			pMat->SetTexture(pTile->pTexture);

			parentGraphics.DrawImage(pTile->pTexture, pMat, rect, CIwSVec2(0,0), CIwSVec2(4096, 4096), c, false);
		}
		iter++;
	}
}
Esempio n. 5
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();
}
Esempio n. 6
0
void Button::Load(char * imagename,CIwSVec2 pos)
{
	_image=Iw2DCreateImageResource(imagename);
	m_ImgSize=CIwSVec2(_image->GetWidth(),_image->GetHeight());
	m_BGSize=CIwSVec2(_image->GetWidth(),_image->GetHeight());
	m_ImgPos=pos;
	m_BGPos=pos;
	btn_type=IMAGE;
}
Esempio n. 7
0
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);
	}
	
}
Esempio n. 8
0
bool CScores::Load()
{
	if (!m_loaded)
	{
		int32 dw = Iw2DGetSurfaceWidth();
		int32 dh = Iw2DGetSurfaceHeight();
		int16 cx, cy, cw, ch;//, dx, dy;
		CGUIImageButton *btn; 
		//CIw2DImage *img;

		cx = 20;
		cy = 20;
		cw = 100;
		ch = g_font->GetHeight();
		btn = new CGUIImageButton(CIwSVec2(cx, cy), CIwSVec2(cw, ch), 0, false, g_font, false);
		btn->SetCaption("back");
		m_guicontrols.push_back((CGUIControl *)btn);

		cx = 20;
		cy = 20 + g_font->GetHeight() + 20;
		cw = 100;
		ch = g_font->GetHeight();
		btn = new CGUIImageButton(CIwSVec2(cx, cy), CIwSVec2(cw, ch), 0, false, g_font, false);
		btn->SetCaption("profile");
		m_guicontrols.push_back((CGUIControl *)btn);

		cx = 20;
		cy = 20 + g_font->GetHeight() + 20 + g_font->GetHeight() + 20;
		cw = 100;
		ch = g_font->GetHeight();
		btn = new CGUIImageButton(CIwSVec2(cx, cy), CIwSVec2(cw, ch), 0, false, g_font, false);
		btn->SetCaption("local");
		m_guicontrols.push_back((CGUIControl *)btn);

		cx = 20;
		cy = 20 + g_font->GetHeight() + 20 + g_font->GetHeight() + 20 + g_font->GetHeight() + 20;
		cw = 100;
		ch = g_font->GetHeight();
		btn = new CGUIImageButton(CIwSVec2(cx, cy), CIwSVec2(cw, ch), 0, false, g_font, false);
		btn->SetCaption("global");
		m_guicontrols.push_back((CGUIControl *)btn);

		m_listview = new CGUIListView(CIwSVec2(dw / 3, dh / 5), CIwSVec2(dw * 2 / 3, dh * 4 / 5), g_font, false);
		m_listview->set_needselect(false);
		m_listview->set_needimages(false);
		m_listview->set_itemsubtextsize(m_listview->get_itemsize() / 2);

		m_guicontrols.push_back((CGUIControl *)m_listview);

		m_loaded = true;
	}

	return m_loaded;
}
Esempio n. 9
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. 10
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));
	}
}
Esempio n. 11
0
void Anima::Load(char * filename,int frameCount,int aniSpeed)
{
	timeElapsed=0;
	_frameIndex=0;
	_aniSpeed=aniSpeed;
	_frameCount=frameCount;
	_image=Iw2DCreateImageResource(filename);
	_frameSize=CIwSVec2(_image->GetWidth()/_frameCount,_image->GetHeight());
	for(int i=0;i!=frameCount;i++)
	{
		_framePos.append(CIwSVec2(_frameSize.x*i,_frameSize.y));
	}
}
Esempio n. 12
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();
}
BackgroundManager::BackgroundManager()
{
	 IW_CALLSTACK("BackgroundManager::BackgroundManager");
	this->i2Size = CIwSVec2(Screen::getSCREENSIZE().x/2, Screen::getSCREENSIZE().y/2); 
	this->positionArray = CIwArray<CIwSVec2>();
	this->units = CIwArray<BackgroundUnit*>();

	this->backgroundSegments = CIwArray<CIw2DImage*>();
	this->positionArray.push_back(CIwSVec2(0,0));
	this->positionArray.push_back(CIwSVec2(this->i2Size.x,0));
	this->positionArray.push_back(CIwSVec2(0,this->i2Size.y));
	this->positionArray.push_back(CIwSVec2(this->i2Size.x,this->i2Size.y));
	
}
void GameplayState::Update(StateEngine* state, double dt)
{
	characters[DAVE]->Update(dt);
	characters[MANDY]->Update(dt);
	if (!m_isThrowing)
		characters[NIGEL]->Update(dt);

	ScrollCranes(dt);

	CheckInterations(state);

	for (int i = 0; i <3; i++)
	{
		CheckObjects(i);
		CheckCollisions(i);	
	}

	m_Cam->SetPosition(
		CIwSVec2(static_cast<int16>(-characters[m_CharacterIndex]->GetPosition().x + (screenWidth /2)),
		static_cast<int16>(-characters[m_CharacterIndex]->GetPosition().y + (screenHeight - characters[m_CharacterIndex]->GetHeight() - 32))));

	if (s3eKeyboardGetState(s3eKeySpace) == 4)
		m_SpacePressed = false;

	if (s3ePointerGetState(S3E_POINTER_BUTTON_LEFTMOUSE) == 4)
	{
		m_MouseClicked = false;
		m_ClickLocation = CIwFVec2(0,0);
		m_TerminalSound->ResetCounter();
	}
}
Esempio n. 15
0
Mouse::Mouse(CIwSVec2 i2Position): ShinyUnit() 
{
   IW_CALLSTACK("Mouse::Mouse");

   this->iAIHole = 10;
   this->bUpdate = false;
   this->bDead = false;
   this->bScared = false;
   this->f2Velocity = CIwFVec2(0.101f, 0);
   this->tTextureList.push_back(ImageManager::getImage("mouse"));
   this->tTextureList.push_back(ImageManager::getImage("mouseleft"));


   this->sSoundList.push_back(SoundManager::getSound("mouse1"));
   this->sSoundList.push_back(SoundManager::getSound("mouse2"));	
   this->sSoundList.push_back(SoundManager::getSound("mouse3"));
   this->sSoundList.push_back(SoundManager::getSound("mouse4"));

   this->i2Position = i2Position;
   this->f2AbsPosition = CIwFVec2((float)this->i2Position.x, (float)this->i2Position.y);
   this->i2InitialPosition = i2Position;
   this->sName = "mouse";
   this->fShininess = 6;
   this->bIsMoving = true;
   this->brBoundingBox = BoundingRectangle(this->getPosition(), this->getSize(), CIwSVec2((int)(this->i2Size.x * 0.3f), (int)(this->i2Size.y * 0.3f)), true);
   this->csPlayWith = CatState::MOUSEPLAYING;

   ClassTracker::addUnit(this);
}
Esempio n. 16
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);
}
Esempio n. 17
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);
	}
Esempio n. 18
0
Scythe::Scythe(CIwSVec2 i2Position): LethalUnit()
{
   IW_CALLSTACK("Scythe::Scythe");

   this->tTextureList.push_back(ImageManager::getImage("scythe"));
   this->tTextureList.push_back(ImageManager::getImage("bloodyscythe"));

   this->sSoundList.push_back(SoundManager::getSound("scythe_kill"));
   this->sSoundList.push_back(SoundManager::getSound("swoosh3"));

   this->iSoundIndex = 5;

   this->i2Position = i2Position;
   this->sName="scythe";
   this->brBoundingBox = BoundingRectangle(this->i2Position, this->i2Size, CIwSVec2((int)(this->i2Size.x * 0.7f), (int)(this->i2Size.y * 0.7f)));
   this->bUpdate = false;
   this->bIsMoving = true;
   this->bDrawn = false;
   this->mRot = CIwMat2D();
   this->iLength = 0;
   this->fAngularAcceleration = 0;
   this->fAngularVel = 0;
   this->fAngle = 0;
   this->iCapDeathCount = 1000;

   this->DarkGreen.Set(46, 139, 87, 255);
   this->LightGreen.Set(0, 255, 127, 255);
   this->green = IwRandMinMax(0 , 255);
   this->up = true;

   ClassTracker::addUnit(this);
}
Esempio n. 19
0
void TextSprite::RecalculateTextData()
{
    CIw2DFont *prevFont = Iw2DGetFont();

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

    int newlineCount = 1;
    char *checkChar = (char *)this->text.c_str();
    while(*checkChar != '\0')
    {
        if(*checkChar++ == '\n')
        {
            newlineCount++;
        }
    }

    textSize = SCREEN_TO_SUBPIXEL(CIwSVec2(Iw2DGetStringWidth(text.c_str()), textFont->GetHeight() * newlineCount));

    UpdatePositionData();

    if(prevFont != null)
    {
        Iw2DSetFont(prevFont);
    }
}
Esempio n. 20
0
void DrawOnBlue()
{
	int w = Iw2DGetSurfaceWidth();
	int h = Iw2DGetSurfaceHeight();
	Iw2DSurfaceClear(0xFFFF0000);
	Iw2DDrawImage(image2, CIwSVec2(w / 2 - image2->GetWidth() / 2, h / 2 - image2->GetHeight() / 2));
}
Esempio n. 21
0
void DrawOnRed()
{
	int w = Iw2DGetSurfaceWidth();
	int h = Iw2DGetSurfaceHeight();
	Iw2DSurfaceClear(0xFF0000FF);
	Iw2DDrawImage(image1, CIwSVec2(w / 2 - image1->GetWidth() / 2, h / 2 - image1->GetHeight() / 2));
}
Esempio n. 22
0
void Map::Render(CIwSVec2 characterBox)
{
	int index_Touched=-1;
	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;
		m_TileDir[index_Touched]+=1;
		if(m_TileDir[index_Touched]==4)
			m_TileDir[index_Touched]=0;
		std::cout<<"x:"<<index_x<<", y:"<<index_y<<", index: "<<index_Touched<<std::endl;

	}
	for(int i=0;i!=_total;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? m_TileDir[i]:0);
		_tileset_map->Render(_layer_middle->m_TileIndex[i],topleft,_layer_middle->m_rotatable? m_TileDir[i]:0);
		_tileset_maze->Render(_layer_maze->m_TileIndex[i],topleft,_layer_maze->m_rotatable? m_TileDir[i]:0);
	}

}
Esempio n. 23
0
void renderImageWorldSpace(CIwFVec2& position, float angle, float scaleFactor,
                        int textureSize, float worldRot, int frameNumber, int numFrames, float z) {
	
	static CIwSVec3 vertices[4];
	static CIwSVec2 UVs[4];
	
	//set up model space vertices
	
	int vertexDist = scaleFactor*textureSize/2;
	
	vertices[0] = CIwSVec3(-1*vertexDist, -1*vertexDist, z);
	vertices[2] = CIwSVec3(vertexDist, -1*vertexDist,    z);
	vertices[3] = CIwSVec3(vertexDist, vertexDist,       z);
	vertices[1] = CIwSVec3(-1*vertexDist, vertexDist,    z);
	
	CIwMat modelTransform = CIwMat::g_Identity;
	modelTransform.SetRotZ(IW_ANGLE_FROM_RADIANS(angle));
	modelTransform.SetTrans(CIwVec3(position.x, -position.y, 0));
	    
	CIwMat rot = CIwMat::g_Identity;
 	rot.SetRotZ(IW_ANGLE_FROM_RADIANS(worldRot));
	modelTransform = modelTransform*rot;
	
	IwGxSetModelMatrix(&modelTransform, false);
	
	float frameRatio = 1.0/numFrames;
	
	//set up sprite UV's
    
    iwfixed cf = IW_FIXED((float)frameNumber  / numFrames);
    iwfixed nf = IW_FIXED((frameNumber + 1.0) / numFrames);
    
	UVs[0] = CIwSVec2(cf, 0);
	UVs[2] = CIwSVec2(nf, 0);
	UVs[3] = CIwSVec2(nf, IW_GEOM_ONE);
	UVs[1] = CIwSVec2(cf, IW_GEOM_ONE);
		
	//render the unit in model space
	IwGxSetUVStream(UVs);
	
	IwGxSetZDepthFixed(8);	
	
	IwGxSetVertStreamModelSpace(vertices, 4);
	IwGxDrawPrims(IW_GX_QUAD_STRIP, NULL, 4);
	
    IwGxFlush();
}
Esempio n. 24
0
void Panel::Load(char * imagename,CIwSVec2 pos)
{
	m_images.append(Iw2DCreateImageResource(imagename));
	m_BGPos=pos;
	m_BGSize=CIwSVec2(m_images[m_images.size()-1]->GetWidth(),m_images[m_images.size()-1]->GetHeight());
	isMusicPlay=false;
	isDisplay=false;
	m_text="";
}
Esempio n. 25
0
void MatrixManager::Star::DrawStar(int alphaf)
{
    CIwSVec2 texpos = CIwSVec2(star_hue << 5, size_frame << 5);
    if (enabled <= 0)
        return;
    //
    myIwGxDrawStar((Iw2DGetSurfaceWidth() - FIELD_SIZE) / 2 + fx / FIELD_DIV,
        (Iw2DGetSurfaceHeight() - FIELD_SIZE) / 2 + fy / FIELD_DIV,
        texpos, multiplier, rot, alphaf);
}
Esempio n. 26
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. 27
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. 29
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. 30
0
void TileSet::Render(int index,CIwSVec2 topLeft,int rotation)
{
	int ind=index-m_firstGid;
	if(ind<0)
		return;
	int index_X=ind%_tilesPerRow;
	int index_Y=ind/_tilesPerRow;
	CIwSVec2 pos = CIwSVec2(index_X * _tilewidth,index_Y * _tileheight);
	if(rotation!=0)
	{
		iwangle  angle =90*rotation;//90 degrees
		CIwSVec2 centre=CIwSVec2(iwsfixed(topLeft.x+(float)_tilewidth/2.0f),iwsfixed(topLeft.y+(float)_tileheight/2.0f));
		CIwMat2D rot;
    
		rot.SetRot(IW_ANGLE_FROM_DEGREES(angle), CIwVec2(centre));

		Iw2DSetTransformMatrix(rot);
	}
	Iw2DDrawImageRegion(_image, topLeft, pos, _tileSize);
	Iw2DSetTransformMatrix(CIwMat2D::g_Identity);
}