Exemple #1
0
void run(char* dirname)
{
  int ch, x, y, i;

  curs_set(0);
  draw_chara(dirname);
  draw_stats(dirname);
  draw_skill(dirname);

  x = 0;
  y = 0;

  for(;;)
    {
      draw_controls(0);
      move_cursor(y);
      cbreak();
      noecho();
      ch = getch();
      for(i = 0; i < COLS; ++i) mvaddch(LINES - 1, i, ' ');
      mvaddch(LINES - 1, COLS - 1, ch);

      if(ch == 'q') break;
      if(ch == 'j') y = move_cursor(y + 1) ? y + 1 : y;
      if(ch == 'k') y = move_cursor(y - 1) ? y - 1 : y;
      if(ch == 'h') change_hp();
      if(ch == 'm') change_mp();
      if(ch == 'f') change_fate();
      if(ch == 'd') ndice();
      if(ch == '?') draw_help();
    }

  return;
}
Exemple #2
0
/**
 * The main loop of the jukebox. Waits for the end of the song (while updating
 * the timer) and then returns an indicator that we need the next song.
 * Also waits for keypresses; the user can press ESC, left arrow or right arrow
 * to trigger appropriate return codes.
 */
int jukebox_loop() {
    int key_p;
    while (TRUE) {
        while (keypressed()) {
            key_p = readkey() >> 8;
            if (key_p == KEY_ESC) {
                return JUKEBOX_EXIT;
            }
            if (key_p == KEY_LEFT) {
                return JUKEBOX_PREV_SONG;
            }
            if (key_p == KEY_RIGHT) {
                return JUKEBOX_NEXT_SONG;
            }
        }
        clear_bitmap(buffer);
        update_starfield(buffer);
        update_track_data();
        update_song_data();
        draw_help();
        vsync();
        blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);

        // When we're at the end of the file, midi_pos will be set to
        // the negative number of beats in the song.
        if (midi_pos < 0) {
            rest(TRACK_CHANGE_WAIT);
            return JUKEBOX_NEXT_SONG;
        }
    }
}
void Renderer::Pass2(const Pipeline &pipeline, const PipelineContext &pipelineContext)
{
	//BEGIN PASS 2
	//
	//end of texture rendering
	//now we copy the texture from the FBO or framebuffer to
	//video texture memory and render fullscreen.

	/** Reset the viewport size */
#ifdef USE_FBO
	if (renderTarget->renderToTexture)
	{
		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, this->renderTarget->fbuffer[1]);
		glViewport(0, 0, this->renderTarget->texsize, this->renderTarget->texsize);
	}
	else
#endif
		glViewport(0, 0, this->vw, this->vh);

	glBindTexture(GL_TEXTURE_2D, this->renderTarget->textureID[0]);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
#ifdef USE_GLES1
	glOrthof(-0.5, 0.5, -0.5, 0.5, -40, 40);
#else
	glOrtho(-0.5, 0.5, -0.5, 0.5, -40, 40);
#endif
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glLineWidth(this->renderTarget->texsize < 512 ? 1 : this->renderTarget->texsize / 512.0);

	CompositeOutput(pipeline, pipelineContext);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glTranslatef(-0.5, -0.5, 0);

	// When console refreshes, there is a chance the preset has been changed by the user
	refreshConsole();
	draw_title_to_screen(false);
	if (this->showhelp % 2)
		draw_help();
	if (this->showtitle % 2)
		draw_title();
	if (this->showfps % 2)
		draw_fps(this->realfps);
	if (this->showpreset % 2)
		draw_preset();
	if (this->showstats % 2)
		draw_stats();
	glTranslatef(0.5, 0.5, 0);

#ifdef USE_FBO
	if (renderTarget->renderToTexture)
		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
#endif
}
//Handles input from ipod
static int handle_event(GR_EVENT *event)
{
    switch (event->type)
    {
		case GR_EVENT_TYPE_KEY_UP:
			switch (event->keystroke.ch)
			{

				case 'h': /* Hold switch */
					draw_window();
				break;
			}
		break;

		case GR_EVENT_TYPE_KEY_DOWN:
			switch (event->keystroke.ch)
			{

				case 'h': /* Hold switch */
					draw_help();
				break;

				case 'm': /* Menu button */
					writePot();
					reset();
					pz_close_window (blackjack_wid);

				break;

				case 'l': /* Wheel left */
					dec_bid();
				break;

				case 'r': /* Wheel right */
					inc_bid();
				break;

				case 'w': /* Prev track */
					dec_bid();
				break;

				case 'f': /* Next track */
					inc_bid();
				break;

				case 'd': /* Play */
					play_stay();
				break;

				case '\r': /* Action */
					hit_me();
				break;
			}
		break;
    }
	return 0;
}
Exemple #5
0
/*
 * Name: net_setup
 * Description: Инициализируются все настройки для сетевой игры
 * */
