Esempio n. 1
0
//--------------------------------------------------------------------------
// Main global function
//--------------------------------------------------------------------------
S3E_MAIN_DECL void IwMain()
{
#ifdef EXAMPLE_DEBUG_ONLY
    // Test for Debug only examples
#endif

    // Example main loop
    ExampleInit();
    uint64 timeOld = s3eTimerGetMs();
    while (1)
    {
        s3eDeviceYield(0);
        s3eKeyboardUpdate();
        s3ePointerUpdate();

        uint64 timeNew = s3eTimerGetMs();
        float dt = (timeNew - timeOld) * 0.001f;
        timeOld = timeNew;

        bool result = ExampleUpdate(dt);
        if (
            (result == false) ||
            (s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_DOWN)||
            (s3eKeyboardGetState(s3eKeyLSK) & S3E_KEY_STATE_DOWN)||
            (s3eDeviceCheckQuitRequest())
        )
            break;
        ExampleRender();
        //s3eSurfaceShow();
    }
    ExampleShutDown();
}
Esempio n. 2
0
void SceneGame::update() {
	unsigned int i;

	// if keyboard is up, check for key press
	if(keyboardUp) {
		// update the keyboard state
		s3eKeyboardUpdate();

		// see if a key is pressed
		for(i=0; i<26; i++) {
			if(s3eKeyboardGetState(s3eKeys[i]) != 0) {
				pressKey(i);
				playInputSound();
			}
		}
	}

	// check for back button pressed
	if(s3eKeyboardGetState(s3eKeyAbsBSK) != 0) {
		GameButtonMenu* buttonMenu = (GameButtonMenu*)this->getChildByTag(SceneGameTagButtonMenu);
		buttonMenu->buttonPressed();
	}
	
	// update the other nodes
	IGNode::update();
}
Esempio n. 3
0
//--------------------------------------------------------------------------
// Main global function
//--------------------------------------------------------------------------
S3E_MAIN_DECL void IwMain()
{
#ifdef EXAMPLE_DEBUG_ONLY
	// Test for Debug only examples
#endif
	onInit();
	while (1)
	{
		s3eDeviceYield(0);
		s3eKeyboardUpdate();
		bool result = onUpdate();
		if (
			(result == false) ||
			(s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_DOWN)
			||
			(s3eKeyboardGetState(s3eKeyLSK) & S3E_KEY_STATE_DOWN)
			||
			(s3eDeviceCheckQuitRequest())
			) {
			break;
		}
		onRender();
		s3eSurfaceShow();
	}
	onShutDown();
}
Esempio n. 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;
}
bool ExampleCheckQuit()
{
    bool rtn = s3eDeviceCheckQuitRequest()
    || (s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_PRESSED)
    || (s3eKeyboardGetState(s3eKeyAbsBSK) & S3E_KEY_STATE_PRESSED);
    if (rtn)
        s3eDebugTracePrintf("quiting example");
    return rtn;
}
Esempio n. 6
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

    Iw2DInit();

    // Example main loop
    ExampleInit();
    // Set screen clear colour

    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
        Iw2DSurfaceClear(0xffffffff);
        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();
    Iw2DTerminate();
    return 0;
}
bool HelloWorldUpdate()
{
	if(s3eKeyboardGetState(s3eKeyBack) & S3E_KEY_STATE_RELEASED)
    {
		s3eDebugTraceLine("back check");
		std::hash_map<char*, char*>::iterator ihashMap; 
		if(hashMap.size() > 1) {
		ihashMap = hashMap.find("ShowAt");
		if(ihashMap->second == "both"){
			 vservManagerFetchingAdData();
		}else if(ihashMap->second == "end") {
			 vservManagerFetchingAdData();
		}
		else if(ihashMap->second == "start"){
			s3eDeviceExit();
			return false;
		}
    }
	}
	if(CheckButtonStatus("Exit") & S3E_KEY_STATE_RELEASED) /*S3E_KEY_STATE_PRESSED)*/
    {
		s3eDebugTraceLine("Exit check");
			HelloWorldShutDown();
			return false;
	}
	return true;
}
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. 9
0
// Main entry point for the application
int main()
{
	int i = 0;
	bool hidden = false;
	bool adsAvailable = false;
	bool noView = false;

	if(AdmobAdsAvailable()){
		InitAds("a14bd815ee70598");
		adsAvailable = true;
	}

		
    // Wait for a quit request from the host OS
    while (!s3eDeviceCheckQuitRequest())
    {
        

		// Fill background blue
        s3eSurfaceClear(0, 0, 255);

        // Print a line of debug text to the screen at top left (0,0)
        // Starting the text with the ` (backtick) char followed by 'x' and a hex value
        // determines the colour of the text.
        s3eDebugPrint(120, 150, "`xffffffHello, World!", 0);

		if (noView){
			s3eDebugPrint(120, 190, "`xff1111No view", 0);
		}else{
			s3eDebugPrint(120, 190, "`x11ff11Ok", 0);
		}

        // Flip the surface buffer to screen
        s3eSurfaceShow();

        // Sleep for 0ms to allow the OS to process events etc.
        s3eDeviceYield(1);

		if(adsAvailable){
			i++;

			if(i>15000){
				i = 0;
				if (hidden) {
					noView = ShowAds() != 0;
				} else {
					noView = HideAds() != 0;
				}

				hidden = !hidden;
			}
		}

		s3eKeyboardUpdate();
		if(s3eKeyboardGetState(s3eKeyBack) & S3E_KEY_STATE_DOWN){
			break;
		}
    }
    return 0;
}
Esempio n. 10
0
File: input.cpp Progetto: dblo/XTD
bool CInput::isKeyDown(s3eKey key) const
{
	if (!KeysAvailable)
		return false;

	// Return down state of queried key
	return (s3eKeyboardGetState(key) & S3E_KEY_STATE_DOWN) == S3E_KEY_STATE_DOWN;
}
Esempio n. 11
0
File: input.cpp Progetto: dblo/XTD
bool CInput::isKeyUp(s3eKey key) const
{
	if (!KeysAvailable)
		return false;

	// Return up state of queried key
	return (s3eKeyboardGetState(key) & S3E_KEY_STATE_UP) == S3E_KEY_STATE_UP;
}
Esempio n. 12
0
File: input.cpp Progetto: dblo/XTD
bool CInput::wasKeyPressed(s3eKey key) const
{
	if (!KeysAvailable)
		return false;

	// Return pressed state of queried key
	return (s3eKeyboardGetState(key) & S3E_KEY_STATE_PRESSED) == S3E_KEY_STATE_PRESSED;
}
Esempio n. 13
0
File: input.cpp Progetto: dblo/XTD
bool CInput::wasKeyReleased(s3eKey key) const
{
	if (!KeysAvailable)
		return false;

	// Return released state of queried key
	return (s3eKeyboardGetState(key) & S3E_KEY_STATE_RELEASED) == S3E_KEY_STATE_RELEASED;
}
Esempio n. 14
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();
}
Esempio n. 15
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;
}
Esempio n. 16
0
int FrameworkApplication::MainLoop (void)  {
	IwTrace(FUNCTIONS, ("FrameworkApplication -> MainLoop()"));

	// Выход из главного цикла по прямому запросу операционки или если фреймоворк событие клавиатуры интерпретировал как команду на выход.
	while (!s3eDeviceCheckQuitRequest()) {
		// Содержательный игровой цикл
		if (EachFrame())
			break;
		// Рендеринг объектов
		if (Render())
			break;
		s3eDeviceYield(0); // Здесь будут игры с FPS-ом.
		// Выход по клавиатуре происходит отсюда временно, потом событие будет через Stage прокидываться.
		s3eKeyboardUpdate();
		if ((s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_DOWN) ||
			(s3eKeyboardGetState(s3eKeyLSK) & S3E_KEY_STATE_DOWN))
				break;
	}
	return 0;
}
Esempio n. 17
0
S3E_MAIN_DECL void IwMain()
{
    Init();

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

    while (1)
    {
        s3eDeviceYield(0);
        s3eKeyboardUpdate();
        s3ePointerUpdate();

        int64 start = s3eTimerGetMs();

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

        Render();

        // Attempt frame rate
        while ((s3eTimerGetMs() - start) < MS_PER_FRAME)
        {
            int32 yield = (int32) (MS_PER_FRAME - (s3eTimerGetMs() - start));
            if (yield<0)
                break;
            s3eDeviceYield(yield);
        }
    }

    ShutDown();
}
void Game::Run()
{
	uint64 now = s3eTimerGetMs(); 

	while( true )
	{
		s3eDeviceYield( 0 );
		s3eKeyboardUpdate();

		m_touchManager->Update();
		m_accelerometerManager->Update();

		m_webManager->Update();

		if( ( s3eKeyboardGetState( s3eKeyEsc ) & S3E_KEY_STATE_DOWN ) || ( s3eKeyboardGetState( s3eKeyAbsBSK ) & S3E_KEY_STATE_DOWN ) || ( s3eDeviceCheckQuitRequest() ) )
		{
			break;
		}

		const uint64 newTime = s3eTimerGetMs();
		const uint64 deltaTime = newTime - now;
		now = newTime;

		Update( deltaTime );
		Render();

		while( ( s3eTimerGetMs() - newTime) < s_msPerFrame )
		{
			const int32 yield = static_cast<int32>( s_msPerFrame - ( s3eTimerGetMs() - newTime ) );
			if( yield < 0 )
			{
				break;
			}

			s3eDeviceYield( yield );
		}
	}
}
Esempio n. 19
0
//--------------------------------------------------------------------------
// Main global function
//--------------------------------------------------------------------------
S3E_MAIN_DECL void IwMain()
{
#ifdef EXAMPLE_DEBUG_ONLY
// Test for Debug only examples
#endif

// Example main loop
    input_engine = GetInputEngine();
    game_class = new Game();
    game_class->Initialize();
    input_engine->RegisterInputController(game_class);
    //graphics_engine = GetHPTGraphicsEngine();
    //graphics_engine->SetBackgroundColor(100,100,255);
    //ExampleInit();
    s3eDeviceRegister(S3E_DEVICE_PAUSE,PauseCallback,NULL);
    s3eDeviceRegister(S3E_DEVICE_UNPAUSE,UnPauseCallback,NULL);
    s3eSurfaceRegister(S3E_SURFACE_SCREENSIZE,ScreenCallback,NULL);

    while (1)
    {
        s3eDeviceYield(0);
        s3eKeyboardUpdate();
        //bool result = ExampleUpdate();
        if( /*(result == false) ||*/ (s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_DOWN) ||
                                     (s3eKeyboardGetState(s3eKeyLSK) & S3E_KEY_STATE_DOWN) || (s3eDeviceCheckQuitRequest()))
            break;
        input_engine->InputChanged();
        game_class->ExecuteGame();
        //ExampleRender();
        //graphics_engine->BeginFrame();
        //graphics_engine->EndFrame();
        //s3eSurfaceShow();
    }
    input_engine->Release();
    delete game_class;
    //graphics_engine->Release();
    //ExampleShutDown();
}
Esempio n. 20
0
int32 ImGui_Marmalade_KeyCallback(void* SystemData, void* userData)
{
    ImGuiIO& io = ImGui::GetIO();
    s3eKeyboardEvent* e = (s3eKeyboardEvent*)SystemData;
    if (e->m_Pressed == 1)
        io.KeysDown[e->m_Key] = true;
    if (e->m_Pressed == 0)
        io.KeysDown[e->m_Key] = false;

    io.KeyCtrl = s3eKeyboardGetState(s3eKeyLeftControl) == S3E_KEY_STATE_DOWN || s3eKeyboardGetState(s3eKeyRightControl) == S3E_KEY_STATE_DOWN;
    io.KeyShift = s3eKeyboardGetState(s3eKeyLeftShift) == S3E_KEY_STATE_DOWN || s3eKeyboardGetState(s3eKeyRightShift) == S3E_KEY_STATE_DOWN;
    io.KeyAlt = s3eKeyboardGetState(s3eKeyLeftAlt) == S3E_KEY_STATE_DOWN || s3eKeyboardGetState(s3eKeyRightAlt) == S3E_KEY_STATE_DOWN;
    io.KeySuper = s3eKeyboardGetState(s3eKeyLeftWindows) == S3E_KEY_STATE_DOWN || s3eKeyboardGetState(s3eKeyRightWindows) == S3E_KEY_STATE_DOWN;

    return 0;
}
Esempio n. 21
0
/*
	Name		Game::run
	Syntax		Game::run()
	Brief		Runs the main game loop
*/
void Game::run()
{
	int time0 = getUpdateFrame();
	int time1 = 0;
	float deltaTime = 0;
	float tickTime = static_cast<float>(1000/UPS);

	// Loop forever, until the user or the OS performs some action to quit the app
	while (!s3eDeviceCheckQuitRequest()
          && !(s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_DOWN)
          && !(s3eKeyboardGetState(s3eKeyAbsBSK) & S3E_KEY_STATE_DOWN)
          )
	{
		
		// Update IwGx state time stamp
		IwGxTickUpdate();
		time1 = getUpdateFrame();
		deltaTime = 0;
		// Update the state logic every tick time, or until the FPS drops below 10
        int frames = time1 - time0;
        frames = MIN(MAX_UPDATES, frames);
        while (frames--)
        {
			// Time-critical updates, such as AI
			update();
			deltaTime += tickTime;
		}
		// Any updates which are not time-critical e.g. player input
		independentUpdate(deltaTime);
		time0 = time1;
		render();
        
        // Sleep for 0ms to allow the OS to process events etc.
        s3eDeviceYield(0);
	}
}
Esempio n. 22
0
		bool update()
		{
			ThreadMessages::message msg;
			while (_threadMessages.peek(msg, true))	{}

#ifdef __S3E__

			s3eDeviceYield(0);
			s3eKeyboardUpdate();
			s3ePointerUpdate();

			bool done = false;

			if (s3eDeviceCheckQuitRequest())
				done = true;

			if (s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_PRESSED)
				done = true;

			return done;
#endif


#if OXYGINE_SDL || EMSCRIPTEN

			//log::messageln("update");

			bool done = false;
			SDL_Event event;
			while (SDL_PollEvent(&event))
			{
#if !EMSCRIPTEN //emscripten handled events from callback
				SDL_handleEvent(event, done);
#endif
			}

			return done;
#endif

			log::warning("update not implemented");
			return true;
		}
