Exemple #1
0
/*
	Name		Game::deinitialise
	Syntax		Game::deinitialise()
	Brief		Releases any resources used by the game
*/
void Game::deinitialise()
{
	if (currentState_)
	{
		currentState_->deinitialise();
		delete currentState_;
		currentState_ = NULL;
	}

	if (input_)
	{
		input_->deinitialise();
		delete input_;
		input_ = NULL;
	}

	dzArchiveDetach();

	// shut down the IwResManager resource manager
	IwResManagerTerminate();

	// Shut down the Iw2D drawing module
	Iw2DTerminate();
	
	// Shut down the IwGx drawing module
    IwGxTerminate();
	
}
int main()
{
	IwGxInit();
	IwGxSetColClear(0, 0, 0xff, 0xff);
	IwResManagerInit();
	Iw2DInit();
	setupTextures();
	registerInput();

    const int textWidth = s3eDebugGetInt(S3E_DEBUG_FONT_SIZE_WIDTH);
    const int textHeight = s3eDebugGetInt(S3E_DEBUG_FONT_SIZE_HEIGHT);
    const int width = s3eSurfaceGetInt(S3E_SURFACE_WIDTH);
    const int height = s3eSurfaceGetInt(S3E_SURFACE_HEIGHT);

	sprintf(g_debugButtonEvent, "ButtonEvent:");
	sprintf(g_debugKeyEvent, "KeyEvent:");
	sprintf(g_debugMotionEvent, "MotionEvent:");
	sprintf(g_debugTouchEvent, "TouchEvent:");
	sprintf(g_debugTouchMotionEvent, "TouchMotionEvent:");

	while (!s3eDeviceCheckQuitRequest())
	{
		render();

		// Yield until unyield is called or a quit request is recieved
        s3eDeviceYield(S3E_DEVICE_YIELD_FOREVER);
	}
	destroyTextures();
	Iw2DTerminate();
	IwResManagerTerminate();
	IwGxTerminate();
	return 0;
}
Exemple #3
0
void ShutDown()
{
    delete gEffects;
    delete gPM;

    IwGxTerminate();
}
Exemple #4
0
//-----------------------------------------------------------------------------
// Main global function
//-----------------------------------------------------------------------------
int main()
{
#ifdef EXAMPLE_DEBUG_ONLY
    // Test for Debug only examples
#ifndef IW_DEBUG
    DisplayMessage("This example is designed to run from a Debug build. Please build the example in Debug mode and run it again.");
    return 0;
#endif
#endif

    //IwGx can be initialised in a number of different configurations to help the linker eliminate unused code.
    //Normally, using IwGxInit() is sufficient.
    //To only include some configurations, see the documentation for IwGxInit_Base(), IwGxInit_GLRender() etc.
    IwGxInit();

    // Example main loop
    ExampleInit();

    // Set screen clear colour
    IwGxSetColClear(0xff, 0xff, 0xff, 0xff);
    IwGxPrintSetColour(128, 128, 128);
    
    while (1)
    {
        s3eDeviceYield(0);
        s3eKeyboardUpdate();
        s3ePointerUpdate();

        int64 start = s3eTimerGetMs();

        bool result = ExampleUpdate();
        if  (
            (result == false) ||
            (s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_DOWN) ||
            (s3eKeyboardGetState(s3eKeyAbsBSK) & S3E_KEY_STATE_DOWN) ||
            (s3eDeviceCheckQuitRequest())
            )
            break;

        // Clear the screen
        IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F);
        RenderButtons();
        RenderSoftkeys();
        ExampleRender();

        // Attempt frame rate
        while ((s3eTimerGetMs() - start) < MS_PER_FRAME)
        {
            int32 yield = (int32) (MS_PER_FRAME - (s3eTimerGetMs() - start));
            if (yield<0)
                break;
            s3eDeviceYield(yield);
        }
    }
    ExampleShutDown();
    DeleteButtons();
    IwGxTerminate();
    return 0;
}
Exemple #5
0
void N2F::Iw3D::Iw2DHelper::Clean()
{
	IwGxFontTerminate();
	Iw2DTerminate();
	IwGxTerminate();

	return;
}
Exemple #6
0
int main()
{
	IwGxInit();
	Iw2DInit();

	AppWarp::Client* WarpClientRef;
	AppWarp::Client::initialize("b29f4030aba3b2bc7002c4eae6815a4130c862c386e43ae2a0a092b27de1c5af","bf45f27e826039754f8dda659166d59ffb7b9dce830ac51d6e6b576ae4b26f7e");
	WarpClientRef = AppWarp::Client::getInstance();

	MenuScreen *menu = new MenuScreen;
	GameScreen *game = new GameScreen(WarpClientRef);

	Game *gm = new Game;
	gm->AddScene("game",game);
	gm->AddScene("menu",menu);

	menu->game = game;
	menu->app = gm;

	Listener listener(WarpClientRef,game);
	WarpClientRef->setConnectionRequestListener(&listener);
	WarpClientRef->setRoomRequestListener(&listener);
	WarpClientRef->setNotificationListener(&listener);

	s3ePointerRegister(S3E_POINTER_BUTTON_EVENT,(s3eCallback)HandleSingleTouchButtonCB,gm);

	while(!s3eDeviceCheckQuitRequest())
	{
		s3eKeyboardUpdate();
		if(s3eKeyboardGetState(s3eKeyAbsBSK) & S3E_KEY_STATE_DOWN)
			break;

		WarpClientRef->update();
		s3ePointerUpdate();
		IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F);

		IwGxPrintSetScale(2);
		IwGxPrintString(0,0,game->msg.c_str());

		gm->Move();
		gm->Render();

		Iw2DSurfaceShow();
		s3eDeviceYield();
	}

	s3ePointerUnRegister(S3E_POINTER_BUTTON_EVENT,(s3eCallback)HandleSingleTouchButtonCB);

	gm->CleanUp();
	delete menu;
	delete game;
	delete gm;

	WarpClientRef->terminate();

	Iw2DTerminate();
	IwGxTerminate();
}
Exemple #7
0
int main()
{
	
	//s3eInetAddress addr;
	//memset(&addr, 0, sizeof(addr));
	//s3eInetLookup("localhost", &addr, NULL, NULL);
	//addr.m_Port = s3eInetHtons(81);

	//s3eSocket* pSock = s3eSocketCreate(S3E_SOCKET_UDP, 0);
	//char szData[20000];
	//for (int i=0; i <20000;++i)
	//{
	//	szData[i] = i;
	//}
	//while (true)
	//{
	//	int sent = s3eSocketSendTo(pSock, szData, 20000, 0, &addr);
	//	s3eDeviceYield(0);
	//}

	s3eLocationStart();

	//IwGx can be initialised in a number of different configurations to help the linker eliminate unused code.
	//For the examples we link in all of IwGx's possible functionality.
	//You can see the code size reduce if you remove any of the IwGxInit calls following IwGxInit_Base.
	//Note that, for demonstration purposes, some examples call IwGxInit() themselves - this will link in the 
	//standard renderer and the GL renderer, so on those examples these features cannot be excluded from the build.
	//IwGxInit_Base();
	//IwGxInit_GLRender();
	IwGxInit();

	Iw2DInit();
	IwUIInit();

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

	IwDebugTraceLinePrintf("Creating Game Object");
	FireflyGameEngine* pGameEngine = new FireflyGameEngine;
	IwDebugTraceLinePrintf("Entering Main");
	int result = GameMain(pGameEngine);
	delete pGameEngine;

	Iw2DTerminate();
	
	delete IwGetUIView();
	delete pController;
	IwUITerminate();
	IwGxTerminate();
	s3eLocationStop();


	return result;
}
Exemple #8
0
//-----------------------------------------------------------------------------
void HexMapTest::ShutDown() {
    // Destroy texture
    delete s_BitMapTexture;

	// Terminate
	delete hexGrid;
	IwGetResManager()->DestroyGroup(pGroup);
	IwResManagerTerminate();
    IwGxTerminate();
}
Exemple #9
0
int main() {
    
	IwGxInit();
	IwResManagerInit();
 
	doMain();
	
	IwResManagerTerminate();
	IwGxTerminate();
		
	return 0;
}
// Example showing how to use the s3eWwise extension
int main()
{
    IW_CALLSTACK("main");

    s3eDebugOutputString("Booting s3eWwise example");

    initWwise();

    s3ePointerRegister(S3E_POINTER_BUTTON_EVENT, (s3eCallback)buttonEvent, NULL);
    s3ePointerRegister(S3E_POINTER_MOTION_EVENT, (s3eCallback)motionEvent, NULL);

    IwGxInit();

    IwGxSetColClear(0, 0, 0, 0xff);

    while(!s3eDeviceCheckQuitRequest())
    {
        std::stringstream str;

        s3eWwiseSoundEngineRenderAudio();

        IwGxClear();

        IwGxPrintString(100, 100, "s3eWwise");

        IwGxPrintString(100, 300, "Touch to fire event");

        str << "RPM = " << rpm;
        IwGxPrintString(100, 400, str.str().c_str());
        str.str(std::string());

        str << "TH = " << touchHeight;
        IwGxPrintString(100, 500, str.str().c_str());
        str.str(std::string());

        str << "Height = " << height;
        IwGxPrintString(100, 600, str.str().c_str());
        str.str(std::string());

        IwGxFlush();
        IwGxSwapBuffers();
        s3eDeviceYield(0);
    }

    IwGxTerminate();

    s3ePointerUnRegister(S3E_POINTER_BUTTON_EVENT, (s3eCallback)buttonEvent);
    s3ePointerUnRegister(S3E_POINTER_MOTION_EVENT, (s3eCallback)motionEvent);

    shutdownWwise();

    return 0;
}
Exemple #11
0
//-----------------------------------------------------------------------------
// Main global function
//-----------------------------------------------------------------------------
int main()
{
    IwGxInit();
	Iw2DInit();
	//SplashInit();
	//SplashRender();
	srand(time(NULL));
	g_Input.Init();
	LifeStatusInit();
	FontInit();
	//MenuInit();
	FondoInit();
    BaconInit();
	MusicInit("./textures/musicOn.jpg");
	while (menuB)
	{
		menuB = false;
		menu();
	}
	spriteManager->removeSprite(corazon);
	delete corazon;
	for (int i=0; i<10; i++)
	{
		spriteManager->removeSprite(garras[i]);
		delete garras[i];
		spriteManager->removeSprite(tnts[i]);
		delete tnts[i];
	}
	for (int i=0; i<20; i++)
	{
		spriteManager->removeSprite(miniCoins[i]);
		delete miniCoins[i];
	}
	delete tank;
	spriteManager->removeSprite(maxiCoin);
	delete maxiCoin;
	delete chuletas;

	g_Input.Release();
	FondoShutDown();
    BaconShutDown();
	FontShutDown();
	SplashShutDown();
	LifeStatusShutDown();
	IwGxFontTerminate();
    IwGxTerminate();
	Iw2DTerminate();
	s3eDeviceExit();
    return 0;
}
void ExamplesMainTerm()
{
    TerminateMessages();

    // User code term
    ExampleTerm();

    delete g_CursorMaterial;
    DeleteButtons();

    //TODO: Switch to IwGx font so we can both measure the font size and scale it

    //IwGxFontTerminate();
    //IwResManagerTerminate();
    IwGxTerminate();
}
Exemple #13
0
void ExampleShutDown()
{
    delete m_pAnimator;
    delete m_pSplinePoly2Tri;
    delete m_pBall;

    // Terminate
    IwGxTerminate();

    if (s_Accelerometer)
    {
        s3eAccelerometerStop();
        s_Accelerometer = false;
    }

    IW_PROFILE_TERM();
    delete &CIwProfileMenu::Get();
}
Exemple #14
0
int main()
{
	IwGxInit();
	IwGxSetColClear(0, 0, 0xff, 0xff);

	while (!s3eDeviceCheckQuitRequest() &&
				 !(s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_DOWN) &&
				 !(s3eKeyboardGetState(s3eKeyAbsBSK) & S3E_KEY_STATE_DOWN))
	{
		IwGxClear();
		IwGxPrintString(120, 150, "Hello, World!");
		IwGxFlush();
		IwGxSwapBuffers();
		s3eDeviceYield(0);
	}

	IwGxTerminate();
	return 0;
}
void Game::Shutdown()
{
	m_webManager->FreeInstance();

	GameState::ReleaseStatesStack();

	m_postProcessing->Remove();
	m_postProcessing->FreeInstance();

	m_shaderManager->Remove();
	m_shaderManager->FreeInstance();

	m_scriptManager->Remove();
	m_scriptManager->FreeInstance();

	m_soundManager->Remove();
	m_soundManager->FreeInstance();

	m_config->Remove();
	m_config->FreeInstance();

	m_accelerometerManager->Stop();
	m_accelerometerManager->FreeInstance();

	m_touchManager->Remove();
	m_touchManager->FreeInstance();

	m_menuManager->Remove();
	m_menuManager->FreeInstance();

	m_font->Remove();
	m_font->FreeInstance();

	LocaliseTerminate();

	WorldLoader::ClearAndFree();

	IwResManagerTerminate();

	IwGraphicsTerminate();
	IwGxTerminate();
}
void Terminate()
{
	// Destroy sound effects
	delete gpGunBattleSound;
	delete gpFemaleCountingSound;

	// Destroy Button instances
	for (uint32 i = 0; i < BUTTON_COUNT; i++)
	{
		delete gButton[i];
	}

	// Destroy texture instance
	delete gpTexture;

	// Disable Pause/Resume callbacks
	s3eDeviceUnRegister(S3E_DEVICE_PAUSE, AppSuspended);
	s3eDeviceUnRegister(S3E_DEVICE_BACKGROUND, AppSuspended);
	s3eDeviceUnRegister(S3E_DEVICE_UNPAUSE, AppResumed);
	s3eDeviceUnRegister(S3E_DEVICE_FOREGROUND, AppResumed);

	// Terminate Marmalade modules
	IwGxTerminate();
}
//-----------------------------------------------------------------------------
void ExampleShutDown()
{
	manager.stop();
	curl_global_cleanup();
	IwGxTerminate();
}
Exemple #18
0
void Desktop::release() {
	clear();
	delete devices;
    IwGxTerminate();
}
void ImGui_Marmalade_Shutdown()
{
    ImGui_Marmalade_InvalidateDeviceObjects();
    ImGui::Shutdown();
    IwGxTerminate();
}
void Terminate()
{
	Iw2DTerminate();
    IwGxTerminate();
}
Exemple #21
0
int main(int, char**)
{
    IwGxInit();

    // Setup Dear ImGui binding
    IMGUI_CHECKVERSION();
    ImGui::CreateContext();
    ImGuiIO& io = ImGui::GetIO(); (void)io;
    //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;  // Enable Keyboard Controls
    ImGui_Marmalade_Init(true);

    // Setup style
    ImGui::StyleColorsDark();
    //ImGui::StyleColorsClassic();

    // Load Fonts
    // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. 
    // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. 
    // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
    // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
    // - Read 'misc/fonts/README.txt' for more instructions and details.
    // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
    //io.Fonts->AddFontDefault();
    //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
    //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
    //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
    //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
    //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
    //IM_ASSERT(font != NULL);

    bool show_demo_window = true;
    bool show_another_window = false;
    ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);

    // Main loop
    while (true)
    {
        if (s3eDeviceCheckQuitRequest())
            break;

        // Poll and handle inputs
        // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
        // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
        // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
        // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
        s3eKeyboardUpdate();
        s3ePointerUpdate();

        // Start the Dear ImGui frame
        ImGui_Marmalade_NewFrame();
        ImGui::NewFrame();

        // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
        if (show_demo_window)
            ImGui::ShowDemoWindow(&show_demo_window);

        // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
        {
            static float f = 0.0f;
            static int counter = 0;

            ImGui::Begin("Hello, world!");                          // Create a window called "Hello, world!" and append into it.

            ImGui::Text("This is some useful text.");               // Display some text (you can use a format strings too)
            ImGui::Checkbox("Demo Window", &show_demo_window);      // Edit bools storing our window open/close state
            ImGui::Checkbox("Another Window", &show_another_window);

            ImGui::SliderFloat("float", &f, 0.0f, 1.0f);            // Edit 1 float using a slider from 0.0f to 1.0f    
            ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color

            if (ImGui::Button("Button"))                            // Buttons return true when clicked (most widgets return true when edited/activated)
                counter++;
            ImGui::SameLine();
            ImGui::Text("counter = %d", counter);

            ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
            ImGui::End();
        }

        // 3. Show another simple window.
        if (show_another_window)
        {
            ImGui::Begin("Another Window", &show_another_window);   // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
            ImGui::Text("Hello from another window!");
            if (ImGui::Button("Close Me"))
                show_another_window = false;
            ImGui::End();
        }

        // Rendering
        ImGui::Render();
        IwGxSetColClear(clear_color.x * 255, clear_color.y * 255, clear_color.z * 255, clear_color.w * 255);
        IwGxClear();
        ImGui_Marmalade_RenderDrawData(ImGui::GetDrawData());
        IwGxSwapBuffers();

        s3eDeviceYield(0);
    }

    // Cleanup
    ImGui_Marmalade_Shutdown();
    ImGui::DestroyContext();
    IwGxTerminate();

    return 0;
}
Exemple #22
0
int main() {

	IwGxInit();
	IwGraphicsInit();
	IwAnimInit();
	Iw2DInit();

	IwTrace(GHOST_HUNTER, ("Ghost Realm booting..."));
	IwTrace(GHOST_HUNTER, ("Audio channels: %d", s3eAudioGetInt(S3E_AUDIO_NUM_CHANNELS)));

	// Set screen clear colour
    IwGxSetColClear(0x0, 0x0, 0x0, 0xff);

	Splash* splash = new Splash();
	s3eDeviceYield(20);
	{ // Init game
		CameraViewPreInit();

		MapControllerInit();
		MapModelInit();
		MapViewInit();

		CameraControllerInit();
		CameraModelInit();
		CameraViewInit();
	}
	delete splash;

	getGameState()->setGameMode(MAP_MODE);

    while (1) {
        s3eDeviceYield(0);

        int start = clock();

		Audio::GetInstance().Update();

		if (getGameState()->getGameMode() == CAMERA_MODE) {
			CameraControllerUpdate();
			CameraModelUpdate();
			CameraViewUpdate();
		} else if (getGameState()->getGameMode() == MAP_MODE) {
			MapControllerUpdate();
			MapModelUpdate();
			MapViewUpdate();
		}
		
		// Cap FPS
		int yield;
        do {
            yield = FRAME_DURATION - (clock() - start);
            if (yield > 0) {
				s3eDeviceYield(yield);
			}
        } while (yield > 0);
    }

	CameraControllerTerm();
	CameraModelTerm();
    CameraViewTerm();

	MapControllerTerm();
	MapModelTerm();
	MapViewTerm();

	delete getGameState();

	Iw2DTerminate();
	IwAnimTerminate();
	IwGraphicsTerminate();
    IwGxTerminate();

    return 0;
}
Exemple #23
0
Graphics::~Graphics()
{
	IwGxTerminate();
}
FrameworkApplication::~FrameworkApplication (void) {
	//delete pModel;
	IwGraphicsTerminate();
	IwGxTerminate();
	IwTrace(FUNCTIONS, ("~FrameworkApplication()"));
}