void net_setup( const char typeConnection ) {
	echo();		// Включаем отображение вводимых символов

	if ( typeConnection == NET_CLIENT ) {           // Настройка клиента
		draw_netClientIPEnter();
		draw_help( "Enter server IP address(255.255.255.255)" );

		WINDOW *input = NULL; // Создаем окно для ввода
		input = subwin( stdscr, 1, 16, 1, 1 );  // Инициализируем его
		while ( wgetstr( input, ip ) || net_checkIP() ) {	// Проверяем IP на правильность ввода
			draw_netClientIPEnter();
			draw_help( "Wrong input, try again. Enter server IP address(255.255.255.255)" );
		}
		delwin( input );

		draw_netClientPortEnter( ip );
		draw_help( "Input port(1025-10000)" );
		while ( ( !scanw( "%d", &port ) ) || port < 1025 || port > 10000 ) {   // Считываем порт
			draw_netClientPortEnter( ip );
			draw_help( "Wrong input, try again. Input port(1025-10000)" );
		}
	} else if ( typeConnection == NET_SERVER ) {      // Настройка сервера
		draw_netServerPortEnter();
		draw_help( "Input port(1025-10000)" );
		while ( ( !scanw( "%d", &port ) ) || port < 1025 || port > 10000 ) {   // Считываем порт
			draw_netServerPortEnter();
			draw_help( "Wrong input, try again. Input port(1025-10000)" );
		}
	} else {
		draw_ERROR( "net_setup", "Wrong argument typeConnection" );
	}

	noecho();	// Отключаем отображение символов
}
Exemple #6
0
int snake_start()
{
restart:
  score = 0;
  init_snake();
  init_map();
  clear();
  refresh();
  draw_score();
  draw_help();
  draw_box(0, 1, LINES-2, COLS-2);
  draw_snake();
  draw_map();
  gen_food();

  if ((pthread_create(&thread_input, NULL, get_input, NULL)) != 0)
    exit(1);
  while (1) {
    usleep(speed);
    check_input();
    if (exit_flag) {
      pthread_cancel(thread_input);
      exit_snake();
      break;
    }
    if (pause_flag) {
      pthread_cancel(thread_input);
      getch();
      pause_flag = 0;
      if ((pthread_create(&thread_input, NULL, get_input, NULL)) != 0)
        exit(1);
    }
    move_snake();
    if (check_dead()) {
      pthread_cancel(thread_input);
      if (snake_dead_exit()) {
        exit_snake();
        break;
      }
      goto restart;
    }
    if (check_food()) {
      inc_score();
      draw_score();
      snake_grow_one();
      gen_food();
    }
  };

  return 0;
}
Exemple #7
0
void View::pre_display()
{
  //info("display: lock");
  view_sync.enter();

  //begin time measuring
  double time_start = get_tick_count();

  //antialising is supported through accumulation buffer (FIXME: use ARB_MULTISAMPLE if available)
  if (!hq_frame)
  {
    clear_background();
    on_display();
  }
  else
  {
    display_antialiased();
    hq_frame = false;
  }

  if (b_help) draw_help();
  else if (b_scale) scale_dispatch();

  //draw current rendring time
# ifdef _DEBUG
  draw_fps();
# endif

  //wait to finish
  glFinish();

  //calculate statistics
  rendering_frames[rendering_frames_top] = get_tick_count() - time_start;
  rendering_frames_top = (rendering_frames_top + 1) % FPS_FRAME_SIZE;

  if (want_screenshot)
  {
    glReadBuffer(GL_BACK_LEFT);
    save_screenshot_internal(screenshot_filename.c_str());
    want_screenshot = false;
  }

  glutSwapBuffers();

  //frame synchronization
  frame_ready = true;
  view_sync.signal_drawing_finished();
  view_sync.leave();
}
Exemple #8
0
static void
curses_draw(void)
{
	if (NULL == get_current_node()) {
		first_node();
		first_intf();
	}

    row = 0;
    move(0,0);
	
	getmaxyx(stdscr, rows, cols);
	
	if (cols < 80) {
		clear();
		putl("Screen must be at least 80 columns wide");
		refresh();
		return;
	}

	if (c_use_colors)
		attrset(COLOR_PAIR(LAYOUT_STATUSBAR) | layout[LAYOUT_STATUSBAR].attr);
	else
		attrset(A_REVERSE);

	if (get_current_node() && get_current_intf()) {
		putl(" interface: %s at %s",
			get_current_intf()->i_name, get_current_node()->n_name);
	}

	move(row, COLS - strlen(PACKAGE_STRING) - 1);
	putl("%s", PACKAGE_STRING);
	move(row, 0);
	
	if (c_use_colors)
		attrset(COLOR_PAIR(LAYOUT_DEFAULT) | layout[LAYOUT_DEFAULT].attr);
	else
		attroff(A_REVERSE);
	
	print_content();

	if (quit_mode)
		print_quit();
	else if (print_help)
		draw_help();

	for (; row < rows-2;) {
		move(++row, 0);
		putl("");
	}
	
	row = rows-1;
	move(row, 0);

	if (c_use_colors)
		attrset(COLOR_PAIR(LAYOUT_STATUSBAR) | layout[LAYOUT_STATUSBAR].attr);
	else
		attrset(A_REVERSE);

	putl(" ^ prev interface, v next interface, <- prev node, -> next node, ? help");
	
	attrset(0);
	refresh();
}
Exemple #9
0
int main(int argc, char *argv[]) {
    int mode = 0;
    initscr();  /* Start curses mode */
    start_color(); /* Start color functionality */
    
    init_pair(10,COLOR_WHITE,COLOR_WHITE);
    init_pair(11,COLOR_YELLOW,COLOR_YELLOW);
    init_pair(12,COLOR_MAGENTA,COLOR_MAGENTA);
    init_pair(13,COLOR_CYAN,COLOR_CYAN);
    init_pair(14,COLOR_GREEN,COLOR_GREEN);
    init_pair(15,COLOR_RED,COLOR_RED);
    init_pair(16,COLOR_BLUE,COLOR_BLUE);
    init_pair(17,COLOR_WHITE,COLOR_WHITE);
    init_pair(18,COLOR_YELLOW,COLOR_YELLOW);
    init_pair(19,COLOR_MAGENTA,COLOR_MAGENTA);
    init_pair(20,COLOR_BLACK,COLOR_WHITE);
    init_pair(21,COLOR_BLACK,COLOR_YELLOW);
    init_pair(22,COLOR_WHITE,COLOR_MAGENTA);
    init_pair(23,COLOR_WHITE,COLOR_CYAN);
    init_pair(24,COLOR_WHITE,COLOR_GREEN);
    init_pair(25,COLOR_WHITE,COLOR_RED);
    init_pair(26,COLOR_WHITE,COLOR_BLUE);
    
    curs_set(0);
    noecho();
    keypad(stdscr,TRUE);
    refresh();
    
    WINDOW **logo;
    WINDOW **menu;

    int i = 0;
    int score = 0;
    while (i == 0) {
        logo = draw_logo();
        menu = draw_menu();
        if (score > 0 ) {
            mode = 1;
        }
        else {
            mode = scroll_menu(menu);
        }
        switch (mode) {
            case 0:
                delete_menu(menu,5);
                delete_menu(logo,169);
                score = tetris_init();
                break;
            case 1:
                delete_menu(menu,5);
                if (score > 0) {
                    draw_hiscores(1,score);
                } 
                else {
                    draw_hiscores(0,score);
                }
                score = 0;
                break;
            case 2:
                delete_menu(menu,5);
                draw_help();
                break;
            case 3:
                delete_menu(menu,5);
                delete_menu(logo,169);
                i = 1;
                break;
        }
    }

    /*getch();*/
    
    endwin(); /* End curses mode */
}
Exemple #10
0
static void curses_draw(void)
{
	if (NULL == get_current_node()) {
		first_node();
		first_item();
	}

	row = 0;
	move(0,0);
	
	getmaxyx(stdscr, rows, cols);
	
	if (cols < 80) {
		clear();
		putl("Screen must be at least 80 columns wide");
		refresh();
		return;
	}

	if (c_use_colors)
		attrset(COLOR_PAIR(LAYOUT_STATUSBAR) | layout[LAYOUT_STATUSBAR].attr);
	else
		attrset(A_REVERSE);

	if (get_current_node() && get_current_item()) {
		putl(" %s on %s",
			get_current_item()->i_name, get_current_node()->n_name);
	}

	move(row, COLS - strlen(PACKAGE_STRING) - 1);
	putl("%s", PACKAGE_STRING);
	move(row, 0);
	
	if (c_use_colors)
		attrset(COLOR_PAIR(LAYOUT_DEFAULT) | layout[LAYOUT_DEFAULT].attr);
	else
		attroff(A_REVERSE);
	
	print_content();

	if (quit_mode)
		print_quit();
	else if (print_help) {
		if (help_page == 0)
			draw_help();
		else
			draw_help_2();
	}

	for (; row < rows-2;) {
		move(++row, 0);
		putl("");
	}
	
	row = rows-1;
	move(row, 0);

	if (c_use_colors)
		attrset(COLOR_PAIR(LAYOUT_STATUSBAR) | layout[LAYOUT_STATUSBAR].attr);
	else
		attrset(A_REVERSE);

	if (1) {
		char s[27];
		time_t t = time(0);
		double d;
		int h, m;

		asctime_r(localtime(&t), s);
		s[strlen(s) - 1] = '\0';
		d = difftime(time(0), start_time);

		if (d / 3600) {
			h = (int) d / 3600;
			m = (int) d % 3600;
			m /= 60;
		} else {
			h = 0;
			m = (int) d / 60;
		}
		
		putl(" %s (%dh/%dm)", s, h, m);
		move(row, COLS - strlen("Press ? for help") - 1);
		putl("%s", "Press ? for help");
		move(row, 0);
	}
	
	attrset(0);
	refresh();
}