Beispiel #1
0
void GameProcessEvent(SDL_Event evt)
{
    if (evt.type == SDL_KEYDOWN)
    {
        switch (evt.key.keysym.sym)
        {
        case SDLK_PAUSE:   // POWER UP button on Dingoo
            g_okQuit = 1;
            break;
        case SDLK_ESCAPE:
	case SDLK_RETURN:  // SELECT button on Dingoo
            MenuStart();
            break;
        case SDLK_LEFT:    // D-PAD LEFT on Dingoo
            g_TileCursorX--;
            if (g_TileCursorX < 0) g_TileCursorX = 8;
            break;
        case SDLK_RIGHT:   // D-PAD RIGHT on Dingoo
            g_TileCursorX++;
            if (g_TileCursorX >= 9) g_TileCursorX = 0;
            break;
        case SDLK_UP:      // D-PAD UP on Dingoo
            g_TileCursorY--;
            if (g_TileCursorY < 0) g_TileCursorY = 8;
            break;
        case SDLK_DOWN:    // D-PAD DOWN on Dingoo
            g_TileCursorY++;
            if (g_TileCursorY >= 9) g_TileCursorY = 0;
            break;
        case SDLK_LCTRL:   // A button on Dingoo
        case SDLK_LALT:    // B button on Dingoo
        case SDLK_SPACE:
            if (g_Board[g_TileCursorY][g_TileCursorX] == BALL_NONE)
            {
                if (g_TileSelectX >= 0 && g_TileSelectY >= 0)  // We have selection and user selects the destination
                {
                    // Check rules and Move the ball
                    if (GameMoveSelectedBall())
                    {
                        if (!GameCheckToRemove())
                        {
                            GamePutThreeRandomBalls();
                            GameCheckToRemove();
                        }
                    }
                }
            }
            else  // If we have a ball under the cursor then select it
            {
                g_TileSelectX = g_TileCursorX;
                g_TileSelectY = g_TileCursorY;
            }
            break;
        default:  // Do nothing
            break;
        }
    }
}
void ScreenSelectCharacter::HandleScreenMessage( const ScreenMessage SM )
{
	switch( SM )
	{
	case SM_BeginFadingOut:
		StartTransitioning( SM_GoToNextScreen );
		return;
	case SM_MenuTimer:
		MenuStart(PLAYER_1);
		if( !AllAreFinishedChoosing() )
			ResetTimer();
		return;
	}
	Screen::HandleScreenMessage( SM );
}
Beispiel #3
0
void Screen::HandleScreenMessage( const ScreenMessage SM )
{
	switch( SM )
	{
	case SM_MenuTimer:
		FOREACH_HumanPlayer(p)
			MenuStart( p );
		break;
	case SM_GoToNextScreen:
		if( SCREENMAN->IsStackedScreen(this) )
			SCREENMAN->PopTopScreen( SM_None );
		else
			SCREENMAN->SetNewScreen( NEXT_SCREEN );
		break;
	case SM_GoToPrevScreen:
		SCREENMAN->DeletePreparedScreens();
		if( SCREENMAN->IsStackedScreen(this) )
			SCREENMAN->PopTopScreen( SM_None );
		else
			SCREENMAN->SetNewScreen( PREV_SCREEN );
		break;
	}
}
/************************************
HandleScreenMessage
Desc: Handles Screen Messages and changes
	game states.
************************************/
void ScreenEz2SelectPlayer::HandleScreenMessage( const ScreenMessage SM )
{
	Screen::HandleScreenMessage( SM );

	switch( SM )
	{
	case SM_MenuTimer:
		if( GAMESTATE->GetNumSidesJoined() == 0 )
		{
			MenuStart(PLAYER_1);
		}

		TweenOffScreen();
		StartTransitioning( SM_GoToNextScreen );
		break;
	case SM_GoToPrevScreen:
		SOUND->StopMusic();
		SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
		break;
	case SM_GoToNextScreen:
		SCREENMAN->SetNewScreen( NEXT_SCREEN );
		break;
	}
}
/************************************
MenuDown
Desc: Actions performed when a player 
presses the button bound to down
************************************/
void ScreenEz2SelectPlayer::MenuDown( PlayerNumber pn )
{
	MenuStart( pn );
}
Beispiel #6
0
/*
	menu start
	menu [up|down|right|left]
	menu enter
	menu exit
*/
void MonitorMenu(void)
{
//	int x, y;
	if (!stricmp(argv[1], "?"))
	{
		Puts("\n  === Help for MENU command ===");
		Puts("\nmenu start					;start main menu");
		Puts("\nmenu [up|down|right|left]	;menu arrow key");
		Puts("\nmenu enter					;enter key");
		Puts("\nmenu exit					;exit key");
		return;
	}

	if (argc != 3)
	{
		//Puts("\nmenu x y");

		if (TaskGetGrid())
		{
			if (!stricmp(argv[1], "up"))
			{
				TaskSetGridCmd(NAVI_KEY_UP);
			}
			else if (!stricmp(argv[1], "down"))
			{
				TaskSetGridCmd(NAVI_KEY_DOWN);
			}
			else if (!stricmp(argv[1], "left"))
			{
				TaskSetGridCmd(NAVI_KEY_LEFT);
			}
			else if (!stricmp(argv[1], "right"))
			{
				TaskSetGridCmd(NAVI_KEY_RIGHT);
			}
			else if (!stricmp(argv[1], "enter"))
			{
				TaskSetGridCmd(NAVI_KEY_ENTER);
			}
			return;
		}

		if (MenuGetLevel())
		{
			if (!stricmp(argv[1], "up"))
			{
				MenuKeyInput(NAVI_KEY_UP);
			}
			else if (!stricmp(argv[1], "down"))
			{
				MenuKeyInput(NAVI_KEY_DOWN);
			}
			else if (!stricmp(argv[1], "left"))
			{
				MenuKeyInput(NAVI_KEY_LEFT);
			}
			else if (!stricmp(argv[1], "right"))
			{
				MenuKeyInput(NAVI_KEY_RIGHT);
			}
			else if (!stricmp(argv[1], "enter"))
			{
				MenuKeyInput(NAVI_KEY_ENTER);
			}
		}

		if (!stricmp(argv[1], "start"))
		{
			Printf("\ncall MenuStart");
			//proc_home_menu_start();
			MenuStart();
		}
		else if (!stricmp(argv[1], "exit"))
		{
			Printf("\ncall MenuEnd");
			MenuEnd();
		}
		else if (!stricmp(argv[1], "test1"))
		{
			//draw 1bpp FOSD Palette
			//environmemt
			//	w ff 3
			//	b 8a 0c 66 40
			//	fosd dnfont 0
			//
			DumpFontOsdPalette();
		}
		else if (!stricmp(argv[1], "test2"))
		{
			//FOSD FIFO test.
			Test16x32FontSet();
		}
		else if (!stricmp(argv[1], "test3"))
		{
			TestUpper256Char();
		}
		else if (!stricmp(argv[1], "test4"))
		{
			TestMultiBPP4();
		}
		else if (!stricmp(argv[1], "test5"))
		{
			TestNum1BPP3BPP();
		}
		else if (!stricmp(argv[1], "main1"))
		{
			TestMainMenuImage(1);
		}
		else if (!stricmp(argv[1], "main2"))
		{
			TestMainMenuImage(2);
		}
		else if (!stricmp(argv[1], "main3"))
		{
			TestMainMenuImage(3);
		}

		return;
	}
//	x=a2h(argv[1]);
//	y=a2h(argv[2]);
//   	Printf("\n ECHO: menu x:%d y:%d", x,y);
//	MenuCheckTouchInput(x,y);
}
Beispiel #7
0
int main(int argc, char * argv[])
{
    int flags = 0;
    SDL_Event evt;
    SDL_Surface *tempSurface;

#ifdef _WIN32
    _putenv("SDL_VIDEO_WINDOW_POS=250,200");
#endif

    // Init randomizer
    srand(SDL_GetTicks());

    // Init SDL video
    if (SDL_Init(SDL_INIT_VIDEO) < 0)
        return 255;  // Unable to initialize SDL
    // Prepare screen surface
    g_pSurface = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 16, flags);
    if (g_pSurface == NULL)
        return 254;  // Unable to set video mode

