Ejemplo n.º 1
0
int			main(UNUSED int ac, char **av, char **env)
{
  t_config		config;
  t_tetrimino		*tetri;
  char			key[10];
  int			c;
  struct winsize	win;

  tetri = NULL;
  if ((tetri = init_main(av, env, &config, tetri)) == NULL)
    return (-1);
  c = 0;
  key[0] = 0;
  while (compare_key(key, config.quit) == 0)
    {
      ioctl(0, TIOCGWINSZ, &win);
      get_entry(key);
      if (key[0] != 0)
	key_control(key, &config, tetri);
      if (++c >= 100 && config.brek == 0 && (c = -1) == -1)
	if (game_physics(&config, tetri))
	  end_game(&config, key);
      usleep(get_speed(config.speed, config.level));
    }
  endwin();
  return (0);
}
Ejemplo n.º 2
0
int main()
{
	init();
	while (1)
	{
		key_control();
	}
	game_over();
}
Ejemplo n.º 3
0
/*
 * definition
 */
void task_tty(){
	int i;
	MSG *p_msg;



/*
 * Can not change
 */
	init_console();

	init_tty();

//	tty_write_str("LeiMing" , (TTY *)&tty_table[TTY_ENABLE]);
//	tty_write_ctrl((TTY *)&tty_table[TTY_ENABLE]);
//	tty_write_str("is Best!" , (TTY *)&tty_table[TTY_ENABLE]);

/*
 * Test

	msg = get_msg();
	msg -> type = 8;

	tty_write_int((u32)msg -> type , (TTY *)&tty_table[TTY_ENABLE]);

	del_msg(msg);

	msg = get_msg();
	tty_write_int((u32)msg -> type , (TTY *)&tty_table[TTY_ENABLE]);
*/

//	int i;
//	char *src = {"Lei Ming is best hahaha"};
//	char dest[20];

//	for(i = 0; i < 20; i++){
//		dest[i] = '0';
//	}


//	strcpy(dest , src , sizeof(dest) - 1);
//	tty_write_str(dest , (TTY *)&tty_table[TTY_ENABLE]);


//	disp_int(i);

//	set_start_vmem((u32)(80 * 1));
	while(1){



		p_msg = recv_msg();

		if(p_msg == (MSG *)NULL){

		}else{

			switch(p_msg -> type){	//根据消息的不同类型来不同地处理
//				case MSG_WRITE_ENTER:

				case MSG_WRITE_CHAR:
					tty_write_char(p_msg -> int_info[0] , (TTY *)&tty_table[p_msg -> int_proc_info[1]]);
					del_msg(p_msg);

					break;
				case MSG_WRITE_INT:
					tty_write_int(p_msg -> int_info[0] , (TTY *)&tty_table[p_msg -> int_proc_info[1]]);
					del_msg(p_msg);

					break;
				case MSG_WRITE_STR:
					tty_write_str(p_msg -> str_info , (TTY *)&tty_table[p_msg -> int_proc_info[1]]);	//第二个参数是进程所在的p_tty
					del_msg(p_msg);

					break;

				case MSG_PRINT_CTRL:
					tty_print_ctrl((TTY *)&tty_table[p_msg -> int_proc_info[1]]);
					del_msg(p_msg);
					break;
				default:
					break;
			}
		}


		key_control((TTY *)&tty_table[TTY_ENABLE]);

	}

}