Ejemplo n.º 1
0
void main()
{
	ENABLE_RAM_MBC1;
	SWITCH_ROM_MBC1(7);
    kwakwa_screen();
	//disable_APA();
	credits = 0U;
	while(1)
	{
		ENABLE_RAM_MBC1;
		SWITCH_ROM_MBC1(7);
		title_screen();
		credits = 0U;
		reset_game();
		disable_APA();
		while(credits == 0U)
		{

			game_screen();

		}
		//disable_APA();
		ENABLE_RAM_MBC1;
		SWITCH_ROM_MBC1(7);
		credits_screen();
		disable_APA();
	}
}
Ejemplo n.º 2
0
//determines what level of game to run
void Game::level_control()
{
    //create white outline for window
    SDL_Rect outline = { 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT };
    
    //determine level to run
    while ( level != END )
    {
        //if queued level is title screen
        if ( level == TITLE )
            //initiate title screen loop
            title_screen(outline);
        
        //if queued level is computer battle
        else if ( level == COMPUTER_BATTLE )
            //initiate computer battle game loop
            computer_battle(outline);
        
        //if queued level is player battle
        else if ( level == PLAYER_BATTLE )
            //initiate player battle game loop
            player_battle(outline);
        
        else if (level == INSTRUCTIONS )
            //initiate instructions loop
            instructions(outline);
    }
}
Ejemplo n.º 3
0
bool game_config_manager::init_game_config(FORCE_RELOAD_CONFIG force_reload)
{
	// Add preproc defines according to the command line arguments.
	game_config::scoped_preproc_define multiplayer("MULTIPLAYER",
		cmdline_opts_.multiplayer);
	game_config::scoped_preproc_define test("TEST", cmdline_opts_.test);
	game_config::scoped_preproc_define editor("EDITOR", jump_to_editor_);
	game_config::scoped_preproc_define title_screen("TITLE_SCREEN",
		!cmdline_opts_.multiplayer && !cmdline_opts_.test && !jump_to_editor_);

	load_game_config(force_reload);

	game_config::load_config(game_config_.child("game_config"));

	hotkey::deactivate_all_scopes();
	hotkey::set_scope_active(hotkey::SCOPE_GENERAL);
	hotkey::set_scope_active(hotkey::SCOPE_GAME);

	hotkey::load_hotkeys(game_config(), true);
	::init_textdomains(game_config());
	about::set_about(game_config());
	ai::configuration::init(game_config());

	return true;
}
Ejemplo n.º 4
0
int main()
{
	int odds[8];
	int player1[5], player2[5];
	int position[8]={0,0,0,0,0,0,0,0};
	int count;
	int winner;
	char more_race='Y';

//Player array, slot0=money total, slot1=horse bet on, slot2=bet amount, slot3=odds of bet
//slot4=original cash level.
	srand(time(0));

	title_screen();
	get_cash(player1,1);
	get_cash(player2,2);

	do
	{
	for(count=0;count<8;count++)
		position[count]=0;
	winner=6000;
	generate_odds(odds,8);
    disp_odds(odds);
	bet(player1,1,odds);
    disp_odds(odds);
	bet(player2,2,odds);

	do
	{
	for(count=0;count<8;count++)
		{	
		position[count]+=move_horse(odds, count);
		if(position[count]>=50)
			winner=count;
		}
	disp_race(position);
	}
	while(winner==6000);
	
	cout<<"\nThe winning horse is horse "<<winner+1<<endl;
	player1[0]+=payoff(winner, player1,1);
	player2[0]+=payoff(winner, player2,2);

	if((player1[0]<=0)||(player2[0]<=0))
		more_race='n';
	else
		{
		cout<<"\nWould you like another race? (Y/N)\n";
		cin>>more_race;
		}
	}
	while((more_race=='Y')||(more_race=='y'));

	final_results(player1,player2);

	return 0;
}
Ejemplo n.º 5
0
void main()
{

	kwakwa_screen();
	DISPLAY_OFF;
	disable_APA();

	while(1)
	{
		title_screen();
		DISPLAY_OFF;
		disable_APA();

		game_screen();
	}
}
Ejemplo n.º 6
0
int main(int argc, char *argv[])
{
   int c, w, h;
   char buf[256], buf2[256];
   ANIMATION_TYPE type;

   for (c = 1; c < argc; c++) {
      if (stricmp(argv[c], "-cheat") == 0)
         cheat = TRUE;

      if (stricmp(argv[c], "-jumpstart") == 0)
         jumpstart = TRUE;
   }

   /* The fonts we are using don't contain the full latin1 charset (not to
    * mention Unicode), so in order to display correctly author names in
    * the credits with 8-bit characters, we will convert them down to 7
    * bits with a custom mapping table. Fortunately, Allegro comes with a
    * default custom mapping table which reduces Latin-1 and Extended-A
    * characters to 7 bits. We don't even need to call set_ucodepage()!
    */
   set_uformat(U_ASCII_CP);
   
   srand(time(NULL));
   if (allegro_init() != 0)
      return 1;
   install_keyboard();
   install_timer();
   install_mouse();

   if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0) {
      allegro_message("Error initialising sound\n%s\n", allegro_error);
      install_sound(DIGI_NONE, MIDI_NONE, NULL);
   }

   if (install_joystick(JOY_TYPE_AUTODETECT) != 0) {
      allegro_message("Error initialising joystick\n%s\n", allegro_error);
      install_joystick(JOY_TYPE_NONE);
   }

   if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0) {
      if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0) {
         set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
         allegro_message("Unable to set any graphic mode\n%s\n",
                         allegro_error);
         return 1;
      }
   }

   get_executable_name(buf, sizeof(buf));
   replace_filename(buf2, buf, "demo.dat", sizeof(buf2));
   set_color_conversion(COLORCONV_NONE);
   data = load_datafile(buf2);
   if (!data) {
      set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
      allegro_message("Error loading %s\n", buf2);
      exit(1);
   }

   if (!jumpstart) {
      intro_screen();
   }

   clear_bitmap(screen);
   set_gui_colors();
   set_mouse_sprite(NULL);

   if (!gfx_mode_select(&c, &w, &h))
      exit(1);

   if (pick_animation_type(&type) < 0)
      exit(1);

   init_display(c, w, h, type);

   generate_explosions();

   //stop_sample(data[INTRO_SPL].dat);

   clear_bitmap(screen);

   while (title_screen())
      play_game();

   destroy_display();

   destroy_explosions();

   stop_midi();

   set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);

   end_title();

   unload_datafile(data);

   allegro_exit();

   return 0;
}
Ejemplo n.º 7
0
int main() {
    // randomize
    srand(time(NULL));
    
    // make sure game resets at the beginning
    int restart = 1;
    
    // initialize values
    int x, y, endX, endY;
    int map[mapX][mapY] = {0};
    
    // display title screen
    title_screen();
    
    // wait for user to press the key
    int h; h = getch();
    
    // get console data
    struct winsize max;
    ioctl(0, TIOCGWINSZ , &max);
    
    // if key is l, load game state
    if (h==108) {
        save_load(&map,&x,&y,&endX,&endY, A_LOAD); // load previous state
        restart = 0; // make sure game won't restart
        usleep(600000); // make sure user got time to read
    }
    
    int is_running = 1;
    
    // game loop
    while (is_running) {
        // check if player got to the end
        if (x == endX && y == endY) {
            finished_screen(max.ws_col-1, max.ws_row-1);
            restart = 1; // make sure game restarts
        }
        
        // if restart is set to 1, reset all values
        if (restart == 1) {
            x = 1; y = 1;
            hardcore_mapgen(&map, &endX, &endY);
            restart = 0;
        }
        
        // draw map on screen
        draw_map(&map,max.ws_col, max.ws_row, x, y, endX, endY);
        
        h = move(&map, &x, &y);
        switch (h) {
            case G_SAVE:
                save_load(&map,&x,&y,&endX,&endY, A_SAVE);
                break;
            case G_QUIT:
                is_running = 0;
                break;
            case G_RESET:
                restart = 1;
                break;
            case G_LOAD:
                save_load(&map,&x,&y,&endX,&endY, A_LOAD);
                break;
        }
    }
    
    return 0;
}
Ejemplo n.º 8
0
/* the main program body */
int main(int argc, char *argv[])
{
   ALLEGRO_PATH *font_path;
   int w = 0, h = 0;
   int www = FALSE;
   int i, n;
   int display_flags = ALLEGRO_GENERATE_EXPOSE_EVENTS;

   srand(time(NULL));
   
   al_set_org_name("liballeg.org");
   al_set_app_name("SPEED");

   if (!al_init()) {
      fprintf(stderr, "Could not initialise Allegro.\n");
      return 1;
   }
   al_init_primitives_addon();

   /* parse the commandline */
   for (i=1; i<argc; i++) {
      if (strcmp(argv[i], "-cheat") == 0) {
         cheat = TRUE;
      }
      else if (strcmp(argv[i], "-simple") == 0) {
         low_detail = TRUE;
      }
      else if (strcmp(argv[i], "-nogrid") == 0) {
         no_grid = TRUE;
      }
      else if (strcmp(argv[i], "-nomusic") == 0) {
         no_music = TRUE;
      }
      else if (strcmp(argv[i], "-www") == 0) {
         www = TRUE;
      }
      else if (strcmp(argv[i], "-fullscreen") == 0) {
         /* if no width is specified, assume fullscreen_window */
         display_flags |= w ? ALLEGRO_FULLSCREEN : ALLEGRO_FULLSCREEN_WINDOW;
      }
      else {
         n = atoi(argv[i]);

         if (!n) {
            usage();
            return 1;
         }

         if (!w) {
            w = n;
            if (display_flags & ALLEGRO_FULLSCREEN_WINDOW) {
               /* toggle from fullscreen_window to fullscreen */
               display_flags &= ~ALLEGRO_FULLSCREEN_WINDOW;
               display_flags |= ALLEGRO_FULLSCREEN;
            }
         }
         else if (!h) {
            h = n;
         }
         else {
            usage();
            return 1;
         }
      }
   }

   /* it's a real shame that I had to take this out! */
   if (www) {
      printf(
	 "\n"
	 "Unfortunately the built-in web browser feature had to be removed.\n"
	 "\n"
	 "I did get it more or less working as of Saturday evening (forms and\n"
	 "Java were unsupported, but tables and images were mostly rendering ok),\n"
	 "but the US Department of Justice felt that this was an unacceptable\n"
	 "monopolistic attempt to tie in web browsing functionality to an\n"
	 "unrelated product, so they threatened me with being sniped at from\n"
	 "the top of tall buildings by guys with high powered rifles unless I\n"
	 "agreed to disable this code.\n"
	 "\n"
	 "We apologise for any inconvenience that this may cause you.\n"
      );

      return 1;
   }
   
   if (!w || !h) {
      if (argc == 1 || (display_flags & ALLEGRO_FULLSCREEN_WINDOW)) {
         w = 640;
         h = 480;
      }
      else {
         usage();
         return 1;
      }
   }

   /* set the screen mode */
   al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST);
   al_set_new_display_option(ALLEGRO_SAMPLES, 4, ALLEGRO_SUGGEST);

   al_set_new_display_flags(display_flags);
   screen = al_create_display(w, h);
   if (!screen) {
      fprintf(stderr, "Error setting %dx%d display mode\n", w, h);
      return 1;
   }

   al_init_image_addon();

   /* The Allegro 5 port introduced an external data dependency, sorry.
    * To avoid performance problems on graphics drivers that don't support
    * drawing to textures, we build up transition screens on memory bitmaps.
    * We need a font loaded into a memory bitmap for those, then a font
    * loaded into a video bitmap for the game view. Blech!
    */
   font_path = get_resources_path();
   al_set_path_filename(font_path, "a4_font.tga");

   al_init_font_addon();
   al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP);
   font = al_load_bitmap_font(al_path_cstr(font_path, '/'));
   if (!font) {
      fprintf(stderr, "Error loading %s\n", al_path_cstr(font_path, '/'));
      return 1;
   }

   al_set_new_bitmap_flags(ALLEGRO_VIDEO_BITMAP);
   font_video = al_load_bitmap_font(al_path_cstr(font_path, '/'));
   if (!font_video) {
      fprintf(stderr, "Error loading %s\n", al_path_cstr(font_path, '/'));
      return 1;
   }
   
   al_destroy_path(font_path);

   /* set up everything else */
   al_install_keyboard();
   al_install_joystick();
   if (al_install_audio()) {
      if (!al_reserve_samples(8))
         al_uninstall_audio();
   }

   init_input();
   init_sound();
   init_hiscore();

   /* the main program body */
   while (title_screen()) {
      if (play_game()) {
	 show_results();
	 score_table();
      }
   }

   /* time to go away now */
   shutdown_hiscore();
   shutdown_sound();

   goodbye();

   shutdown_input();

   al_destroy_font(font);
   al_destroy_font(font_video);

   return 0;
}
Ejemplo n.º 9
0
void main(void){
	char i,joker_runtime,j1,j2;

	*(char*)0x0328 = 0xfc;	//block run/stop
	cputc(0x8);		//block shift-cbm

//	*(char*)0xd020 = 0x03;
//	cgetc();
	
	clrscr();
	setgfx(0x0428);
	revers(1);textcolor(15);cputsxy(5,11,"[l]oad or [r]eset highscores?");
	
	if (yesno()){
		load_hs();
	}
	else{
		for(i=0;i<10;++i){
			strcpy (highscore[i].name,"----------");
			highscore[i].level = 0;
			highscore[i].score = 0;
		}
	}

	while (1){
		ass_setup();
		memmove((char*)0xe000,&bmp_data,LINES*320);
		memmove((char*)0xcc00,(char*)(&bmp_data + LINES*320),LINES*40);
		title_screen();

		memset((char*)0xdbc0,15,40);
		
		level = score[0] = xpos1 = ypos1 = joker = time_out = no_more_moves_flag = 0;
		if (players){
			xpos2 = 1; ypos2 = score[1] = 0;
		}
		
		time1 = 160;
		animals = 7;

		while (1){
			if (time_out){
				stop = 1;
				vic->spr_ena = 0;
				init_msx(4);
				if (joker==0){
					check_moves();

					if (pm_x1 == pm_x2){
						clone(pm_y1+1,pm_x1,1);
						print3x3(EMPTY_SYMB,pm_x1,pm_y1+1);
					}
					else{
						clone(pm_y1,pm_x1+1,1);
						print3x3(EMPTY_SYMB,pm_x1+1,pm_y1);
					}
					clone(pm_y1,pm_x1,0);
					print3x3(EMPTY_SYMB,pm_x1,pm_y1);
					vic->spr_ena = 3;

					while (*(char*)0xdc00 != 111){
						vic->spr_ena ^= 3;
						delay(30);
					}
				}
				else{
					while(*(char*)0xdc00 != 111);
					//kill_joker();
				}
				broesel();
				time_out_screen();
				break;
			}

			//check for level up
			for (i=0;i<animals;++i){
				if (hits[i])
					break;
			}
			
			if (level == 0 || i == animals){
				stop = 1;
				kill_joker();
				init_msx(((level%2)>>1) + 3);
				if (++level != 1){
					broesel();
				}
				if (level == 5){
					animals = 8;
				}
				if (level == 17){
					all_done();
					time_out_screen();
					break;
				}

				xpos1 = 3; ypos1 = 3;
				vic->spr7_x = 39+3*24;
				vic->spr7_y = 50+3*24;
				if (players){
					xpos2 = ypos2 = 4;
					vic->spr6_x = 39+4*24;
					vic->spr6_y = 50+4*24;
				}
				else{
					vic->spr6_x = vic->spr6_y = 0;
				}
				memset(hits,(level+2),8);

				level_up_screen();
				init_msx(~level%2);
				print_matrix();
				timer_delay = level_time[level-1];
				memset((char*)0xdbc0,0x0f,40);
				stop = no_more_moves_flag = key = 0;
			}
			if (no_more_moves_flag){
				stop = 1;
				no_more_moves();
				print_matrix();
				stop = no_more_moves_flag = 0;
			}
			if (!isstop()){
				stop = 1;
				//kill_joker();
				memcpy(backup,matrix,64);
				broesel();
				pause_screen();
				memcpy(matrix,backup,64);
				print_matrix();
				stop = 0;
			}
			if (key == CH_F8){
				stop = 1;
				//kill_joker();
				key = 0;
				broesel();
				break;
			}
			// if a joker exists, check its runtime and destroy if needed
			if(joker == 1 && (clock() - jok1)/CLOCKS_PER_SEC >= joker_runtime){
				kill_joker();
				if (!check_moves()){
					stop = 1;
					no_more_moves();
					print_matrix();
					stop = no_more_moves_flag = 0;
				}
			}

					

			// if no joker exists, create one on random number
			if (joker == 0 && random() == 0xea && random() >= 0xff){
				joker = 1;
				random(); random();
				joker_x = random() & 7;
				joker_y = random() & 7;
				matrix[joker_y][joker_x] = JOKER_SYMB;
				while ((joker_runtime = random() & 7) < 3);				
				jok1 = clock();
			}
			
			// joystick
			if (demo){
				if (*(char*)0xdc00 == 111 || *(char*)0xdc01 == 239){
					//kill_joker();
					broesel();
					break;
				}
 				if (cue_max == 0){
					if (pm_x1 > xpos1){
						for (i=0;i<(pm_x1-xpos1);++i)
							put2cue(119);
					}
					else{
						for (i=0;i<(xpos1-pm_x1);++i)
							put2cue(123);
					}
					if (pm_y1 > ypos1){
						for (i=0;i<(pm_y1-ypos1);++i)
							put2cue(125);
					}
					else{
						for(i=0;i<(ypos1-pm_y1);++i)
							put2cue(126);
					}
				}
			       	while (cue_max);
				delay(50);
//				s_temp = score[0];
				swap (xpos1,ypos1,pm_x2-pm_x1,pm_y2-pm_y1);
				/*				
				if (score[0] == s_temp){
					vic->bordercolor++;
					while(1);
				}
				*/
				
				delay(50);
				continue;
			}
			if((j1 = *(char*)(0xdc00 + tt)&0x7f) != nothing){
				pl = 0;
				if (j1 == fire_up){
					if (ypos1) swap (xpos1,ypos1,0,-1);
				}
				if (j1 == fire_down){
					if (ypos1 < 7) swap(xpos1,ypos1,0,1);
				}
				if (j1 == fire_left){
					if (xpos1) swap (xpos1,ypos1,-1,0);
				}
				if (j1 == fire_right){
					if (xpos1 < 7) swap (xpos1,ypos1,1,0);
				}
				if (j1 == 111){
					if (matrix[ypos1][xpos1] == JOKER_SYMB){
						joker_hit(pl);
					}
				}
			}
			if (players){
				if((j2 = *(char*)0xdc01) != 255){
					pl = 1;
					if (j2 == 238){
						if (ypos2) swap (xpos2,ypos2,0,-1);
					}
					if (j2 == 237){
						if (ypos2 < 7) swap(xpos2,ypos2,0,1);
					}
					if (j2 == 235){
						if (xpos2) swap (xpos2,ypos2,-1,0);
					}
					if (j2 == 231){
						if (xpos2 < 7) swap (xpos2,ypos2,1,0);
					}
					if (j2 == 239){
						if (matrix[ypos2][xpos2] == JOKER_SYMB){
							joker_hit(pl);
						}
					}
				}
			}
		}	
	}
Ejemplo n.º 10
0
/**
 * Documentation here
 */
void main_menu()
{


  MENU *my_menu;
  /* Order here doesn't matter. Name (the first item in each of these
     "pairs") does. If you change the name, change the selection
     handling code towards the end of this function. */
  char *my_choices[] = {
    "Create","(Create new termship game)",
    "Join", "(Join existing termship game on network)",
    "Exit", "",
    (char *)NULL, (char *)NULL
  };
  ITEM **my_items;
  int n_choices = ARRAY_SIZE(my_choices)/2;

  /* some testing modes: */
#ifdef TEST_SHIPS
  initShips();
  return;
#endif

  keypad(stdscr, TRUE);
  curs_set(0); // make cursor invisible
  noecho();
  title_screen();

  clear();

  my_items = (ITEM **)calloc(n_choices,sizeof(ITEM *));
  for (int i=0; my_choices[i*2]!=NULL; ++i) {
    /* i*2 since we're iterating in pairs */
    my_items[i] = new_item(my_choices[(i*2)], my_choices[(i*2)+1]);
  }

  my_menu = new_menu(my_items);
  set_menu_mark(my_menu, "   * ");
  post_menu(my_menu);
  refresh();

  int c;
  while ((c = getch()) != 10) {
    switch (c) {
    case KEY_DOWN:
      menu_driver(my_menu, REQ_DOWN_ITEM);
      break;
    case KEY_UP:
      menu_driver(my_menu, REQ_UP_ITEM);
      break;
    }
  }
  ITEM *cur = current_item(my_menu);
  const char *selected_name = item_name(cur);
  
  /* delete the menu, free resources */
  for (int i=0; i<n_choices-1; ++i) {
    free_item(my_items[i]);
  }
  /* free(my_items); */
  unpost_menu(my_menu);
  free_menu(my_menu);

  if (0==strcmp(selected_name, "Create")) {
    user_mode = SERVER_MODE;
    get_text_string_from_centered_panel("Enter your name",
                    global_user_name,
                    MAX_NAME);
    init_game(user_mode);
  } else if (0==strcmp(selected_name, "Join")) {
    user_mode = CLIENT_MODE;
    get_text_string_from_centered_panel("Enter your name",
                    global_user_name,
                    MAX_NAME);
    init_game();
  }

  return;
}
Ejemplo n.º 11
0
int main( int argv, char* argc[])
{
    //create the hole objects
    Hole Hole1 = Hole(100, -5);
    Hole Hole2 = Hole(80, 20);
    Hole Hole3 = Hole(75, -10);
    Hole Hole4 = Hole(90, 0);
    Hole Hole5 = Hole(60, 15);
    
    int score = 0;
    int currentHole = 1;    
    int player;   
    
    //call title screen
    player = title_screen();
    //return num 1-4
    //create all four playable characters
    Player jimmy = Player("Jimmy Mickle",5,4,"../../music/Harder_than_you_think.wav");
    Player nick = Player("Nick Lance",4,5,"../../music/Mind_heist.wav");
    Player dylan = Player("Dylan Freechild",3,5,"../../music/Who_did_that_to_you.wav");
    Player dan = Player("Dan Bolivar",2,2,"../../music/Hymn.wav");
    Player *myPlayer = NULL;
 
    //choose player from title screen
    switch(player) {
    	case 1:
    		myPlayer = &jimmy;
    		break;
    	case 2:
    		myPlayer = &nick;
    		break;
    	case 3:
    		myPlayer = &dylan;
    		break;
    	case 4:
    		myPlayer = &dan;
    		break;
    	default:
    		myPlayer = &jimmy;
		break;
    }
    
    // choose the current hole to play
    while( currentHole < 6)
    {
        switch( currentHole )
        {
            case 1: 
              playHole(1, Hole1, *myPlayer, &score);
            break;
            case 2: 
              playHole(2, Hole2, *myPlayer, &score);
            break;
            case 3: 
              playHole(3, Hole3, *myPlayer, &score);
            break;
            case 4: 
              playHole(4, Hole4, *myPlayer, &score);
            break;
            case 5: 
              playHole(5, Hole5, *myPlayer, &score);
            break;
        }  
        
        //increment current hole
        currentHole++;
    }
    
    clean_up();
    
    return 0;
}