Esempio n. 23
0
void ButtonsRender()
{
    int previousDebugTextSize = s3eDebugGetInt(S3E_DEBUG_FONT_SCALE);
    int fontScale = g_ButtonScale;
    char buf[128];

    // select double sized text
    if (previousDebugTextSize != (int)g_ButtonScale)
        s3eDebugSetInt(S3E_DEBUG_FONT_SCALE, g_ButtonScale);

    // find out the dimensions of the font
    const int textWidthDefault = s3eDebugGetInt(S3E_DEBUG_FONT_SIZE_WIDTH);
    const int textHeight = s3eDebugGetInt(S3E_DEBUG_FONT_SIZE_HEIGHT);

    // get the current pointer position and selection state
    int pointerX = s3ePointerGetX();
    int pointerY = s3ePointerGetY();
    s3ePointerState pointerState = s3ePointerGetState(S3E_POINTER_BUTTON_SELECT);

    int x = 10;
    int y = 50;
    
    g_SelectedButton = 0;

    // draw the buttons
    for (Button* iter = g_ButtonsHead; iter; iter = iter->m_Next)
    {
        if (!iter->m_Display)
            continue;

        if (g_HideDisabledButtons && !iter->m_Enabled)
            continue;

        fontScale = g_ButtonScale;
        int textWidth = textWidthDefault;
        if (s3eDebugGetInt(S3E_DEBUG_FONT_SCALE) != fontScale)
            s3eDebugSetInt(S3E_DEBUG_FONT_SCALE, fontScale);

        if (iter->m_Key != S3E_KEY_INVALID)
        {
            if (s3eKeyboardGetState(iter->m_Key) & S3E_KEY_STATE_PRESSED)
            {
                g_SelectedButton = iter;
                s3eDebugTracePrintf("button selected using key");
            }
        }

        if (iter->m_Key != S3E_KEY_INVALID)
        {
            char keyName[32];
            s3eKeyboardGetDisplayName(keyName, iter->m_Key);
            if (iter->m_Enabled)
                snprintf(buf, sizeof(buf), "`x000000%s: %s", keyName, iter->m_Name);
            else
                snprintf(buf, sizeof(buf), "`xa0a0a0%s: %s", keyName, iter->m_Name);
        }
        else
        {
            if (iter->m_Enabled)
                snprintf(buf, sizeof(buf), "`x000000%s", iter->m_Name);
            else
                snprintf(buf, sizeof(buf), "`xa0a0a0%s", iter->m_Name);
        }

        int len = strlen(buf) - 8;
        int _x0 = x - 2;
        int _y0 = y - 4;
        int _h = textHeight + 4;
        int _y1 = _y0 + _h;
        int _w;
        int _x1;
        int textOffset = 0;
        
        // Scale down font size if button contents are too long for screen
        while (true)
        {
            _w = (textWidth * len) + 8;
            
            _x1 = _x0 + _w;

            if (fontScale == 1 || _x1 <= s3eSurfaceGetInt(S3E_SURFACE_WIDTH))
                break;

            fontScale -= 1;
            s3eDebugSetInt(S3E_DEBUG_FONT_SCALE, fontScale);
            textWidth = s3eDebugGetInt(S3E_DEBUG_FONT_SIZE_WIDTH);
            textOffset += (textHeight-s3eDebugGetInt(S3E_DEBUG_FONT_SIZE_HEIGHT))/2;
        }

        if (pointerX >= _x0 && pointerX <= _x1 &&
            pointerY >= _y0 && pointerY <= _y1 && iter->m_Enabled)
        {
            if (pointerState & S3E_POINTER_STATE_DOWN)
                DrawRect(_x0, _y0, _w, _h, 0, 255, 0);
            else
                DrawRect(_x0, _y0, _w, _h, 255, 0, 0);

            if (pointerState & S3E_POINTER_STATE_RELEASED)
                g_SelectedButton = iter;
        }
        else
        {
            if (iter->m_Enabled)
                DrawRect(_x0, _y0, _w, _h, 255, 0, 0);
            else
                DrawRect(_x0, _y0, _w, _h, 127, 0, 0);
        }

        s3eDebugPrint(x, y+textOffset,  buf, 0);

        // Store button's position and size
        iter->m_XPos = _x0;
        iter->m_YPos = _y0;
        iter->m_Width = _w;
        iter->m_Height = _h;

        y = y + textHeight * 2;
    }

    if (g_SelectedButton && g_SelectedButton->m_Callback)
        g_SelectedButton->m_Callback(g_SelectedButton);

    if (previousDebugTextSize != fontScale)
        s3eDebugSetInt(S3E_DEBUG_FONT_SCALE, previousDebugTextSize);

    g_YBelowButtons = y;
}
Esempio n. 24
0
extern "C" void RenderButtons()
{
    ExButtons* pbutton = g_ButtonsHead;

    if(g_ButtonsHead)
    {
        pbutton = g_ButtonsHead;
        while(pbutton != NULL)
        {
            // Check the key and pointer states.
            pbutton->key_state = s3eKeyboardGetState(pbutton->key);
            if( s3eKeyboardGetState(pbutton->key) & S3E_KEY_STATE_DOWN )
            {
                if(pbutton->handler)
                    pbutton->handler();
            }

            if (!(s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_UP))
            {
                int pointerx = s3ePointerGetX();
                int pointery = s3ePointerGetY();
                if (pointerx >= pbutton->x && pointerx <= pbutton->x+pbutton->w && pointery >=pbutton->y && pointery <= pbutton->y+pbutton->h)
                {
                    if (s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_DOWN)
                    {
                        pbutton->key_state = S3E_KEY_STATE_DOWN;
                    }
                    if (s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_PRESSED)
                    {
                        pbutton->key_state = S3E_KEY_STATE_PRESSED;
                    }

                    if(pbutton->handler)
                        pbutton->handler();
                }

            }

            // Draw the text
            IwGxSetScreenSpaceSlot(0);

            if(s3ePointerGetInt(S3E_POINTER_AVAILABLE))
            {
                CIwMaterial *fadeMat = IW_GX_ALLOC_MATERIAL();
                fadeMat->SetAlphaMode(CIwMaterial::SUB);
                IwGxSetMaterial(fadeMat);

                CIwColour* cols = IW_GX_ALLOC(CIwColour, 4);
                if(pbutton->key_state == S3E_KEY_STATE_DOWN)
                    memset(cols, 15, sizeof(CIwColour)*4);
                else
                    memset(cols, 50, sizeof(CIwColour)*4);

                // Draw button area
                CIwSVec2 XY(pbutton->x, pbutton->y-2), dXY(pbutton->w, pbutton->h);
                IwGxDrawRectScreenSpace(&XY, &dXY, cols);
            }

            IwGxPrintString(pbutton->x + 2, pbutton->y + ((pbutton->h - 10)/2), pbutton->name, false);
            pbutton = pbutton->next;
        }
    }
}
Esempio n. 25
0
extern "C" void RenderCursorskeys()
{
    int height = 20;
    int width = 45;

    int lefty = IwGxGetScreenHeight() - (height * 2);
    int leftx = (IwGxGetScreenWidth() - 220) / 2;
    int upy = IwGxGetScreenHeight() - (height * 3);
    int upx = leftx+width + (width/2);
    int downy = IwGxGetScreenHeight() - height;
    int downx = upx;
    int righty = IwGxGetScreenHeight() - (height * 2);
    int rightx = downx + width + (width/2);

    CIwMaterial *fadeMat = IW_GX_ALLOC_MATERIAL();
    fadeMat->SetAlphaMode(CIwMaterial::SUB);
    IwGxSetMaterial(fadeMat);

    g_Cursorkey = EXCURSOR_NONE;

    if ( (s3eKeyboardGetState(s3eKeyLeft) & S3E_KEY_STATE_DOWN) )
        g_Cursorkey = EXCURSOR_LEFT;
    if ( (s3eKeyboardGetState(s3eKeyRight) & S3E_KEY_STATE_DOWN) )
        g_Cursorkey = EXCURSOR_RIGHT;
    if ( (s3eKeyboardGetState(s3eKeyUp) & S3E_KEY_STATE_DOWN) )
        g_Cursorkey = EXCURSOR_UP;
    if ( (s3eKeyboardGetState(s3eKeyDown) & S3E_KEY_STATE_DOWN) )
        g_Cursorkey = EXCURSOR_DOWN;

    if(s3ePointerGetInt(S3E_POINTER_AVAILABLE))
    {
        if (s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_DOWN)
        {
            int pointerx = s3ePointerGetX();
            int pointery = s3ePointerGetY();
            // Check left
            if (pointerx >= leftx && pointerx <= leftx+width && pointery >=lefty && pointery <= lefty+height)
                g_Cursorkey = EXCURSOR_LEFT;
            // Check right
            if (pointerx >= rightx && pointerx <= rightx+width && pointery >=righty && pointery <= righty+height)
                g_Cursorkey = EXCURSOR_RIGHT;
            // Check up
            if (pointerx >= upx && pointerx <= upx+width && pointery >=upy && pointery <= upy+height)
                g_Cursorkey = EXCURSOR_UP;
            // Check down
            if (pointerx >= downx && pointerx <= downx+width && pointery >=downy && pointery <= downy+height)
                g_Cursorkey = EXCURSOR_DOWN;
        }

        CIwColour* cols = IW_GX_ALLOC(CIwColour, 4);
        if((s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_DOWN) && (g_Cursorkey != EXCURSOR_NONE))
            memset(cols, 10, sizeof(CIwColour)*4);
        else
            memset(cols, 50, sizeof(CIwColour)*4);

        // draw black rect covering screen
        CIwSVec2 rectdim(width, height);

        CIwSVec2 uXY(upx, upy-2);
        IwGxDrawRectScreenSpace(&uXY, &rectdim, cols);
        IwGxPrintString(upx + 10, upy + 5, "Up", false);

        CIwSVec2 dXY(downx, downy-2);
        IwGxDrawRectScreenSpace(&dXY, &rectdim, cols);
        IwGxPrintString(downx + 10, downy + 5, "Down", false);

        CIwSVec2 lXY(leftx, lefty-2);
        IwGxDrawRectScreenSpace(&lXY, &rectdim, cols);
        IwGxPrintString(leftx + 10, lefty + 5, "Left", false);

        CIwSVec2 rXY(rightx, righty-2);
        IwGxDrawRectScreenSpace(&rXY, &rectdim, cols);
        IwGxPrintString(rightx + 10, righty + 5, "Right", false);
    }
}
Esempio n. 26
0
void CIwGameInput::Update()
{
	// Update the pointer if it is available
	if (PointerAvailable)
		s3ePointerUpdate();

	// Update key system if it is available
	s3eKeyboardUpdate();

	Tapped = false;

	int num_touches = getTouchCount();
	DragDelta.x = 0;
	DragDelta.y = 0;

	if (num_touches == 0)
		Dragging = false;
	else
		Dragging = true;

	// User has just pressed screen so start timer
	if (PreviousNumTouches == 0 && num_touches == 1)
	{
		TapTimer.setDuration(TAP_TIME_MS);
		TouchedPos.x = getTouch(0)->x;
		TouchedPos.y = getTouch(0)->y;
	}

	// User has stopped pressing screen so check to see if press was a short press (a tap)
	if (PreviousNumTouches == 1 && num_touches == 0)
	{
		// Only check if touch hasnt moved much
		int dx = getTouch(0)->x - TouchedPos.x;
		int dy = getTouch(0)->y - TouchedPos.y;
		int d = dx * dx + dy * dy;
		DragDelta.x = dx;
		DragDelta.y = dy;

		if (d <= TAP_SENSITIVITY)
		{
			if (TapTimer.HasTimedOut())
			{
				TapTimer.Stop();
				Tapped = true;
			}
		}
		else
		{
			TapTimer.Stop();
		}
	}

	PreviousNumTouches = num_touches;

	// Update buttons
	BackPressed = false;
	bool back_released = (s3eKeyboardGetState(s3eKeyBack) & S3E_KEY_STATE_RELEASED) == S3E_KEY_STATE_RELEASED || (s3eKeyboardGetState(s3eKeyAbsBSK) & S3E_KEY_STATE_RELEASED) == S3E_KEY_STATE_RELEASED;
	if (back_released)
		BackPressed = true;

	MenuPressed = false;
	bool menu_released = (s3eKeyboardGetState(s3eKeyMenu) & S3E_KEY_STATE_RELEASED) == S3E_KEY_STATE_RELEASED || (s3eKeyboardGetState(s3eKeyAbsASK) & S3E_KEY_STATE_RELEASED) == S3E_KEY_STATE_RELEASED;
	if (menu_released)
		MenuPressed = true;

	// Update accelerometer
	if (AccelerometerActive)
	{
		AccelerometerPosition.x = s3eAccelerometerGetX();
		AccelerometerPosition.y = s3eAccelerometerGetY();
		AccelerometerPosition.z = s3eAccelerometerGetZ();
	}

	// Update compass
	if (CompassActive)
	{
		CompassDirection = s3eCompassGet();
		s3eCompassHeading heading = { 0, 0, 0 };
		if (s3eCompassGetHeading(&heading) != S3E_RESULT_SUCCESS)
		{
			CompassHeading.x = heading.m_X;
			CompassHeading.y = heading.m_Y;
			CompassHeading.z = heading.m_Z;
		}
	}

}
Esempio n. 27
0
		bool update()
		{
			ThreadMessages::message msg;
			while (_threadMessages.peek(msg, true))
			{

			}
#ifdef __S3E__

			s3eDeviceYield(0);
			s3eKeyboardUpdate();
			s3ePointerUpdate();

			bool done = false;

			if (s3eDeviceCheckQuitRequest())
				done = true;

			if (s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_PRESSED)
				done = true;

			return done;
#endif


	#if OXYGINE_SDL || EMSCRIPTEN

			//log::messageln("update");
			Input *input = &Input::instance;
			bool done = false;
			SDL_Event event;
			while (SDL_PollEvent(&event)) 
			{
				Event ev(Input::event_platform);
				ev.userData = &event;
				Input::instance.dispatchEvent(&ev);
				
				ObjectScript::processKeyboardEvent(&ev, getStage().get());

				switch(event.type)
				{
				case SDL_QUIT:
					done = true;
					break;
				case SDL_WINDOWEVENT:
					{					
						/*
						if (event.window.event == SDL_WINDOWEVENT_ENTER)
							active = false;
						if (event.window.event == SDL_WINDOWEVENT_LEAVE)
							active = true;
							*/

						if (event.window.event == SDL_WINDOWEVENT_MINIMIZED)
							active = false;
						if (event.window.event == SDL_WINDOWEVENT_RESTORED)
							active = true;

						bool newFocus = focus;
						if (event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)
							newFocus = false;
						if (event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED)
							newFocus = true;
						if (focus != newFocus)
						{
							focus = newFocus;
#if HANDLE_FOCUS_LOST

							if (focus)							
								focusAcquired();

							log::messageln("focus: %d", (int)focus);
							Event ev(focus ? Stage::ACTIVATE : Stage::DEACTIVATE);
							if (getStage())
								getStage()->dispatchEvent(&ev);

							if (!focus)
								focusLost();							
#endif							
						}
						//log::messageln("SDL_SYSWMEVENT %d", (int)event.window.event);
						break;
					}
				case SDL_MOUSEWHEEL:
					input->sendPointerWheelEvent(event.wheel.y, &input->_pointerMouse);
					break;
				case SDL_KEYDOWN:
				{
					KeyEvent ev(KeyEvent::KEY_DOWN, &event.key);
					getStage()->dispatchEvent(&ev);
				} break;
				case SDL_KEYUP:
				{
					KeyEvent ev(KeyEvent::KEY_UP, &event.key);
					getStage()->dispatchEvent(&ev);
				} break;
#if SDL_VIDEO_OPENGL
				case SDL_MOUSEMOTION:
					input->sendPointerMotionEvent((float)event.motion.x, (float)event.motion.y, 1.0f, &input->_pointerMouse);
					break;
				case SDL_MOUSEBUTTONDOWN:
				case SDL_MOUSEBUTTONUP:
					{
						MouseButton b = MouseButton_Left;
						switch(event.button.button)
						{
							case 1: b = MouseButton_Left; break;
							case 2: b = MouseButton_Middle; break;
							case 3: b = MouseButton_Right; break;
						}

						input->sendPointerButtonEvent(b, (float)event.button.x, (float)event.button.y, 1.0f, 
							event.type == SDL_MOUSEBUTTONDOWN ? TouchEvent::TOUCH_DOWN : TouchEvent::TOUCH_UP, &input->_pointerMouse);
					}					
					break;
#else

				case SDL_FINGERMOTION:
					{
						//log::messageln("SDL_FINGERMOTION");
						Vector2 pos = convertTouch(event);
						input->sendPointerMotionEvent(
							pos.x, pos.y, event.tfinger.pressure,
							input->getTouchByID((int)event.tfinger.fingerId));
					}
				
					break;
				case SDL_FINGERDOWN:
				case SDL_FINGERUP:
					{				
						//log::messageln("SDL_FINGER");
						Vector2 pos = convertTouch(event);
						input->sendPointerButtonEvent(
							MouseButton_Touch,
							pos.x, pos.y, event.tfinger.pressure,
							event.type == SDL_FINGERDOWN ? TouchEvent::TOUCH_DOWN : TouchEvent::TOUCH_UP,
							input->getTouchByID((int)event.tfinger.fingerId));
					}				
					break;
#endif
				}
			}


			return done;
	#elif EMSCRIPTEN
			return false;
	#endif


			log::warning("update not implemented");
			return true;
		}
