Exemplo n.º 1
0
int initgame(){
  loadtexture("all",		 "px.jpg",	4,0,8);
  loadtexture("all",		 "speed.jpg",	4,0,11);
  loadtexture(course[loadc].dir, "lf.jpg",	4,0,2);
  loadtexture(course[loadc].dir, "rt.jpg",	4,0,3);
  loadtexture(course[loadc].dir, "dn.jpg",	4,0,4);
  loadtexture(course[loadc].dir, "up.jpg",	4,0,5);
  loadtexture(course[loadc].dir, "ft.jpg",	4,0,6);
  loadtexture(course[loadc].dir, "bk.jpg",	4,0,7);
  loadtexture(course[loadc].dir, "terrain.jpg",	4,0,9);
  loadtexture(course[loadc].dir, "map.bmp",	4,0,13);
  loadmap    (&course[loadc]);
  
  player.rotvel	=  0;
  player.vel 	=  0;
  player.dir 	=  0;
  player.rotdir =  0;
  player.rot 	=  180;
  player.x   	= -600;
  player.z   	= -1000;

  debugf("Reset Player Variables");
  playmusic("data/music/growler.mp3");
  newgame = 0;
  timestart = SDL_GetTicks();
  printf("\nLoaded Map:\n  %s (data/%s)\n  %s\n\n",
          course[loadc].name, course[loadc].dir,
	  course[loadc].description);

  return 1;
}
Exemplo n.º 2
0
// Duke3D-specific.  --ryan.
// void MUSIC_PlayMusic(char *_filename)
int32_t MUSIC_PlaySong(char *song, int32_t loopflag)
{
//	initprintf("MUSIC_PlaySong");
    MUSIC_StopSong();

    if (external_midi)
    {
        FILE *fp;

#if defined FORK_EXEC_MIDI
        static int32_t sigchld_handler_set = 0;

        if (!sigchld_handler_set)
        {
            struct sigaction sa;
            sa.sa_handler=sigchld_handler;
            sa.sa_flags=0;
            sigemptyset(&sa.sa_mask);

            if (sigaction(SIGCHLD, &sa, NULL)==-1)
                initprintf("%s: sigaction: %s\n", __func__, strerror(errno));

            sigchld_handler_set = 1;
        }
#endif

        fp = Bfopen(external_midi_tempfn, "wb");
        if (fp)
        {
            fwrite(song, 1, g_musicSize, fp);
            Bfclose(fp);

#if defined FORK_EXEC_MIDI
            external_midi_restart = loopflag;
            playmusic();
#else
            music_musicchunk = Mix_LoadMUS(external_midi_tempfn);
            if (!music_musicchunk)
                initprintf("Mix_LoadMUS: %s\n", Mix_GetError());
#endif
        }
        else initprintf("%s: fopen: %s\n", __func__, strerror(errno));
    }
    else
        music_musicchunk = Mix_LoadMUS_RW(SDL_RWFromMem((char *) song, g_musicSize)
#if (SDL_MAJOR_VERSION > 1)
            , SDL_FALSE
#endif
            );

    if (music_musicchunk != NULL)
        if (Mix_PlayMusic(music_musicchunk, (loopflag == MUSIC_LoopSong)?-1:0) == -1)
            initprintf("Mix_PlayMusic: %s\n", Mix_GetError());

    return MUSIC_Ok;
}
Exemplo n.º 3
0
void interruptHandler() {
    static u8 i;

    i++;
    switch (i) {
    case 4:
        cpct_scanKeyboard_if();
        break;
    case 5:
        // Play music
        playmusic();
        break;
    case 6:
        i = 0;
    }
}
Exemplo n.º 4
0
static void sigchld_handler(int signo)
{
    if (signo==SIGCHLD && external_midi_restart)
    {
        int status;

        if (external_midi_pid > 0)
        {
            if (waitpid(external_midi_pid, &status, WUNTRACED)==-1)
                perror("waitpid (3)");

            if (WIFEXITED(status) && WEXITSTATUS(status)==0)
            {
                // loop ...
                playmusic();
            }
        }
    }
}
Exemplo n.º 5
0
int main(int argc , char** argv){
	srand(time(NULL));
	printf("\n\nEnter Player Name:");
	scanf("%s",playerName);
	scoreFile();

	glutInit(&argc, argv);
	glutInitDisplayMode( GLUT_DOUBLE );
	glutInitWindowSize( WIDTH , HEIGHT );
	glutInitWindowPosition(0,0);
	glutCreateWindow("First Window");
	
	init();
	glutDisplayFunc(display);
	//glutIdleFunc(display);
	glutTimerFunc(25, update , 0);
	glutKeyboardFunc(keyboard);

	glutMouseFunc(mouseClick);
	glutMotionFunc(mousePressed);
	//glutPassiveMotionFunc(mousePassiveMotion);
	playmusic();
	glutMainLoop();
}
Exemplo n.º 6
0
void valider (char* texte, Mix_Chunk* gSound, short* musique, Mix_Music* gMusic, short* onoff, SDL_bool* done)
{
    if (strcmp (texte, "yolo") == 0)
    {
        printf ("c est bien\n");
        playsound (1, gSound);
    }
    else if (strcmp (texte, "rick") == 0)
    {
        printf ("c est bien\n");
        playsound (1, gSound);
        SDL_Delay (1000);
        *musique = 5;
        *onoff = 0;
        playmusic (*musique, gMusic);
        *done = SDL_TRUE;
    }
    else if (strcmp (texte, "love") == 0)
    {
        printf ("c est bien\n");
        playsound (1, gSound);
        SDL_Delay (1000);
        *musique = 7;
        *onoff = 0;
        playmusic (*musique, gMusic);
        *done = SDL_TRUE;
    }
    else if (strcmp (texte, "hardcore") == 0)
    {
        printf ("c est bien\n");
        playsound (1, gSound);
        SDL_Delay (1000);
        fenetreJeu ("Hardcore/", 3, 255, 255, 255, gSound, gMusic, musique, onoff,   14316556, 0);
        *done = SDL_TRUE;
    }
    else if (strcmp (texte, "nyan cat") == 0)
    {
        printf ("c est bien\n");
        playsound (1, gSound);
        SDL_Delay (1000);
        *onoff = 0;
        playmusic (8, gMusic);
        fenetreJeu ("Cat/", 0, 255, 255, 255, gSound, gMusic, musique, onoff, 1450, 2);
        *done = SDL_TRUE;
    }
    else if (strcmp (texte, "kubiak") == 0)
    {
        printf ("c est bien\n");
        playsound (1, gSound);
        SDL_Delay (1000);
        *onoff = 0;
        playmusic (7, gMusic);
        fenetreJeu ( "secret/", 0, 255, 105, 180, gSound, gMusic, musique, onoff,   2000, 1);
        *done = SDL_TRUE;
    }
    else if (strcmp (texte, "heyayayay") == 0)
    {
        printf ("c est bien\n");
        playsound (1, gSound);
        SDL_Delay (1000);
        *onoff = 0;
        playmusic (9, gMusic);
        fenetreJeu ( "Hey/", 0, 255, 105, 180, gSound, gMusic, musique, onoff,   1450, 2);
        *done = SDL_TRUE;
    }
    else
    {
        printf ("c est rate\n");
        playsound (2, gSound);
    }

    return;
}
Exemplo n.º 7
0
int main( int argc, char *arvg[] ) {
	int quit = 0;
	int config_status = 0;
	int event;

#ifdef __WIN32__
	freopen( "cabrio.out", "w", stdout );
	freopen( "cabrio.err", "w", stderr );
#endif

	config_status = config_open( NULL );
	if( config_status == -1 )
		return -1;

	if( sdl_init() != 0 )
		bail();

	if( ogl_init() != 0 )
		bail();
	
	/* Clear the screen as soon as we can. This avoids graphics
	 * glitches which can occur with some SDL implementations. */
	ogl_clear();
	sdl_swap();

	if( event_init() != 0 )
		bail();

	if( font_init() != 0 )
		bail();

	if( config_status == 1 ) {
		/* Config file didn't exist, so run the setup utility */
		if( setup() != 0 )
			return -1;
		config_update();
		if( config_create() != 0 )
			return -1;
	}

	location_init();

	/* If config or location results in a new font, it'll be loaded here. */
	font_free();
	font_init();

	/* Large game lists take a while to initialise,
	 * so show the background while we wait... */
	bg_init();
	bg_clear();
	bg_draw();
	sdl_swap();

	if( platform_init() != 0 )
		bail();

	if( category_init() != 0 )
		bail();

	if( game_sel_init() != 0 )
		bail();

	if( hint_init() != 0 )
		bail();

	if( snap_init() != 0 )
		bail();
	
	if( game_list_create() != 0 )
		bail();

	if( menu_init() != 0 )
		bail();

	if( submenu_init() != 0 )
		bail();

	sound_init();
	video_init();
	
	event_flush();

	if( !config_get()->iface.theme.menu.auto_hide )
		menu_show();
		
	focus_set( FOCUS_GAMESEL );

	while( !quit ) {
		ogl_clear();
		bg_draw();
		snap_draw();
		if (!config_get()->iface.hide_buttons)
			hint_draw();
		menu_draw();
		submenu_draw();
		game_sel_draw();
		sdl_swap();
		if (Mix_PlayingMusic() != 1 && config_get()->iface.theme_sound && reader_running == 0) 
			playmusic();
		if (( event = event_poll() )) {
			if( supress_wait == 0 ) {
				if( event == EVENT_QUIT ) {
					quit = 1;
				}
				else {
					supress();
					event_process( event );
				}
			}
		}
		if( supress_wait > 0 )
			supress_wait--;
		
		sdl_frame_delay();
	}
	clean_up();
	return 0;
}
Exemplo n.º 8
0
int initmenu2(void){

  playmusic("data/music/Win.mp3");
  
  return 1;
}
Exemplo n.º 9
0
int initmenu1(void){

  playmusic("data/music/Lose.mp3");
  
  return 1;
}
Exemplo n.º 10
0
int initmenu(void){

  playmusic("data/music/sensation.mp3");
  
  return 1;
}
Exemplo n.º 11
0
void actMinotaurTimer(Entity* my)
{
	node_t* node;

	MINOTAURTIMER_LIFE++;
	if (( (currentlevel < 25 && MINOTAURTIMER_LIFE == TICKS_PER_SECOND * 120)
			|| (currentlevel >= 25 && MINOTAURTIMER_LIFE == TICKS_PER_SECOND * 180)
		)
		&& rand() % 5 == 0 )   // two minutes if currentlevel < 25, else 3 minutes.
	{
		int c;
		bool spawnedsomebody = false;
		for ( c = 0; c < 9; c++ )
		{
			Uint32 zapLeaderUid = 0;
			Entity* monster = summonMonster(HUMAN, my->x, my->y);
			if ( monster )
			{
				monster->skill[29] = 1; // so we spawn a zap brigadier
				spawnedsomebody = true;
				if ( !zapLeaderUid )
				{
					zapLeaderUid = monster->getUID();
				}
				else
				{
					Stat* monsterStats = monster->getStats();
					monsterStats->leader_uid = zapLeaderUid;
				}
			}
		}

		if ( spawnedsomebody )
		{
#ifdef MUSIC
			fadein_increment = default_fadein_increment * 20;
			fadeout_increment = default_fadeout_increment * 5;
			playmusic( sounds[175], false, true, false);
#endif
			for ( c = 0; c < MAXPLAYERS; c++ )
			{
				Uint32 color = SDL_MapRGB(mainsurface->format, 0, 255, 255);
				if ( stats[c]->type == HUMAN )
				{
					messagePlayerColor(c, color, language[1114], stats[c]->name);
				}
				else
				{
					messagePlayerColor(c, color, language[3285]);
				}
			}
		}
	}
	else if (( (currentlevel < 25 && MINOTAURTIMER_LIFE >= TICKS_PER_SECOND * 150)
					|| (currentlevel >= 25 && MINOTAURTIMER_LIFE >= TICKS_PER_SECOND * 210)
				)
		&& !MINOTAURTIMER_ACTIVE )     // two and a half minutes if currentlevel < 25, else 3.5 minutes
	{
		Entity* monster = summonMonster(MINOTAUR, my->x, my->y);
		if ( monster )
		{
			int c;
			for ( c = 0; c < MAXPLAYERS; c++ )
			{
				playSoundPlayer( c, 107 + rand() % 3, 128 );
				Uint32 color = SDL_MapRGB(mainsurface->format, 255, 128, 0);
				messagePlayerColor(c, color, language[1115]);
			}
			MINOTAURTIMER_ACTIVE = MINOTAURTIMER_LIFE;
		}
	}
	if ( MINOTAURTIMER_ACTIVE && MINOTAURTIMER_LIFE >= MINOTAURTIMER_ACTIVE + TICKS_PER_SECOND * 3 )
	{
		int c;
		for ( c = 0; c < MAXPLAYERS; c++ )
		{
			if ( currentlevel < 25 )
			{
				playSoundPlayer(c, 120 + rand() % 3, 128);
				Uint32 color = SDL_MapRGB(mainsurface->format, 255, 0, 255);
				messagePlayerColor(c, color, language[1116]);
				messagePlayerColor(c, color, language[73]);
			}
			else
			{
				playSoundPlayer(c, 375, 128);
				playSoundPlayer(c, 379, 128);
				messagePlayerColor(c, uint32ColorOrange(*mainsurface), language[1116]);
				messagePlayerColor(c, uint32ColorOrange(*mainsurface), language[73]);
				messagePlayerColor(c, uint32ColorBaronyBlue(*mainsurface), language[73]);
			}
		}
		list_RemoveNode(my->mynode);
		return;
	}
}