コード例 #1
0
//-----------------------------------------------------------------------------
// Finished parsing the object
//-----------------------------------------------------------------------------
void GUIElement::ParseClose( CIwTextParserITX* apParser )
{
#ifdef IW_BUILD_RESOURCES
	IW_CALLSTACK( "GUIElement::ParseClose" );

	// Nesting level needs decreasing first
	s_FrameDepth--;

	// Get parent object from parser stack if we're still nested
	if( s_FrameDepth )
	{
		GUIElement* lpParent = reinterpret_cast<GUIElement*>( apParser->GetObject( -1 ) );
		IwAssertMsg( GUI, lpParent, ( "GUIElement %s declared without a parent", DebugGetName() ) );

		if( lpParent )
		{
			// Check parent really is a frame!
			IwAssertMsg( GUI, lpParent->TestFlags( GF_FRAME ), ( "GUIElement %s not declared within a GUIFrame", DebugGetName() ) );

			m_pParent = reinterpret_cast<GUIFrame*>( lpParent );
			m_pParent->AddChild( this );
		}
	}
	else
	{
		// Top level object, add to resource manager
		if( !strcmp( GetClassName(), "GUITemplate" ) )
			IwGetResManager()->AddRes( RESTYPE_GUITEMPLATE, this );
		else
			IwGetResManager()->AddRes( RESTYPE_GUIELEMENT, this );
	}
#endif
}
コード例 #2
0
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();

}
コード例 #3
0
void PatteRunGameEngine::Init(void* pGameStateVoid)
{
	IGameHandler* pGameState = (IGameHandler*)pGameStateVoid;
	/*
	g_pBall = new CBall(pGameState);
	g_pUserPaddle = new CGPSPaddle(pGameState);
	//g_pUserPaddle = new CCompPaddle(this, g_pBall, false);
	g_pCompPaddle = new CCompPaddle(pGameState, g_pBall, true);

	g_pBall->PushPaddle(g_pUserPaddle);
	g_pBall->PushPaddle(g_pCompPaddle);
	*/
	g_pUser = new CGPSUser(pGameState);
	g_pGameHandler = pGameState;
	g_pFontHuge = (CIwGxFont*)IwGetResManager()->GetResNamed("font_huge", "CIwGxFont");
	g_pFont = (CIwGxFont*)IwGetResManager()->GetResNamed("font_medium", "CIwGxFont");
	g_pFontSmall = (CIwGxFont*)IwGetResManager()->GetResNamed("font_small", "CIwGxFont");
	
	CIwImage imgTile;
	imgTile.LoadFromFile("images/patterun/tile.png");

	g_pTile = new CIwTexture();
	g_pTile->CopyFromImage(&imgTile);
	g_pTile->Upload();
}
コード例 #4
0
ファイル: HexMapTest.cpp プロジェクト: ralphtrickey/Hex-Map
//-----------------------------------------------------------------------------
void HexMapTest::Init()
{
	zoom = 1.0f;
	rotation = 0.0f;
	screenTranslationX = 0;
	screenTranslationY = 0;

	// Initialise the input system
	g_Input.Init();

    // Initialise vectors
    s_left      =  CIwVec3::g_AxisX;
    s_up        = -CIwVec3::g_AxisY;
    s_Angles = CIwSVec3::g_Zero;
    s_cameraPos =  CIwVec3(0, 0, -0x80);

    // Initialise view matrix
    s_viewMatrix = CIwMat::g_Identity;

    s_viewMatrix.SetTrans(s_cameraPos);
    s_viewMatrix.LookAt(
        s_viewMatrix.GetTrans(),
         CIwVec3::g_Zero,
        -CIwVec3::g_AxisY);

	// Initialise
    IwGxInit();
	IwResManagerInit();
    // Set screen clear colour
    IwGxSetColClear(0x40, 0x40, 0x40, 0x00);

    // Turn all lighting off
    IwGxLightingOff();

    // Set field of view
    IwGxSetPerspMul(0xa0);

    // Set near and far planes
    IwGxSetFarZNearZ(0x1000, 0x10);

    // Create empty texture object
    s_BitMapTexture = new CIwTexture;

    // Load image data from disk into texture
    s_BitMapTexture->LoadFromFile("./textures/testTexture_8bit.bmp");

    // "Upload" texture to VRAM
    s_BitMapTexture->Upload();


    // Set the view matrix along the -ve z axis
    CIwMat view = CIwMat::g_Identity;
    view.t.z = -0x100;
    IwGxSetViewMatrix(&view);
	IwGetResManager()->LoadGroup("TileRes.group"); 
	pGroup = IwGetResManager()->GetGroupNamed("TileRes");
	hexGrid = new HexGrid(hexGridMaxX, hexGridMaxY, textureMaxX, textureMaxY);
	hexGrid->setTexture(IW_TEXTURE(pGroup,"grid"),textureMaxX,textureMaxY);
	s_ModelMatrix.SetIdentity();
}
コード例 #5
0
EggDropGameEngine::EggDropGameEngine()
{
	g_pLogoTexture = (CIwTexture*)IwGetResManager()->GetResNamed("eggdrop", "CIwTexture");
	g_pEgg = (CIwTexture*)IwGetResManager()->GetResNamed("egg", "CIwTexture");
	g_pSpoon = (CIwTexture*)IwGetResManager()->GetResNamed("spoon", "CIwTexture");
	g_pCrackedEgg = (CIwTexture*)IwGetResManager()->GetResNamed("crackedegg", "CIwTexture");
	g_pGrass = (CIwTexture*)IwGetResManager()->GetResNamed("grass", "CIwTexture");
}
コード例 #6
0
FindTheSpotGameEngine::FindTheSpotGameEngine()
{
	g_pLogoTexture = (CIwTexture*)IwGetResManager()->GetResNamed("findthespot", "CIwTexture");
	g_pHotterTexture = (CIwTexture*)IwGetResManager()->GetResNamed("hotter", "CIwTexture");
	g_pColderTexture = (CIwTexture*)IwGetResManager()->GetResNamed("colder", "CIwTexture");
	g_pFoundTexture = (CIwTexture*)IwGetResManager()->GetResNamed("found", "CIwTexture");
	g_pCursorTexture = (CIwTexture*)IwGetResManager()->GetResNamed("cursor", "CIwTexture");
	g_pTile = NULL;
}
コード例 #7
0
void ResourceManager::init() {
	IwSoundInit();
	IwResManagerInit();
#ifdef IW_BUILD_RESOURCES
	IwGetResManager()->AddHandler(new CIwResHandlerWAV);
#endif
	IwGetResManager()->LoadGroup("sounds.group");
	imgs = new map<string, SImg>();
	sounds = new map<int, Sound>();
}
コード例 #8
0
void IGScene::unloadResources() {
	// unload all resource groups
	int numGroups = IwGetResManager()->GetNumGroups();
	for(int i=0; i<numGroups; i++) {
		CIwResGroup* group = IwGetResManager()->GetGroup(i); 
		IwGetResManager()->DestroyGroup(group);
	}

	// delete resources in memory
	IGResourceManager::getInstance()->freeAllResources();
}
コード例 #9
0
ファイル: CameraView.cpp プロジェクト: Mikuz/Ghost-Realm
void LoadViking() {
	IwGetResManager()->LoadGroup("viking/viking.group");
	CIwResGroup* pGroup = IwGetResManager()->GetGroupNamed("viking");

	ghostStore_Model[0] = (CIwModel*)pGroup->GetResNamed("viking", IW_GRAPHICS_RESTYPE_MODEL);
	ghostStoreCollision[0] = (GhostCollision*)pGroup->GetResNamed("viking", "GhostCollision");
	ghostStore_Skin[0]  = (CIwAnimSkin*)pGroup->GetResNamed("viking", IW_ANIM_RESTYPE_SKIN);
	ghostStore_Skel[0]  = (CIwAnimSkel*)pGroup->GetResNamed("Armature", IW_ANIM_RESTYPE_SKELETON);
	ghostStore_Anims[0][GHOST_ANIM_IDLE]  = (CIwAnim*)pGroup->GetResNamed("Armature_idle", IW_ANIM_RESTYPE_ANIMATION);
	ghostStore_Anims[0][GHOST_ANIM_AGRO]  = (CIwAnim*)pGroup->GetResNamed("Armature_agro", IW_ANIM_RESTYPE_ANIMATION);
	ghostStore_Anims[0][GHOST_ANIM_DODGE]  = (CIwAnim*)pGroup->GetResNamed("Armature_dodge", IW_ANIM_RESTYPE_ANIMATION);
	ghostStore_Anims[0][GHOST_ANIM_ATTACK]  = (CIwAnim*)pGroup->GetResNamed("Armature_attack", IW_ANIM_RESTYPE_ANIMATION);
	ghostStore_Anims[0][GHOST_ANIM_CAPTURED]  = (CIwAnim*)pGroup->GetResNamed("Armature_captured", IW_ANIM_RESTYPE_ANIMATION);
}
コード例 #10
0
CaptureGameEngine::CaptureGameEngine()
{
	g_pLogoTexture = (CIwTexture*)IwGetResManager()->GetResNamed("Capture", "CIwTexture");
	g_pUserTexture = (CIwTexture*)IwGetResManager()->GetResNamed("user", "CIwTexture");
	g_pCursorTexture = (CIwTexture*)IwGetResManager()->GetResNamed("cursor", "CIwTexture");
	
	for (int i = 0; i < 3; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			g_pTiles[i][j] = NULL;
		}
	}
}
コード例 #11
0
ファイル: CameraView.cpp プロジェクト: Mikuz/Ghost-Realm
void LoadSkelman() {
	IwGetResManager()->LoadGroup("Skelman/Skelman.group");
	CIwResGroup* pGroup = IwGetResManager()->GetGroupNamed("Skelman");

	ghostStore_Model[1] = (CIwModel*)pGroup->GetResNamed("GEO_For_Export", IW_GRAPHICS_RESTYPE_MODEL);
	ghostStoreCollision[1] = (GhostCollision*)pGroup->GetResNamed("GEO_For_Export", "GhostCollision");
	ghostStore_Skin[1]  = (CIwAnimSkin*)pGroup->GetResNamed("GEO_For_Export", IW_ANIM_RESTYPE_SKIN);
	ghostStore_Skel[1]  = (CIwAnimSkel*)pGroup->GetResNamed("HIP01", IW_ANIM_RESTYPE_SKELETON);
	ghostStore_Anims[1][GHOST_ANIM_IDLE]  = (CIwAnim*)pGroup->GetResNamed("Skelman_Idle", IW_ANIM_RESTYPE_ANIMATION);
	ghostStore_Anims[1][GHOST_ANIM_AGRO]  = (CIwAnim*)pGroup->GetResNamed("Skelman_Idle", IW_ANIM_RESTYPE_ANIMATION);
	ghostStore_Anims[1][GHOST_ANIM_DODGE]  = (CIwAnim*)pGroup->GetResNamed("Skelman_Miss", IW_ANIM_RESTYPE_ANIMATION);
	ghostStore_Anims[1][GHOST_ANIM_ATTACK]  = (CIwAnim*)pGroup->GetResNamed("Skelman_Attack", IW_ANIM_RESTYPE_ANIMATION);
	ghostStore_Anims[1][GHOST_ANIM_CAPTURED]  = (CIwAnim*)pGroup->GetResNamed("Skelman_Death", IW_ANIM_RESTYPE_ANIMATION);
}
コード例 #12
0
ResourceManager::~ResourceManager()
{
    uint32 index;

    for(index = 0; index < images->size(); index++)
    {
        delete images->at(index);
    }

    for(index = 0; index < fonts->size(); index++)
    {
        delete fonts->at(index);
    }

    for(index = 0; index < audioData->size(); index++)
    {
        s3eFreeBase(audioData->at(index));
    }

    for(index = 0; index < groups->size(); index++)
    {
        IwGetResManager()->DestroyGroup(groups->at(index));
    }

    delete groups;
    delete images;
    delete fonts;
    delete audioSizes;
    delete audioData;
    delete texts;
}
コード例 #13
0
// achievements scene
SceneAchievements::SceneAchievements() : IGScene()
{
	IGLog("SceneAchievements init");
	
	// load the resources
	IwGetResManager()->LoadGroup("achievements.group");
	
	// the background
	IGSprite* spriteBackground = new IGSprite("background_wood", IGPoint(160,240), 0);
	this->addChild(spriteBackground);

	// header
	IGSprite* spriteHeader = new IGSprite("achievements_header", IGPoint(160,41), 1);
	this->addChild(spriteHeader);

	// the menu items
	buttonBack = new AchievementsButtonBack();
	buttonBack->setOpacity(64);
	AchievementsButtonMenu* buttonMenu = new AchievementsButtonMenu();
	buttonNext = new AchievementsButtonNext();
	this->addChild(buttonBack);
	this->addChild(buttonMenu);
	this->addChild(buttonNext);

	// pages
	pageNumber = 0;
	numPages = (int)(ACHIEVEMENT_NUM / 5);
	if(ACHIEVEMENT_NUM % 5 > 0)
		numPages++;

	// display achievements
	updateAchievements();
}
コード例 #14
0
bool CIwGameImage::Load(bool blocking)
{
	// If already loaded return true
	if (Image2D != NULL || Texture != NULL)
		return true;

	// Image is file based
	if (File != NULL)
	{
		File->setFileAvailableCallback(CIwGameImage_FileRetrievedAsyncCallback, this);
		if (File->Open(NULL, "rb", blocking))
			return true;
		else
			return false;
	}

	if (ResourceGroup != NULL)
	{
		// Create image from the resource group
		IwGetResManager()->SetCurrentGroup(ResourceGroup);
		Image2D = Iw2DCreateImageResource(NameHash);
		if (Image2D != NULL)
		{
			Width = Image2D->GetWidth();
			Height = Image2D->GetHeight();
			State = State_Loaded;
			return true;
		}
	}

	return false;
}
コード例 #15
0
void CIwGameAudio::Init()
{
	// initialise IwSound
	IwSoundInit();

	// Turn music and sound on
	SoundOn = true;
	MusicOn = true;
	SoundVolume = 1.0f;
	MusicVolume = 1.0f;

	// Used to convert our WAV's located in the resource group files
#ifdef IW_BUILD_RESOURCES
	IwGetResManager()->AddHandler(new CIwResHandlerWAV);
#endif

	// Mark audio as available
	Available = true;
//	Available = false;

	// Set default music codec to MP3
	MusicCodec = S3E_AUDIO_CODEC_MP3;

	// Create a sound collection
	SoundCollection = new CIwGameSoundCollection();
}
コード例 #16
0
ファイル: brixpath.cpp プロジェクト: codemanki/brixpath
void Brixpath::init()
{
    //Init system stuff
    Iw2DInit();
    IwResManagerInit();
    IwGxFontInit();
    
    //read resources
    IwGetResManager()->LoadGroup("brixpath.group");
    _backgroundImage = Iw2DCreateImageResource("3px");
    
	// Initialize evil classes
	g_Input.Init();
    g_ColorManager.initialize();
    g_FontManager.initialize();
    g_GameStateManager.initialize();
    
    //Load leveles
    g_LevelsManager.initializeFromFile("test.json");
    
    
    _gameStateData.gameLevel = 0;
    _gameStateData.currentScene = MAIN_MENU_SCENE;
    _gameStateData.switchToScene = MAIN_MENU_SCENE;
    
    //levels should be initialize only after Iw2d and similar stuff is initialized;
    _sceneManager = new ScenesManager(&_gameStateData);
    
    _scene = _sceneManager->getActiveScene();
    
    //and start drawing scene
    _scene->capture();
};
コード例 #17
0
// leadersboard scene
SceneLeadersboard::SceneLeadersboard() : IGScene()
{
	IGLog("SceneLeadersboard init");
	
	// load the resources
	IwGetResManager()->LoadGroup("leadersboard.group");
	
	// the background
	IGSprite* spriteBackground = new IGSprite("background_wood", IGPoint(160,240), 0);
	this->addChild(spriteBackground);

	// header
	IGSprite* spriteHeader = new IGSprite("leadersboard_header", IGPoint(160,41), 1);
	this->addChild(spriteHeader);

	// the menu items
	buttonBack = new LeadersboardButtonBack();
	buttonBack->setOpacity(64);
	LeadersboardButtonMenu* buttonMenu = new LeadersboardButtonMenu();
	buttonNext = new LeadersboardButtonNext();
	this->addChild(buttonBack);
	this->addChild(buttonMenu);
	this->addChild(buttonNext);

	// pages
	pageNumber = 0;
	numPages = (int)(LEADERSBOARD_NUM / 5);
	if(LEADERSBOARD_NUM % 5 > 0)
		numPages++;

	// display leadersboard
	updateLeadersboard();
}
コード例 #18
0
//-----------------------------------------------------------------------------
void ExampleInit()
{
    // Startapp:
	if (s3eDeviceGetInt(S3E_DEVICE_OS) == S3E_OS_ID_ANDROID)
	{
		if(startappAvailable())
		{
			initSDK(STARTAPP_DEVID, STARTAPP_APPID); 
		}
	}
	
	//Initialise the IwUI module
    IwUIInit();

    //Instantiate the view and controller singletons.
    //IwUI will not instantiate these itself, since they can be subclassed to add functionality.
    new CIwUIController;
    new CIwUIView;

    //Load group which contains the ui specifications
    IwGetResManager()->LoadGroup("IwUIBasicButtonEvents.group");

    //Load button
    s_Button = (CIwUIButton*) CIwUIElement::CreateFromResource("EventButton");

    //Attach eventhandler to button
    s_Button->AddEventHandler(new MyButtonEventHandler);

    //Add the label to the UIView singleton
    IwGetUIView()->AddElement(s_Button);
}
コード例 #19
0
//-----------------------------------------------------------------------------
// Parse an attribute from an ITX file
//-----------------------------------------------------------------------------
bool GUIElement::ParseAttribute( CIwTextParserITX* apParser, const char* apAttrName )
{
#ifdef IW_BUILD_RESOURCES
	IW_CALLSTACK( "GUIElement::ParseAttribute" );

	if( !strcmp( apAttrName, "bounds" ) )
	{
		m_Bounds.Parse( apParser );
	}
	else if( !strcmp( apAttrName, "addTemplate" ) )
	{
		CIwStringS lTemplateName;
		apParser->ReadString( lTemplateName );
		GUITemplate* lpTemplate = reinterpret_cast<GUITemplate*>( IwGetResManager()->GetResNamed( lTemplateName.c_str(), RESTYPE_GUITEMPLATE ) );
		IwAssertMsg( GUI, lpTemplate, ( "Unable to locate GUITemplate called %s", lTemplateName.c_str() ) );
		lpTemplate->CloneTemplateChildren( this );
	}
	else if( !strcmp( apAttrName, "useTemplate" ) )
	{
		CIwStringS lTemplateName;
		apParser->ReadString( lTemplateName );
		GUITemplate* lpTemplate = reinterpret_cast<GUITemplate*>( IwGetResManager()->GetResNamed(lTemplateName.c_str(), RESTYPE_GUITEMPLATE ) );
		IwAssertMsg( GUI, lpTemplate, ( "Unable to locate GUITemplate called %s", lTemplateName.c_str() ) );
		lpTemplate->CloneTemplate( this );
	}
	else if( !strcmp( apAttrName, "debug" ) )
	{
		SetFlags( GF_DEBUG );
	}
	else if( !strcmp( apAttrName, "enable" ) )
	{
		apParser->ReadBool( &m_Enabled );
	}
	else if( !strcmp( apAttrName, "offset" ) )
	{
		m_Offset.Parse( apParser );
	}
	else if( !strcmp( apAttrName, "touchable" ) )
	{
		SetFlags( GF_TOUCHABLE );
	}
	else
		return CIwResource::ParseAttribute( apParser, apAttrName );
#endif
	return true;
}
コード例 #20
0
void IntroState::Destroy()
{
	IwGetResManager()->DestroyGroup("Intro");
	delete m_TransManager;
	delete m_Splash1;
	delete m_Splash2;
	
	printf("IntroState Destroyed\n");
}
コード例 #21
0
//-----------------------------------------------------------------------------
// Finished parsing the object
//-----------------------------------------------------------------------------
void GUIColour::ParseClose( CIwTextParserITX* apParser )
{
#ifdef IW_BUILD_RESOURCES
	IW_CALLSTACK( "GUIColour::ParseClose" );

	// Top level object, add to resource manager
	IwGetResManager()->AddRes( RESTYPE_GUICOLOUR, this );
#endif
}
コード例 #22
0
ファイル: HexMapTest.cpp プロジェクト: ralphtrickey/Hex-Map
//-----------------------------------------------------------------------------
void HexMapTest::ShutDown() {
    // Destroy texture
    delete s_BitMapTexture;

	// Terminate
	delete hexGrid;
	IwGetResManager()->DestroyGroup(pGroup);
	IwResManagerTerminate();
    IwGxTerminate();
}
コード例 #23
0
ファイル: EndGameState.cpp プロジェクト: Lordarnon/kartz
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
}
コード例 #24
0
void Game::Init()
{
	IwGxInit();
	IwGraphicsInit();

	IwResManagerInit();

#ifdef IW_BUILD_RESOURCES
	IwGetTextParserITX()->SetAssertOnUnrecognisedTokens( false );
	IwGetResManager()->AddHandler( new CIwResHandlerWAV );
#endif

	IW_CLASS_REGISTER( Collision );
	IW_CLASS_REGISTER( CStatic );
	IW_CLASS_REGISTER( CDynamic );
	IW_CLASS_REGISTER( CLocator );

	IwGxSetColClear( 0x40, 0x40, 0x40, 0x00 );

	LocaliseInit();

	m_font = FontManager::GetInstance();

	m_menuManager = MenuManager::GetInstance();

	m_touchManager = TouchManager::GetInstance();
	m_touchManager->Init();

	m_accelerometerManager = AccelerometerManager::GetInstance();
	m_accelerometerManager->Init();

	m_webManager = WebManager::GetInstance();
	m_webManager->Init();

	m_config = Config::GetInstance();
	m_config->Init();

	m_soundManager = SoundManager::GetInstance();
	m_soundManager->Init();

	m_scriptManager = ScriptManager::GetInstance();
	m_scriptManager->Init();

	m_shaderManager = ShaderManager::GetInstance();
	m_shaderManager->Init();

	m_postProcessing = PostProcessing::GetInstance();
	m_postProcessing->Init();

	GameState::InitStatesStack();
	GameState::SetState( new GS_Loading() );
}
コード例 #25
0
MapBackground::MapBackground()
{
	g_tempZoom = g_newZoom = g_actualZoom = g_curZoom = 17;// - 1;

	if (NULL == g_pNotFoundTexture)
	{
		g_pNotFoundTexture = (CIwTexture*)IwGetResManager()->GetResNamed("notfound", IW_GX_RESTYPE_TEXTURE);
	}
	if (NULL == g_pLoadingTexture)
	{
		g_pLoadingTexture = (CIwTexture*)IwGetResManager()->GetResNamed("loading", IW_GX_RESTYPE_TEXTURE);
	}
	g_bMouseDown = false;
	g_bLocationChanged = false;
	g_dAlpha = 0xFF;

	if (s3ePointerGetInt(S3E_POINTER_MULTI_TOUCH_AVAILABLE))
    {
        //Register for multi touch events on platforms where the functionality is available.
        s3ePointerRegister(S3E_POINTER_TOUCH_EVENT, (s3eCallback)MultiTouchButtonCB, NULL);
        s3ePointerRegister(S3E_POINTER_TOUCH_MOTION_EVENT, (s3eCallback)MultiTouchMotionCB, NULL);
    }
}
コード例 #26
0
void IntroState::Init()
{
	IwGetResManager()->LoadGroup("introsprites.group");

	m_Splash1 = new Sprite("logo", false);
	m_Splash2 = new Sprite("splash2", false);

	m_TransManager = new TransitionManager();
	m_TransitionState = FADE_IN;

	if (s3eAudioIsCodecSupported(S3E_AUDIO_CODEC_MP3))
		s3eAudioPlay("music.mp3", 1);

	printf("IntroState initialized\n");
}
コード例 #27
0
ファイル: CLevel.cpp プロジェクト: marmalade/project-ball
void CLevel::BuildCollision(const char* pUserString, CIwModel* pModel)
{
	//check user string to test whether to affect this asset
	/*if( strcmp(pUserString, "level") != 0 )
		return*/;
	
	// Create a new collision resource and name it after its model partner
	CCollision* pCollision = new CCollision;
	pCollision->SetName(pModel->DebugGetName());

	for(uint32 i = 0; i < IwGetModelBuilder()->GetNumFaces(); i++)
	{
		pCollision->AddFace(IwGetModelBuilder()->GetFace(i), pModel);
	}

	// Add the collision resource to IwResManager - it will be serialised as part of the current group.
	IwGetResManager()->AddRes("CCollision", pCollision);
}
コード例 #28
0
// scene game menu
SceneGameMenu::SceneGameMenu() : IGScene()
{
	IGLog("SceneGameMenu init");
	errorUp = false;

	// load the resources
	IwGetResManager()->LoadGroup("game_menu.group");

	// the background
	IGSprite* spriteBackground = new IGSprite("background_forest_light", IGPoint(160,240), 0);
	this->addChild(spriteBackground);

	// header
	IGSprite* spriteHeader = new IGSprite("game_menu_header", IGPoint(160,60), 1);
	this->addChild(spriteHeader);

	// the menu items
	GameMenuButtonResume* buttonResume = new GameMenuButtonResume();
	GameMenuButtonRestart* buttonRestart = new GameMenuButtonRestart();
	GameMenuButtonNext* buttonNext = new GameMenuButtonNext();
	GameMenuButtonOptions* buttonOptions = new GameMenuButtonOptions();
	GameMenuButtonAbandon* buttonAbandon = new GameMenuButtonAbandon();
	this->addChild(buttonResume);
	this->addChild(buttonRestart);
	this->addChild(buttonNext);
	this->addChild(buttonOptions);
	this->addChild(buttonAbandon);

	// game info
	IGSprite* spriteInfoBackground = new IGSprite("game_menu_info_background", IGPoint(160,145), 2);
	this->addChild(spriteInfoBackground);
	char buffer1[50];
	char buffer2[100];
	switch(GameData::getInstance()->stage) {
		case GameStageForest: sprintf(buffer1, "Forest"); break;
		case GameStageCaves: sprintf(buffer1, "Caves"); break;
		case GameStageBeach: sprintf(buffer1, "Beach"); break;
		case GameStageShip: sprintf(buffer1, "Pirate Ship"); break;
	}
	sprintf(buffer2, "%s * Level: %i", buffer1, GameData::getInstance()->level);
	IGLabel* labelInfo = new IGLabel("font_algerian_16", std::string(buffer2), IGPoint(160,145), IGRect(300,50), 3);
	labelInfo->setColor(147,213,18,255);
	this->addChild(labelInfo);
}
コード例 #29
0
ファイル: Iw2DSprite.cpp プロジェクト: marmalade/iw2dsprite
bool Iw2DSprite::LoadFromResource(CIwResGroup* pGroup, std::string pName, bool pDataFromFile)
{
	bool sameName = ( pName.compare(m_ResourceName) > 0 ) ? true : false;
	bool emptyName = m_ResourceName.empty();
	if( !sameName || m_ResourceGroup != pGroup || !m_Built || ( !emptyName && !m_ResourceGroup) )
	{
		m_ResourceGroup = pGroup;
		m_ResourceName = pName;
		m_Built = false;

		IwGetResManager()->SetCurrentGroup(m_ResourceGroup);
		
		if( m_ResourceGroup->GetResNamed(m_ResourceName.c_str(),IW_GX_RESTYPE_TEXTURE) )
		{				
			m_Built = true;

			if(pDataFromFile)
			{
				std::string w,h,f;
				w = m_ResourceName + "_w" ;
				h = m_ResourceName + "_h" ;
				f = m_ResourceName + "_frames" ;
	
				int temp;
				s3eConfigGetInt("Sprites",w.c_str(),&temp);
				m_FrameSize.x = temp;
				s3eConfigGetInt("Sprites",h.c_str(),&temp);
				m_FrameSize.y = temp;
				s3eConfigGetInt("Sprites",f.c_str(),&temp);	
				m_MaxFrames = temp;
			}

			m_SpriteSheet = Iw2DCreateImageResource(m_ResourceName.c_str()); 

			m_Frames.x = m_SpriteSheet->GetWidth() / m_FrameSize.x;
			m_Frames.y = m_SpriteSheet->GetHeight() / m_FrameSize.y;	
			m_Center.x = m_FrameSize.x / 2;
			m_Center.y = m_FrameSize.y / 2;
			m_Angle = 0;
			m_Flip = CIwSVec2::g_Zero;
		}		
	}
	return m_Built;
}
コード例 #30
0
ファイル: resources.cpp プロジェクト: constZinovyev/Swiper
Resources::Resources(){
    Blocks[0] = Iw2DCreateImage("textures/EmptyBlock.png");
    Blocks[1] = Iw2DCreateImage("textures/Object 1.png");
    Blocks[2] = Iw2DCreateImage("textures/Object 2.png");
    Blocks[3] = Iw2DCreateImage("textures/Object 3.png");
    BGiPhone4 = Iw2DCreateImage("textures/backiPhone4.png");
    imgBlocks[0]= Iw2DCreateImage("textures/anim12.png");
    imgBlocks[1]= Iw2DCreateImage("textures/anim13.png");
    imgBlocks[2]= Iw2DCreateImage("textures/anim21.png");
    imgBlocks[3]= Iw2DCreateImage("textures/anim23.png");
    imgBlocks[4]= Iw2DCreateImage("textures/anim31.png");
    imgBlocks[5]= Iw2DCreateImage("textures/anim32.png");
    emtBlock = Iw2DCreateImage("textures/EmptyBlock.png");
    imgButtonStart = Iw2DCreateImage("textures/buttonStart.png");
    MenuBG = Iw2DCreateImage("textures/Swiperbackground.png");
    Retry = Iw2DCreateImage("textures/Retry.png");
    Info = Iw2DCreateImage("textures/Info.png");
    //lightToMiddle = Iw2DCreateImage("textures/B-D.png");
    //middleToLight = Iw2DCreateImage("textures/D-B.png");
    backAfterDie = Iw2DCreateImage("textures/BackAfterDie.png");
    Font = (CIwGxFont*)IwGetResManager()->GetResNamed("SansusWR", "CIwGxFont");
    int frame_w = (int)(imgBlocks[0]->GetWidth() / 20.0);
    int frame_h = (int)(imgBlocks[0]->GetHeight()/1);
    for (int i = 0; i < 6; ++i){
        animBetweenBlocks[i] = new CAtlas(frame_w,frame_h,20,imgBlocks[i]);
    }
    
    emptyBlock = new CAtlas(emtBlock->GetWidth(),emtBlock->GetHeight(),1,emtBlock);
    //animLightToMiddle = new CAtlas(frame_w, frame_h, 20, lightToMiddle);
    //frame_w = (int)(middleToLight->GetWidth() / 20.0);
    //frame_h = (int)(middleToLight->GetHeight()/1);
    //animMiddleToLight = new CAtlas(frame_w, frame_h, 20, middleToLight);
    /*// Create atlases
    int frame_w = (int)(Gems[0]->GetWidth() / 5);
    int frame_h = (int)(Gems[0]->GetHeight() / 3);
    for (int t = 0; t < MAX_GEM_TYPES; t++)
        GemAtlases[t] = new CAtlas(frame_w, frame_h, 15, Gems[t]);
    frame_w = (int)(Explosion->GetWidth() / 5);
    frame_h = (int)(Explosion->GetHeight() / 3);
    ExplosionAtlas = new CAtlas(frame_w, frame_h, 15, Explosion);
     */
}