Esempio n. 28
0
void doMain() {
    if(s3ePointerGetInt(S3E_POINTER_MULTI_TOUCH_AVAILABLE)){
        s3ePointerRegister(S3E_POINTER_TOUCH_EVENT, (s3eCallback)MultiTouchButtonCB, NULL);
        s3ePointerRegister(S3E_POINTER_TOUCH_MOTION_EVENT, (s3eCallback)MultiTouchMotionCB, NULL);
    } else {
        s3ePointerRegister(S3E_POINTER_BUTTON_EVENT, (s3eCallback)SingleTouchButtonCB, NULL);
        s3ePointerRegister(S3E_POINTER_MOTION_EVENT, (s3eCallback)SingleTouchMotionCB, NULL);
    }


    IwGetResManager()->LoadGroup("resource_groups/palate.group");
    
    palateGroup = IwGetResManager()->GetGroupNamed("Palate");

    std::vector<int> ui_texture_hashes;
	uint background_hash = IwHashString("background_clean");
	CIwResList* resources = palateGroup->GetListHashed(IwHashString("CIwTexture"));
	for(CIwManaged** itr = resources->m_Resources.GetBegin(); itr != resources->m_Resources.GetEnd(); ++itr) {
		if(background_hash != (*itr)->m_Hash) {
			ui_texture_hashes.push_back((*itr)->m_Hash);
		}
	}
    
    CIwMaterial* background = new CIwMaterial();
    background->SetTexture((CIwTexture*)palateGroup->GetResNamed("background_clean", IW_GX_RESTYPE_TEXTURE));
    background->SetModulateMode(CIwMaterial::MODULATE_NONE);
    background->SetAlphaMode(CIwMaterial::ALPHA_DEFAULT);

	unit_ui = new CIwMaterial();
    unit_ui->SetModulateMode(CIwMaterial::MODULATE_NONE);
    unit_ui->SetAlphaMode(CIwMaterial::ALPHA_DEFAULT);
    unit_ui->SetTexture((CIwTexture*)palateGroup->GetResNamed("TAKE2", IW_GX_RESTYPE_TEXTURE));
    
    CIwSVec2 bg_wh(320, 480);
	CIwSVec2 ui_wh(80, 480);
	CIwSVec2 ui_offset(240, 0);
	CIwSVec2 uv(0, 0);
	CIwSVec2 duv(IW_GEOM_ONE, IW_GEOM_ONE);

    init();
    
	IwGxLightingOff();
    IwGxSetColClear(255, 255, 255, 255);
    
    float worldScrollMultiplier = 0.75;
    
    if(s3eDeviceGetInt(S3E_DEVICE_OS) == S3E_OS_ID_IPHONE) {
        worldScrollMultiplier = 0.925;
    }

	while (1) {
        
        int64 start = s3eTimerGetMs();
	
		s3eDeviceYield(0);
		s3eKeyboardUpdate();
		s3ePointerUpdate();
		
		if ((s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_DOWN)
				|| (s3eKeyboardGetState(s3eKeyAbsBSK) & S3E_KEY_STATE_DOWN)       
				|| (s3eDeviceCheckQuitRequest())) {
			
		    break;
		}
	
        switch(currentState) {

        case MAIN_MENU:
            if(s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_PRESSED) {
                currentState = IN_GAME;
            }
            if(frameCount % FRAMES_PER_UPDATE == 0) {
			    mainMenu->tick();
		    }
            mainMenu->render();
            break;
        case IN_GAME:
            IwGxSetMaterial(background);
            IwGxSetScreenSpaceSlot(-1);
            IwGxDrawRectScreenSpace(&CIwSVec2::g_Zero, &bg_wh, &uv, &duv);

		    IwGxSetMaterial(unit_ui);
            IwGxSetScreenSpaceSlot(1); 
            IwGxDrawRectScreenSpace(&ui_offset, &ui_wh, &uv, &duv);
        
		    if (worldScrollSpeed > .0005 || worldScrollSpeed < -.0005) {
			    game->rotate(worldScrollSpeed);
			    worldScrollSpeed *= worldScrollMultiplier;
		    }
            if(frameCount % FRAMES_PER_UPDATE == 0) {
			    game->tick();
		    }
		
		    game->render();
		    if(!renderTouches()) {
                break;
            }

            break;
        }
        		
        IwGxFlush();
        
        IwGxSwapBuffers();
		
		// Attempt frame rate
		while ((s3eTimerGetMs() - start) < MS_PER_FRAME){
			int32 yield = (MS_PER_FRAME - (s3eTimerGetMs() - start));
			if (yield < 0) {
				break;
			}
				
			s3eDeviceYield(yield);
		}
		
		frameCount++;

        
        IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F);
	}
    
	delete game;
    delete mainMenu;
	delete localPlayer;
	delete opponentPlayer;
    delete background;
	delete unit_ui;
    palateGroup->Finalise();
    
    for(int i = 0; i < MAX_TOUCHES; ++i)
        if(touches[i].unit)
            delete touches[i].unit;
}
void GameplayState::HandleEvent(StateEngine* state)
{
	m_Moving = false;
	if ( (s3eKeyboardGetState(s3eKeySpace) & S3E_POINTER_STATE_DOWN) && m_SpacePressed == false)
	{
		if (m_CharacterIndex == MANDY)
		{
			characters[MANDY]->Jump();
		}
		m_SpacePressed = true;
	}

	if( (s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_DOWN))
    {
		m_ClickLocation = (CIwFVec2((s3ePointerGetX() - (float)m_Cam->GetPosition().x) , (s3ePointerGetY() - (float)m_Cam->GetPosition().y )));
		for (int i = 0; i < 3; i++)
		{
			// Check collision with the character portraits
			if (m_Portraits[i]->isColliding(CIwFVec2((float)s3ePointerGetX(), (float)s3ePointerGetY())))
			{
				if (m_CharacterIndex != i)
				{
					m_Cam->SetPosition(CIwSVec2(static_cast<int16>(-characters[i]->GetPosition().x + (screenWidth /2)), static_cast<int16>(-characters[i]->GetPosition().y + (screenHeight - characters[i]->GetHeight()))));
					m_CharacterIndex = i; // Set the character to be the element that was collided against
					m_PortraitSounds[i]->Play();
				}
			}
		}

		if (n_guiButtons[0]->isColliding((CIwFVec2((float)s3ePointerGetX(), (float)s3ePointerGetY()))))
		{
			if (characters[m_CharacterIndex]->GetDirection() == FACING_RIGHT)
				characters[m_CharacterIndex]->SetDirection(FACING_LEFT);
			m_Moving = true;

			characters[m_CharacterIndex]->MoveBy(CIwFVec2((-5 * state->m_deltaTime) - characters[m_CharacterIndex]->GetMovSpeed().x, 0),state->m_deltaTime);
			CheckCollisions(m_CharacterIndex);
		}

		if (n_guiButtons[1]->isColliding((CIwFVec2((float)s3ePointerGetX(), (float)s3ePointerGetY()))))
		{
			if (characters[m_CharacterIndex]->GetDirection() == FACING_LEFT)
				characters[m_CharacterIndex]->SetDirection(FACING_RIGHT);
			m_Moving = true;

			characters[m_CharacterIndex]->MoveBy(CIwFVec2((5 * state->m_deltaTime) + characters[m_CharacterIndex]->GetMovSpeed().x, 0),state->m_deltaTime);
			CheckCollisions(m_CharacterIndex);
		}

		if (characters[DAVE]->isColliding(characters[NIGEL]->GetPosition()) && (m_canThrow == false) && m_CharacterIndex == DAVE)
		{
			if (characters[NIGEL]->isColliding((CIwFVec2(s3ePointerGetX() - (float)m_Cam->GetPosition().x , s3ePointerGetY() - (float)m_Cam->GetPosition().y ))))
			{
				while (s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_DOWN)
				{
					// Continue to poll input
					s3ePointerUpdate();
					s3eKeyboardUpdate();
					m_canThrow = true;
					m_throwingTarget->SetPosition((CIwFVec2((s3ePointerGetX() - (float)m_Cam->GetPosition().x)  - ( m_throwingTarget->GetWidth() /2) , (s3ePointerGetY() - (float)m_Cam->GetPosition().y ) - (m_throwingTarget->GetHeight() /2))));
					m_throwingTarget->UpdateCollider();
					
					// Draw the current state or else we'll be in a loop that will show no updated frame
					state->Draw();
					m_ThrowingSound->ResetCounter();
				}

				m_isThrowing = true;
				m_ThrowingSound->Play();
				m_CharacterIndex = NIGEL;
			}
		}

		m_MouseClicked = true;
	}

	if (m_isThrowing)
	{
		characters[NIGEL]->UpdateCollider();
		if (m_canThrow)
		{
			if (!characters[NIGEL]->isColliding(m_throwingTarget, CIwFVec2(m_throwingTarget->GetWidth() /2, -(m_throwingTarget->GetHeight() / 2))) && m_ThrowingTargetSide == 0 && m_Moving == false)
			{
				m_ThrowingNigelSound->Play();
				characters[NIGEL]->LerpTo(CIwFVec2(m_throwingTarget->GetPosition().x, m_throwingTarget->GetPosition().y), 0.05f);
			}

			else
			{
				m_canThrow = false;
				m_ThrowingNigelSound->ResetCounter();
			}
		}
		else
		{
			m_isThrowing = false;
			characters[NIGEL]->MoveBy(CIwFVec2(m_ThrowingTargetSide * 2,2),state->m_deltaTime);
		}
	}

	if (m_gameOver)
	{
		state->ChangeState(GameoverState::Instance());
	}
}
Esempio n. 30
0
void PauseMenu::Update(float deltaTime, float alphaMul)
{
	if (!m_IsActive)
		return;

	Scene::Update(deltaTime, alphaMul);

	// Detect screen tap
	if ((m_IsInputActive && m_Manager->GetCurrent() == this && !g_pInput->m_Touched && g_pInput->m_PrevTouched) || (s3eKeyboardGetState(s3eKeyBack) & S3E_KEY_STATE_DOWN) || (s3eKeyboardGetState(s3eKeyBack) & S3E_KEY_STATE_PRESSED))
	{
		g_pInput->Reset();

			// Switch to game scene
			Game* game = (Game*)g_pSceneManager->Find("game");
			g_pSceneManager->SwitchTo(game);

			// Resume game
			game->resumeGame();
			// Restore button alpha state
			//PauseMenu* menu = (PauseMenu*)g_pSceneManager->Find("pausemenu");
	}

}