//---------------------------------------------------------------
// Name: DynamicStarField()
// Desc:
//---------------------------------------------------------------
int DynamicStarField(RECT *starField, int nNumofStars, CVECTOR velVec, int nFrame)
{
	static PARTICLE *stars = new PARTICLE[nNumofStars];
	static RECT tempField = {0,0,1,1};
	
	//reverse the velocity vector so the stars move in the oppsoite direction as the ship
	velVec.Reverse();
	//velVec.y = -velVec.y;
	
	//init the stars
	if(!nFrame) //if first frame
		InitStars(stars, starField, tempField, nNumofStars);
	
	DrawStars(stars, nNumofStars);
	MoveStars(stars, nNumofStars, tempField, velVec);

	if(bDebugMode)
		DebugInfo(stars, nFrame, nNumofStars, tempField);

	return(1);
}
Beispiel #2
0
/*=========================================================================
// Name: main()
// Desc: Entrypoint
//=======================================================================*/
int main(int argc, char *argv[])
{
    printf("-----------------------------------------------------\n");
    printf(" BlueCube (improved version v0.9 hosted on github)   \n");
    printf("    just another tetris clone,                       \n");
    printf("    written by Sebastian Falbesoner <theStack>       \n");
    printf("-----------------------------------------------------\n");
    
    /* First, check whether sound should be activated */
    bSoundActivated = 1;
    if ((argc == 2) && (strcmp(argv[1], "--nosound") == 0)) {
        printf("No sound is used!\n");
        bSoundActivated = 0;
    }

    /* Init randomizer */
    printf("Initializing randomizer... ");
    srand(time(NULL));
    printf("done.\n");
    
    /* Let's init the graphics and sound system */
    printf("Starting up SDL... ");
    InitSDLex();
    printf("done.\n");
    if (bSoundActivated) {
        printf("Initializing sound subsystem... ");
        InitSound();
        printf("done.\n");
    }
    
    /* Load font */
    printf("Loading font files... ");
    font = LoadFontfile("font/font.dat", "font/widths.dat");
    printf("done.\n");

    /* Load soundfiles */
    if (bSoundActivated) {
        printf("Loading sound files... ");
        LoadSound("sound/killline.snd", &sndLine);
        LoadSound("sound/nextlev.snd",  &sndNextlevel);
        printf("done.\n");
    }
    printf("=== Let the fun begin! ===\n");

    /* Init star background */
    InitStars();

    if (bSoundActivated) {
        ClearPlayingSounds();
        SDL_PauseAudio(0);
    }

    /* Start menu first, please... */
    gamestate = STATE_MENU;

    /* Call main loop */
    Mainloop();

    /* Free sounds again */
    if (bSoundActivated) {
        printf("Releasing memory for sound samples... ");
        SDL_FreeWAV(sndLine.samples); 
        SDL_FreeWAV(sndNextlevel.samples);
        printf("done.\n");
    }

    /* Free font again */
    printf("Releasing memory for fonts... ");
    FreeFont(font);
    printf("done.\n");

    return 0;
}