Beispiel #1
0
/*
 *
 * Initializes background and foreground tile lists.
 *
 */
void init_world(void)
{
    init_background();
    init_foreground();
    view_x=random(WORLD_WIDTH-VIEW_WIDTH);
    view_y=random(WORLD_HEIGHT-VIEW_HEIGHT);
}
Beispiel #2
0
 void rotate(EIM_ROTATE rotate)
 {
     init_background();
     switch(rotate)
     {
         case EIM_ROTATE_90:
             MagickRotateImage(magick_wand, background_, 90);
         break;
         case EIM_ROTATE_180:
             MagickRotateImage(magick_wand, background_, 180);
         break;
         case EIM_ROTATE_270:
             MagickRotateImage(magick_wand, background_, 270);
         break;
     }
 }
Beispiel #3
0
void default_panel()
{
	panels = NULL;
	num_panels = 0;
	default_icon = NULL;
	task_dragged = FALSE;
	panel_horizontal = TRUE;
	panel_position = CENTER;
	panel_items_order = NULL;
	panel_autohide = FALSE;
	panel_autohide_show_timeout = 0;
	panel_autohide_hide_timeout = 0;
	panel_autohide_height = 5; // for vertical panels this is of course the width
	panel_shrink = FALSE;
	panel_strut_policy = STRUT_FOLLOW_SIZE;
	panel_dock = FALSE;         // default not in the dock
	panel_layer = BOTTOM_LAYER; // default is bottom layer
	panel_window_name = strdup("tint2");
	wm_menu = FALSE;
	max_tick_urgent = 14;
	mouse_left = TOGGLE_ICONIFY;
	backgrounds = g_array_new(0, 0, sizeof(Background));
	gradients = g_array_new(0, 0, sizeof(GradientClass));

	memset(&panel_config, 0, sizeof(Panel));
	snprintf(panel_config.area.name, sizeof(panel_config.area.name), "Panel");
	panel_config.mouse_over_alpha = 100;
	panel_config.mouse_over_saturation = 0;
	panel_config.mouse_over_brightness = 10;
	panel_config.mouse_pressed_alpha = 100;
	panel_config.mouse_pressed_saturation = 0;
	panel_config.mouse_pressed_brightness = 0;
	panel_config.mouse_effects = 1;

	// First background is always fully transparent
	Background transparent_bg;
	init_background(&transparent_bg);
	g_array_append_val(backgrounds, transparent_bg);
	GradientClass transparent_gradient;
	init_gradient(&transparent_gradient, GRADIENT_VERTICAL);
	g_array_append_val(gradients, transparent_gradient);
}
void start(){
  initscr();
  srand(time(0));
  init_background(0,0);
  refresh();
  keypad(stdscr,TRUE);
  pthread_t keyboard;                                      //键盘监听线程
  int err = init_network();                                //初始化网络模块
  if(err!=0){
    mvprintw(5,60,"Network model init failed!");
  }
 start:
  initpanel();                                                   //把两个panel清空
  initblock(b1);initblock(b2);
  printpanel(PANELSTARTX,PANELSTARTY);
  err = pthread_create(&keyboard,NULL,keylistener,NULL);
  if(err !=0){
     printf("can't create thread keyboard listener!");
     exit(1);
    }

  //main thread make the block moving down until the gameover
  while(!over){
    movemid();
    if(caninput(b1)){			//可以放下当前块说明游戏未结束
      while( canmovedown() ){		//直到不能下落位置
	//继续下落
	goahead();	
	//显示一次			
	printpanel(PANELSTARTX,PANELSTARTY);

	usleep(sleeptime);
      }

      //save temp panel to preview panel and create new block
      savetoprev();
      printpanel(PANELSTARTX,PANELSTARTY);

	//停止下落后要消除
      eliminate();
	
	//把下一个块替换上来
      nextblock();
    }
    else
      over=true;
  }
  attrset(COLOR_PAIR(7));
  mvprintw(21,37,"YOU DEAD!Try again?(y/n):");
  int input;
  int quit = 1;
  while(quit){
    input=getch();                              //判断用户还要不要玩下去
    switch(input){
    case 'y':  
      over = 0;
      attrset(COLOR_PAIR(0));
      mvprintw(21,37,"                         ");
      goto start;                                 //重新开始
      break;
    case 'n':  endwin();quit = 0;break;
    default: 
      mvprintw(21,37,"YOU DEAD!Try again?(y/n):");
  }
  }
}
Beispiel #5
0
int main(int argc,char **argv) {
	INFO(char *dbg="Main(init): ");

	native_startup(argc, argv);

	/*** init modules ***/

	INFO(printf("%sSharedMemory\n",dbg));
	init_sharedmem(&dope);

	INFO(printf("%sTimer\n",dbg));
	init_timer(&dope);

	INFO(printf("%sTick\n",dbg));
	init_tick(&dope);

	INFO(printf("%sRelax\n",dbg));
	init_relax(&dope);

	INFO(printf("%sKeymap\n",dbg));
	init_keymap(&dope);

	INFO(printf("%sThread\n",dbg));
	init_thread(&dope);

	INFO(printf("%sCache\n",dbg));
	init_cache(&dope);

	INFO(printf("%sHashTable\n",dbg));
	init_hashtable(&dope);

	INFO(printf("%sApplication Manager\n",dbg));
	init_appman(&dope);

	INFO(printf("%sTokenizer\n",dbg));
	init_tokenizer(&dope);

	INFO(printf("%sMessenger\n",dbg));
	init_messenger(&dope);

	INFO(printf("%sScript\n",dbg));
	init_script(&dope);

	INFO(printf("%sClipping\n",dbg));
	init_clipping(&dope);

	INFO(printf("%sScreen Driver\n",dbg));
	init_scrdrv(&dope);

	INFO(printf("%sInput\n",dbg));
	init_input(&dope);

	INFO(printf("%sViewManager\n",dbg));
	init_viewman(&dope);

	INFO(printf("%sConvertFNT\n",dbg));
	init_conv_fnt(&dope);

	INFO(printf("%sFontManager\n",dbg));
	init_fontman(&dope);

	INFO(printf("%sGfxScreen16\n",dbg));
	init_gfxscr16(&dope);

	INFO(printf("%sGfxImage16\n",dbg));
	init_gfximg16(&dope);

	INFO(printf("%sGfxImage32\n",dbg));
	init_gfximg32(&dope);

	INFO(printf("%sGfxImageYUV420\n",dbg));
	init_gfximgyuv420(&dope);

	INFO(printf("%sGfx\n",dbg));
	init_gfx(&dope);

	INFO(printf("%sRedrawManager\n",dbg));
	init_redraw(&dope);

	INFO(printf("%sUserState\n",dbg));
	init_userstate(&dope);

	INFO(printf("%sWidgetManager\n",dbg));
	init_widman(&dope);

	INFO(printf("%sScope\n",dbg));
	init_scope(&dope);

	INFO(printf("%sButton\n",dbg));
	init_button(&dope);

	INFO(printf("%sEntry\n",dbg));
	init_entry(&dope);

	INFO(printf("%sVariable\n",dbg));
	init_variable(&dope);

	INFO(printf("%sLabel\n",dbg));
	init_label(&dope);

	INFO(printf("%sLoadDisplay\n",dbg));
	init_loaddisplay(&dope);

	INFO(printf("%sBackground\n",dbg));
	init_background(&dope);

	INFO(printf("%sScrollbar\n",dbg));
	init_scrollbar(&dope);

	INFO(printf("%sScale\n",dbg));
	init_scale(&dope);

	INFO(printf("%sFrame\n",dbg));
	init_frame(&dope);

	INFO(printf("%sContainer\n",dbg));
	init_container(&dope);

	INFO(printf("%sGrid\n",dbg));
	init_grid(&dope);

	INFO(printf("%sWinLayout\n",dbg));
	init_winlayout(&dope);

	INFO(printf("%sWindow\n",dbg));
	init_window(&dope);

	INFO(printf("%sScreen\n",dbg));
	init_screen(&dope);

	INFO(printf("%sScheduler\n",dbg));
	if (config_don_scheduler)
        {
	//	init_don_scheduler(&dope);
          printf("NOOOOOOOOOOOOOOOOOOO\n");
        }
	else
		init_simple_scheduler(&dope);

	INFO(printf("%sVScreenServer\n",dbg));
	init_vscr_server(&dope);

	INFO(printf("%sVScreen\n",dbg));
	init_vscreen(&dope);
	
	INFO(printf("%sVTextScreen\n",dbg));
	init_vtextscreen(&dope);

	INFO(printf("%sServer\n",dbg));
	init_server(&dope);

	INFO(printf("%screate screen\n",dbg));
	{
		static GFX_CONTAINER *scr_ds;
		gfx       = pool_get("Gfx 1.0");
		screen    = pool_get("Screen 1.0");
		userstate = pool_get("UserState 1.0");

		scr_ds = gfx->alloc_scr("default");
		curr_scr = screen->create();
		curr_scr->scr->set_gfx(curr_scr, scr_ds);
		userstate->set_max_mx(gfx->get_width(scr_ds));
		userstate->set_max_my(gfx->get_height(scr_ds));
	}
	
	INFO(printf("%sstarting server\n",dbg));
	if ((server = pool_get("Server 1.0")))
		server->start();
	
	INFO(printf("%sstarting scheduler\n",dbg));
	if ((sched  = pool_get("Scheduler 1.0")))
		sched->process_mainloop();

	return 0;
}
Beispiel #6
0
int
main(int argc, char *argv[])
{
	/* TODO: refactor main() function */

	char dir[PATH_MAX];
	char lwin_path[PATH_MAX] = "";
	char rwin_path[PATH_MAX] = "";
	int lwin_handle = 0, rwin_handle = 0;
	int old_config;
	int no_configs;

	init_config();

	if(is_in_string_array(argv + 1, argc - 1, "--logging"))
	{
		init_logger(1);
	}

	(void)setlocale(LC_ALL, "");
	if(getcwd(dir, sizeof(dir)) == NULL)
	{
		perror("getcwd");
		return -1;
	}
#ifdef _WIN32
	to_forward_slash(dir);
#endif

	init_filelists();
	init_registers();
	set_config_paths();
	reinit_logger();

	init_commands();
	init_builtin_functions();
	update_path_env(1);

	if(init_status() != 0)
	{
		puts("Error during session status initialization.");
		return -1;
	}

	no_configs = is_in_string_array(argv + 1, argc - 1, "--no-configs");

	/* Tell file type module what function to use to check availability of
	 * external programs. */
	config_filetypes(&external_command_exists);
	/* This should be called before loading any configuration file. */
	reset_all_file_associations(curr_stats.env_type == ENVTYPE_EMULATOR_WITH_X);

	init_option_handlers();

	old_config = is_old_config();
	if(!old_config && !no_configs)
		read_info_file(0);

	ipc_pre_init();

	parse_args(argc, argv, dir, lwin_path, rwin_path, &lwin_handle, &rwin_handle);

	ipc_init(&parse_recieved_arguments);

	init_background();

	set_view_path(&lwin, lwin_path);
	set_view_path(&rwin, rwin_path);

	/* Force view switch when path is specified for invisible pane. */
	if(lwin_path[0] != '\0' && rwin_path[0] == '\0' && curr_view != &lwin)
	{
		change_window();
	}

	load_initial_directory(&lwin, dir);
	load_initial_directory(&rwin, dir);

	/* Force split view when two paths are specified on command-line. */
	if(lwin_path[0] != '\0' && rwin_path[0] != '\0')
	{
		curr_stats.number_of_windows = 2;
	}

	/* Setup the ncurses interface. */
	if(!setup_ncurses_interface())
		return -1;

	colmgr_init(COLOR_PAIRS);
	init_modes();
	init_undo_list(&perform_operation, NULL, &cfg.undo_levels);
	load_local_options(curr_view);

	curr_stats.load_stage = 1;

	if(!old_config && !no_configs)
	{
		load_scheme();
		source_config();
	}

	write_color_scheme_file();
	setup_signals();

	if(old_config && !no_configs)
	{
		convert_configs();

		curr_stats.load_stage = 0;
		read_info_file(0);
		curr_stats.load_stage = 1;

		set_view_path(&lwin, lwin_path);
		set_view_path(&rwin, rwin_path);

		load_initial_directory(&lwin, dir);
		load_initial_directory(&rwin, dir);

		source_config();
	}

	(void)create_trash_dir(cfg.trash_dir);

	check_path_for_file(&lwin, lwin_path, lwin_handle);
	check_path_for_file(&rwin, rwin_path, rwin_handle);

	curr_stats.load_stage = 2;

	exec_startup_commands(argc, argv);
	update_screen(UT_FULL);
	modes_update();

	/* Update histories of the views to ensure that their current directories,
	 * which might have been set using command-line parameters, are stored in the
	 * history.  This is not done automatically as history manipulation should be
	 * postponed until views are fully loaded, otherwise there is no correct
	 * information about current file and relative cursor position. */
	save_view_history(&lwin, NULL, NULL, -1);
	save_view_history(&rwin, NULL, NULL, -1);

	curr_stats.load_stage = 3;

	main_loop();

	return 0;
}
Beispiel #7
0
int change_gfx_mode(void)
{
   int ret = DEMO_OK;
   int flags = 0;

   /* Select appropriate (fullscreen or windowed) gfx mode driver. */
   if (fullscreen == 0) {
      flags |= ALLEGRO_WINDOWED | ALLEGRO_RESIZABLE;
      screen_width = window_width;
      screen_height = window_height;
   } else if (fullscreen == 1) {
      flags |= ALLEGRO_FULLSCREEN_WINDOW;
   } else {
      flags |= ALLEGRO_FULLSCREEN;
   }
   
   if (screen) {
      al_destroy_display(screen);
   }

   al_set_new_display_flags(flags);
   
   // May be a good idea, but need to add a border to textures for it.
   // al_set_new_bitmap_flags(ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR);
   
   if (screen_samples > 1) {
      al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST);
      al_set_new_display_option(ALLEGRO_SAMPLES, screen_samples, ALLEGRO_SUGGEST);
   }
   else {
      al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 0, ALLEGRO_SUGGEST);
      al_set_new_display_option(ALLEGRO_SAMPLES, 0, ALLEGRO_SUGGEST);
   }
   
   al_set_new_display_option(ALLEGRO_SUPPORTED_ORIENTATIONS,
                             ALLEGRO_DISPLAY_ORIENTATION_LANDSCAPE, ALLEGRO_SUGGEST);

   /* Attempt to set the selected colour depth and gfx mode. */
   screen = al_create_display(screen_width, screen_height);
   if (!screen) {
      return DEMO_ERROR_ALLEGRO;
   }
   al_set_window_constraints(screen, 320, 320, 0, 0);
   
   screen_width = al_get_display_width(screen);
   screen_height = al_get_display_height(screen);
   screen_orientation = ALLEGRO_DISPLAY_ORIENTATION_90_DEGREES;
   
   al_register_event_source(event_queue, al_get_display_event_source(screen));

   /* blank display now, before doing any more complicated stuff */
   al_clear_to_color(al_map_rgb(0, 0, 0));

   /* Attempt to load game data. */
   ret = load_data();

   /* If loading was successful, initialize the background scroller module. */
   if (ret == DEMO_OK) {
      init_background();
   }

   return ret;
}
Beispiel #8
0
void init_text(int splash)
{
	SDL_Event ev;
	int toexit=0;
	SDL_Surface *sur;
	SDL_Rect r;
	int i,j;


	if (!text_screen)
	{

//		text_screen=SDL_ConvertSurface(screen,screen->format,0);
		text_screen=SDL_CreateRGBSurface(screen->flags,screen->w,screen->h,screen->format->BitsPerPixel,screen->format->Rmask,screen->format->Gmask,screen->format->Bmask,screen->format->Amask);
//		text_screen=SDL_DisplayFormat(screen);
		if (!text_screen)
		{
#ifdef STDOUTPUT
			puts("Unable to make a SDL_Surface (text_screen)");
#endif
			exit(-1);

		}
	}

#ifdef DREAMCAST
        __sdl_dc_emulate_keyboard=1;
#endif
	if (!splash)
	{
		menu_raise();
		return;
	}

	text_image2=load_img_0(MENU_FILE_TEXT2);
	font_inv.Surface=text_image2;
	SFont_InitFontInfo(&font_inv);

	text_image=load_img_0(MENU_FILE_TEXT);
	SFont_InitFont(text_image);

	text_win_uleft=load_img_255(MENU_FILE_WIN_ULEFT);
	text_win_uright=load_img_255(MENU_FILE_WIN_URIGHT);
	text_win_upper=load_img_255(MENU_FILE_WIN_UPPER);
	text_win_left=load_img_255(MENU_FILE_WIN_LEFT);
	text_win_right=load_img_255(MENU_FILE_WIN_RIGHT);
	text_win_bright=load_img_255(MENU_FILE_WIN_BRIGHT);
	text_win_bleft=load_img_255(MENU_FILE_WIN_BLEFT);
	text_win_bottom=load_img_255(MENU_FILE_WIN_BOTTOM);
	text_cdrom=menu_IMG_Load(MENU_FILE_LOADING);

	init_background();

	obten_colores();
	sound_play_menu_music();
#ifndef AUTO_EVENTS
	sur=menu_IMG_Load(MENU_FILE_SPLASH);
	r.x=(text_screen->w - sur->w)/2;
	r.y=(text_screen->h - sur->h)/2;
	r.h=sur->w;
	r.w=sur->h;
	SDL_FillRect(text_screen,NULL,0); //0xFFFFFFFF);
	while(SDL_PollEvent(&ev)) SDL_Delay(50);
	for (i=128;(i>-8)&&(!toexit);i-=8)
	{
#ifdef DREAMCAST
		vid_waitvbl();
#else
		SDL_Delay(50);
#endif
		SDL_FillRect(text_screen,NULL,0); //0xFFFFFFFF);
		SDL_BlitSurface(sur,NULL,text_screen,&r);
		fade16(text_screen,i);
		text_flip();
		while(SDL_PollEvent(&ev)) toexit=1;
	}
	for(i=0;(i<23)&&(!toexit);i++)
	{
		while(SDL_PollEvent(&ev)) toexit=1;
		SDL_Delay(100);
	}
	for(i=0;(i<128)&&(!toexit);i+=16)
	{
#ifdef DREAMCAST
		vid_waitvbl();
#else
		SDL_Delay(50);
#endif
		SDL_FillRect(text_screen,NULL,0); //0xFFFFFFFF);
		SDL_BlitSurface(sur,NULL,text_screen,&r);
		fade16(text_screen,i);
		text_flip();
		while(SDL_PollEvent(&ev)) toexit=1;
	}
	for(i=128;(i>-8)&&(!toexit);i-=8)
	{
#ifdef DREAMCAST
		vid_waitvbl();
#else
		SDL_Delay(50);
#endif
		text_draw_background();
		fade16(text_screen,i);
		text_flip();
		while(SDL_PollEvent(&ev)) toexit=1;
	}
	SDL_FreeSurface(sur);
#else
#ifndef DREAMCAST
	chdir(ROM_PREFIX);
#else
//	fs_chdir(ROM_PREFIX);
	fs_chdir("/");//ROM_PREFIX);
#endif
#endif
//	menu_msg_time=SDL_GetTicks();
}