예제 #1
0
// Triggered when break time is done.
void makeBreakFinishedLightGame() {
  // clean leds just in case
  resetEverything();
  // do the game
  for(int counter = 0; counter < 2; counter++) {
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
    delay(1000);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    delay(1000);
  }
  // clean leds
  resetEverything();
}
예제 #2
0
static void createGameLayout( void )
{
	playSong( "Music/play.it" );
	introMode = 0;
	resetEverything( );

	Vector2 basePos = { 50.0f, 50.0f };
	for( basePos.x = 50.0f; basePos.x < 1000.0f; basePos.x += 100.0f ) {
		for( basePos.y = 50.0f; basePos.y < 500.0f; basePos.y += 100.0f ) {
			float chance = randFloat( 0.0f, 1.0f );

			chance -= CHANCE_OF_WIRE_GROUP;
			if( chance <= 0.0f ) {
				layWireGroup( basePos );
				continue;
			}

			chance -= CHANCE_OF_MINE_GROUP;
			if( chance <= 0.0f ) {
				layMineGroup( basePos );
				continue;
			}

			chance -= CHANCE_OF_PIT;
			if( chance <= 0.0f ) {
				layPit( basePos );
			}
		}
	}
}
예제 #3
0
// Called when pomodoro number 12 is reached.
void makePomodoroN12FinishedLightGame() {
  // clean leds just in case
  resetEverything();
  // do the game
  for(int counter = 0; counter < 4; counter++) {
    digitalWrite(2, HIGH);
    digitalWrite(7, HIGH);
    delay(500);
    digitalWrite(3, HIGH);
    digitalWrite(6, HIGH);
    delay(500);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    delay(500);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    delay(500);
    digitalWrite(3, LOW);
    digitalWrite(6, LOW);
    delay(500);
    digitalWrite(2, LOW);
    digitalWrite(7, LOW);
    delay(500);
  }
  delay(500);
}
예제 #4
0
void DriverStation::init()
{
    if (!m_init)
        {
            m_init = true;

            QTimer::singleShot (500, this, SIGNAL (initialized()));
            QTimer::singleShot (500, this, SLOT   (resetEverything()));
            QTimer::singleShot (500, DS_Timers::getInstance(), SLOT (start()));
        }
}
예제 #5
0
// This can run up to 16000 times per second, but most of the time runs around 3000 times per second.
void loop() {
  // check if system should be on
  checkSwitch();
  // main process
  if(systemOn) {
    // inspect serial port looking for input
    inspectSerialPortInput();
  } else {
    // shut down everything
    resetEverything();
  }
}
예제 #6
0
static int gameScreen_Enter( void )
{
	cam_TurnOnFlags( 0, 1 );
	SDL_ShowCursor( SDL_DISABLE );

	setRendererClearColor( 0.878f, 0.807f, 0.667f, 1.0f );

	resetEverything( );

	sideCollisions[OUR_SIDE].type = CT_AABB;
	sideCollisions[OUR_SIDE].aabb.center.x = 500.0f;
	sideCollisions[OUR_SIDE].aabb.center.y = 600.0f + 10.0f;
	sideCollisions[OUR_SIDE].aabb.halfDim.x = 1000.0f;
	sideCollisions[OUR_SIDE].aabb.halfDim.y = 10.0f;

	sideCollisions[THEIR_SIDE].type = CT_AABB;
	sideCollisions[THEIR_SIDE].aabb.center.x = 500.0f;
	sideCollisions[THEIR_SIDE].aabb.center.y = -10.0f;
	sideCollisions[THEIR_SIDE].aabb.halfDim.x = 1000.0f;
	sideCollisions[THEIR_SIDE].aabb.halfDim.y = 10.0f;

	sideCollisions[LEFT_SIDE].type = CT_AABB;
	sideCollisions[LEFT_SIDE].aabb.center.x = -10.0f;
	sideCollisions[LEFT_SIDE].aabb.center.y = 300.0f;
	sideCollisions[LEFT_SIDE].aabb.halfDim.x = 10.0f;
	sideCollisions[LEFT_SIDE].aabb.halfDim.y = 1000.0f;

	sideCollisions[RIGHT_SIDE].type = CT_AABB;
	sideCollisions[RIGHT_SIDE].aabb.center.x = 1000.0f + 10.0f;
	sideCollisions[RIGHT_SIDE].aabb.center.y = 300.0f;
	sideCollisions[RIGHT_SIDE].aabb.halfDim.x = 10.0f;
	sideCollisions[RIGHT_SIDE].aabb.halfDim.y = 1000.0f;

	sideColliders.firstCollider = sideCollisions;
	sideColliders.count = 4;
	sideColliders.stride = sizeof( union Collider );

	//createGameLayout( );
	createIntroLayout( );

	playSong( "Music/intro.it" );

	return 1;
}
예제 #7
0
// Called when pomodoro number 22 is reached.
void makePomodoroN22FinishedLightGame() {
  // clean leds just in case
  resetEverything();
  // do the game
  int led;
  bool currentState = 1;
  digitalWrite(2, HIGH);
  delay(100);
  digitalWrite(2, LOW);
  for(int counter = 0; counter < 20; counter++) {
    for(led = 3; led < 8; led++) {
      digitalWrite(led, HIGH);
      delay(100);
      digitalWrite(led, LOW);
    }
    for(led = 6; led > 1; led--) {
      digitalWrite(led, HIGH);
      delay(100);
      digitalWrite(led, LOW);
    }
  }
}
예제 #8
0
static void gameScreen_ProcessEvents( SDL_Event* e )
{
	if( e->type == SDL_MOUSEBUTTONDOWN ) {
		int mouseX;
		int mouseY;
		SDL_GetMouseState( &mouseX, &mouseY );

		if( e->button.button == SDL_BUTTON_RIGHT ) {
			launchFromPosition.x = (float)mouseX;
		} else if( e->button.button == SDL_BUTTON_LEFT ) {
			if( testAndDeductDrum( ) >= 1.0f ) {
				launchPanjandrum( launchFromPosition, launchToPosition );
			}
		}
	}

	if( e->type == SDL_KEYDOWN ) {
		if( e->key.keysym.sym == SDLK_r ) {
			resetEverything( );
		}
	}
}
예제 #9
0
파일: asspong.c 프로젝트: davido262/asspong
void processEvents_ASM(BOOL* isRunning) {
    char key = 0;
    while (kbhit()) {
        //key = getch();
        _asm {
            mov ah, 00h     // Get keystroke
            int 16h
            mov key, al     // Get character
        }
        key = tolower(key);
        switch (key) {
        case 27: // ESC
    //     case 'q':
            *isRunning = FALSE;
            break;
        case ' ':
            resetEverything();
            break;

        case 'w':
            g_isKeyDownW = TRUE;
            break;
        case 's':
            g_isKeyDownS = TRUE;
            break;

        case 'o':
            g_isKeyDownO = TRUE;
            break;
        case 'l':
            g_isKeyDownL = TRUE;
            break;

        default:
            break;
        }
    }
}
예제 #10
0
// Executes the light game triggered by the finish of a pomodoro.
void makePomodoroFinishedLightGame() {
  // clean leds just in case
  resetEverything();
  // do the game
  for(int counter = 0; counter < 5; counter++) {
    // turn off all green leds
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    // rest
    delay(1000);
    // turn on all green leds
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    // rest
    delay(1000);
  }
  // and off every green leds
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  delay(1000);
}
예제 #11
0
static void createIntroLayout( void )
{
	introMode = 1;
	resetEverything( );

	startCollider.type = CT_AABB;
	startCollider.aabb.center.x = 481.0f;
	startCollider.aabb.center.y = 198.0f;
	startCollider.aabb.halfDim.x = 72.0f;
	startCollider.aabb.halfDim.y = 27.0f;

	Vector2 spawnPos;
	spawnPos.x = 500.0f;

	spawnPos.y = 334.0f;
	spawnBarbedWire( spawnPos );

	spawnPos.y = 495.0f;
	spawnPit( spawnPos );
	spawnTroop( spawnPos, 1 );

	spawnPos.y = 410.0f;
	layMineGroup( spawnPos );
}
예제 #12
0
파일: asspong.c 프로젝트: davido262/asspong
// main function
int main(void) {
    clock_t startTime;
    BOOL isRunning = TRUE;

    // introduction
    printf("    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+\n");
    printf("    |               CC322 - Organizacion de Computadoras I                 |\n");
    printf("    |                            .-----------.                             |\n");
    printf("    |                           /   AssPong   \\                            |\n");
    printf("    |                          '==============='                           |\n");
    printf("    |                                                                      |\n");
    printf("    |                          *** Equipo 9 ***                            |\n");
    printf("    |                          Cavazos Woo David                           |\n");
    printf("    |                      Corona Garcia Erick Daniel                      |\n");
    printf("    |                                                                      |\n");
    printf("    |    Instrucciones:                                                    |\n");
    printf("    |        [ESC]   Salir                                                 |\n");
    printf("    |        [SPACE] Reset                                                 |\n");
    printf("    |        [w]     Mover jugador 1 arriba                                |\n");
    printf("    |        [s]     Mover jugador 1 abajo                                 |\n");
    printf("    |        [o]     Mover jugador 2 arriba                                |\n");
    printf("    |        [l]     Mover jugador 2 abajo                                 |\n");
    printf("    |                                                                      |\n");
    printf("    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+\n");
    printf("Usando contexto de ASM\n");
    printf("Presione [Enter] para continuar...");
    _asm {
        mov ah, 10h
        int 16h
    }

    system(PLAY_MUSIC);
    initializeVideoContext_ASM();

    srand((unsigned int)(time(0)));
    initializeDimensions();
    resetEverything();

    g_deltaTime = 0.0;
    g_player1Wins = 0;
    g_player2Wins = 0;

    g_isKeyDownW = FALSE;
    g_isKeyDownS = FALSE;
    g_isKeyDownO = FALSE;
    g_isKeyDownL = FALSE;

    // main loop
    while (isRunning) {
        startTime = clock();

        // update
        g_isKeyDownW = FALSE;
        g_isKeyDownS = FALSE;
        g_isKeyDownO = FALSE;
        g_isKeyDownL = FALSE;
        processEvents_ASM(&isRunning);
        update();

        // draw
        clearScreen_ASM();
        drawEverything();

        // framerate cap
//         g_deltaTime = MILLISECONDS_CAP;
//         delay((unsigned int)MILLISECONDS_CAP);
//         g_deltaTime *= 0.001;

        g_deltaTime = (double)(clock() - startTime) / (double)CLOCKS_PER_SEC * 1000.0;
        if (MILLISECONDS_CAP > g_deltaTime)
            delay((unsigned int)(MILLISECONDS_CAP - g_deltaTime));
        g_deltaTime = (double)(clock() - startTime) / (double)CLOCKS_PER_SEC;
    }

    // shutdown
    system(STOP_MUSIC);

    // show winner
    system("cls");
    printf("\n");
    printf("                       .--------------------------------.\n");
    printf("                      /   ");
    if (g_player1Wins == g_player2Wins)
        printf("  ~~~~ Empate ~~~~ ");
    else if (g_player1Wins > g_player2Wins)
        printf("Ganador: Jugador 1 ");
    else
        printf("Ganador: Jugador 2 ");
    printf("(%2u : %2u)   \\\n", g_player1Wins, g_player2Wins);
    printf("                     '===================================='\n");
    printf("Presione [Enter] para salir...");
    _asm {
        mov ah, 00h
        int 16h
    }

    return EXIT_SUCCESS;
}
예제 #13
0
void processEvents_SDL(BOOL* isRunning) {
    SDL_Event event;
    while (SDL_PollEvent(&event)) {
        switch (event.type) {
        case SDL_QUIT:
            *isRunning = FALSE;
            break;

        case SDL_KEYDOWN:
            switch (event.key.keysym.sym) {
            // quit
            case SDLK_ESCAPE:
                *isRunning = FALSE;
                break;
            // reset
            case SDLK_SPACE:
                resetEverything();
                break;

            // player 1
            case SDLK_w:
                g_isKeyDownW = TRUE;
                break;
            case SDLK_s:
                g_isKeyDownS = TRUE;
                break;

            // player 2
            case SDLK_UP:
                g_isKeyDownUP = TRUE;
                break;
            case SDLK_DOWN:
                g_isKeyDownDOWN = TRUE;
                break;

            default:
                break;
            }
            break;

        case SDL_KEYUP:
            switch (event.key.keysym.sym) {
            // player 1
            case SDLK_w:
                g_isKeyDownW = FALSE;
                break;
            case SDLK_s:
                g_isKeyDownS = FALSE;
                break;

            // player 2
            case SDLK_UP:
                g_isKeyDownUP = FALSE;
                break;
            case SDLK_DOWN:
                g_isKeyDownDOWN = FALSE;
                break;

            default:
                break;
            }
            break;

        default:
            break;
        }
    }
}
예제 #14
0
// main function
int main(int, char**) {
    // introduction
    printf("    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+\n");
    printf("    |               CC322 - Organizacion de Computadoras I                 |\n");
    printf("    |                            .-----------.                             |\n");
    printf("    |                           /   AssPong   \\                            |\n");
    printf("    |                          '==============='                           |\n");
    printf("    |                                                                      |\n");
    printf("    |                          *** Equipo 9 ***                            |\n");
    printf("    |                          Cavazos Woo David                           |\n");
    printf("    |                      Corona Garcia Erick Daniel                      |\n");
    printf("    |                                                                      |\n");
    printf("    |    Instrucciones:                                                    |\n");
    printf("    |        [ESC]   Salir                                                 |\n");
    printf("    |        [SPACE] Reset                                                 |\n");
    printf("    |        [w]     Mover jugador 1 arriba                                |\n");
    printf("    |        [s]     Mover jugador 1 abajo                                 |\n");
    printf("    |        [UP]    Mover jugador 2 arriba                                |\n");
    printf("    |        [DOWN]  Mover jugador 2 abajo                                 |\n");
    printf("    |                                                                      |\n");
    printf("    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+\n");

    initialize_SDL();

    // SDL_mixer initialization
    Mix_OpenAudio(AUDIO_FREQUENCY, MIX_DEFAULT_FORMAT, AUDIO_CHANNELS, AUDIO_BUFFER_SIZE);
    g_music = Mix_LoadMUS("still_alive.ogg");

    printf("Presione [Enter] para continuar...");
    getchar();

    initializeVideoContext_SDL();

    // play music
    if (g_music == 0)
        printf("Unable to load music: %s", Mix_GetError());
    else
        Mix_PlayMusic(g_music, -1);

    srand((unsigned int)(time(0)));
    initializeDimensions();
    resetEverything();

    g_deltaTime = 0.0;
    g_player1Wins = 0;
    g_player2Wins = 0;

    g_isKeyDownW = FALSE;
    g_isKeyDownS = FALSE;
    g_isKeyDownUP = FALSE;
    g_isKeyDownDOWN = FALSE;

    // main loop
    Uint32 startTime;
    BOOL isRunning = TRUE;
    while (isRunning) {
        startTime = SDL_GetTicks();

        // update
        processEvents_SDL(&isRunning);
        update();

        // draw
        clearScreen_SDL();
        drawEverything();
        SDL_Flip(g_screen); // flip buffers

        // framerate cap
        g_deltaTime = SDL_GetTicks() - startTime;
        if (MILLISECONDS_CAP > g_deltaTime)
            SDL_Delay((Uint32)(MILLISECONDS_CAP - g_deltaTime));
        g_deltaTime = (SDL_GetTicks() - startTime) * 0.001;

        // show framerate
//        stringstream title;
//        title << "Pong - " << setprecision(1) << fixed <<
//                        (g_deltaTime == 0.0? double(FRAMERATE_CAP) : 1.0 / g_deltaTime) << " fps";
//        SDL_WM_SetCaption(title.str().c_str(), "");
    }

    // shutdown
    Mix_FreeMusic(g_music);
    Mix_CloseAudio();
    shutdown_SDL();

    // show winner
    printf("\n");
    printf("                       .--------------------------------.\n");
    printf("                      /   ");
    if (g_player1Wins == g_player2Wins)
        printf("  ~~~~ Empate ~~~~ ");
    else if (g_player1Wins > g_player2Wins)
        printf("Ganador: Jugador 1 ");
    else
        printf("Ganador: Jugador 2 ");
    printf("(%2u : %2u)   \\\n", g_player1Wins, g_player2Wins);
    printf("                     '===================================='\n");
    printf("Presione [Enter] para salir...");
    getchar();

    return EXIT_SUCCESS;
}