#ifdef _WIN32
    SDL_WM_SetCaption("Color Lines SDL", "Color Lines SDL");
#else
    SDL_ShowCursor(SDL_DISABLE);
#endif

    // Load font
    tempSurface = SDL_LoadBMP("ColorLinesData/font.bmp");
    if (tempSurface == NULL)
        return 253;  // Unable to load bitmap
    g_pFont = SDL_DisplayFormat(tempSurface);
    SDL_FreeSurface(tempSurface);

    // Load sprites
    tempSurface = SDL_LoadBMP("ColorLinesData/sprites.bmp");
    if (tempSurface == NULL)
        return 253;  // Unable to load bitmap
    g_pSprites = SDL_DisplayFormat(tempSurface);
    SDL_FreeSurface(tempSurface);

    MenuStart();

    while (!g_okQuit)
    {
        while (SDL_PollEvent(&evt))
        {
            if (evt.type == SDL_QUIT)
            {
                g_okQuit = 1;
                break;
            }
            else
            {
                if (g_GameMode == GAMEMODE_MENU)
                    MenuProcessEvent(evt);
                else
                    GameProcessEvent(evt);
            }
        }

        if (g_GameMode == GAMEMODE_PLAY)
        {
            DrawGameScreen();
            SDL_Flip(g_pSurface);
        }

        SDL_Delay(20);
    }

    SDL_FreeSurface(g_pSprites);
    SDL_FreeSurface(g_pFont);

    SDL_Quit();

    return 0;
}