Esempio n. 1
0
void arkanoid::Game::new_level_message(){
	clear();
	use_color(5);
	mvprintw(actual_max_row / 2, (actual_max_col / 2) - 5, "Livello: %d", level_nr + 1);
	use_color(2);
	mvprintw(round(actual_max_row * (static_cast<float>(9)/static_cast<float>(10))), (actual_max_col / 2) - 15, "Premi un tasto per continuare");
	refresh();
	nodelay(stdscr, FALSE);
	getch();
	clear();
}
Esempio n. 2
0
void arkanoid::Game::ending_message(){

	clear();
	use_color(5);
	mvprintw(actual_max_row / 2, (actual_max_col / 2) - 6, "Hai perso! :(");
	use_color(2);
	mvprintw(round(actual_max_row * (static_cast<float>(9)/static_cast<float>(10))), (actual_max_col / 2) - 12, "Premi un tasto per uscire");
	refresh();
	nodelay(stdscr, FALSE);
	getch();
	clear();
}
Esempio n. 3
0
void arkanoid::Game::introduction(){

	getmaxyx(stdscr, actual_max_row, actual_max_col);
	use_color(5);
	mvprintw(actual_max_row / 2, (actual_max_col / 2) - 9, "Benvenuti su Arzanoid");
	mvprintw(round(actual_max_row * (static_cast<float>(3)/static_cast<float>(4))), round(actual_max_col * (static_cast<float>(1)/static_cast<float>(4))) - 15, "Developed by Antonio Agostino");
	mvprintw(round(actual_max_row * (static_cast<float>(3)/static_cast<float>(4))), round(actual_max_col * (static_cast<float>(3)/static_cast<float>(4))) - 12, "https://github.com/Zane83");
	use_color(2);
	mvprintw(round(actual_max_row * (static_cast<float>(9)/static_cast<float>(10))), (actual_max_col / 2) - 14, "Premi un tasto per continuare");
	refresh();
	getch();
	clear();
}
Esempio n. 4
0
void arkanoid::Game::draw_object(Drawable &dr){
	if(dr.is_visible()){
		if(dr.d_id == 0){
			dr_counter++;
			dr.d_id = dr_counter;
			drawed.push_back(dr);
		}
		

		float xdiff = static_cast<float>(actual_max_col) / static_cast<float>(default_max_col);
		float ydiff = static_cast<float>(actual_max_row) / static_cast<float>(default_max_row);
		unsigned start_r = round(dr.d_start_row * ydiff);
		unsigned end_r = round(dr.d_end_row * ydiff);
		unsigned start_c = round(dr.d_start_col * xdiff);
		unsigned end_c = round(dr.d_end_col* xdiff);

		use_color(dr.d_color);

		for(unsigned i = start_r; i <= end_r; i++)
		{
			for(unsigned j = start_c; j <= end_c; j++)
			{
		
				mvprintw(i, j, "%c", dr.d_ch);
				refresh();
		
			}
		}
	}
}
Esempio n. 5
0
void arkanoid::Game::draw_border(){

	use_color(4);
	for(unsigned i = 0; i < actual_max_row; i++){
		mvprintw(i, 0, "+");
		mvprintw(i, actual_max_col - 1, "+");
		refresh();
	}	

	for(unsigned j = 0; j < actual_max_col; j++){
		mvprintw(0, j, "+");
		mvprintw(actual_max_row - 1, j, "+");
		refresh();
	}
	
}
Esempio n. 6
0
static int
sc_ui_display_msg(sc_context_t *ctx, int type, const char *msg)
{
	const char	*color_pfx = "", *color_sfx = "";
	FILE		*outf = NULL;
	int		n;

	switch (type) {
	case SC_LOG_TYPE_ERROR:
		outf = ctx->error_file;
		break;

	case SC_LOG_TYPE_DEBUG:
		outf = ctx->debug_file;
		break;
	}
	if (outf == NULL)
		return 0;

	if (use_color(ctx, outf)) {
		color_sfx = "\33[0m";
		switch (type) {
		case SC_LOG_TYPE_ERROR:
			color_pfx = "\33[01;31m";
			break;
		case SC_LOG_TYPE_DEBUG:
			color_pfx = "\33[00;32m";
			break;
		}
	}

	fprintf(outf, "%s%s%s", color_pfx, msg, color_sfx);
	n = strlen(msg);
	if (n == 0 || msg[n-1] != '\n')
		fprintf(outf, "\n");
	fflush(outf);
	return 0;
}
Esempio n. 7
0
void convert_to_types(struct byte_array ba)
{
  as_TYPE2(char,   CTYPE_CHAR);
  as_TYPE2(signed char,   CTYPE_SIGNED_CHAR);
  as_TYPE2(unsigned char,   CTYPE_UNSIGNED_CHAR);

  as_TYPE2(short,  CTYPE_SHORT);
  as_TYPE2(unsigned short,  CTYPE_UNSIGNED_SHORT);

  as_TYPE2(int, CTYPE_INT);
  as_TYPE2(unsigned int, CTYPE_UNSIGNED_INT);

  as_TYPE2(long, CTYPE_LONG);
  as_TYPE2(unsigned long, CTYPE_UNSIGNED_LONG);

  as_TYPE2(long long, CTYPE_LONG_LONG);
  as_TYPE2(unsigned long long, CTYPE_UNSIGNED_LONG_LONG);

  as_TYPE2(float, CTYPE_FLOAT);
  as_TYPE2(double, CTYPE_DOUBLE);
  as_TYPE2(long double, CTYPE_LONG_DOUBLE);


  if (popts.showchars || popts.alltypes)
  {
    printf("%sprintable chars%s\n", use_color(popts.color, THEME_HEADING),
           use_color(popts.color, THEME_RESET));

    int bytes = ba.datalen;
    const int linewidth = 16; // bytes per line
    const int blocks = bytes/linewidth + ( (bytes%linewidth)>0 );

    for (int j = 0; j < blocks; j++)
    {
      int offset = linewidth * j;
      unsigned char* const src = ba.data + offset;

      for (size_t i = 0; i < linewidth; ++i)
      {
        if (i+offset < bytes)
        {
          if (isprint( *(src+i)))
            printf("%s%c%s", cols_chr[0],*(src+i),cols_chr[1]);
          else
            printf("%s.%s",cols_dot[0],cols_dot[1]);
        }
        else printf(" ");
      }
      printf(" |");

      // print hex
      for (size_t i = 0; i < linewidth ; ++i)
      {
        if ((offset+i) < bytes)
        {
          unsigned int b = *(ba.data+offset+i);

          // Note: there are easier ways to get hex digits, but, this is okay for
          // now, becuase I might display the hex in different colours.
          char msb = tohex((b & 0xF0)>>4);
          char lsb = tohex((b & 0x0F));

          const char** cols = (isprint( *(src+i)))? cols_chr:cols_dot;
          printf(" %s%c%c%s",cols[0],msb,lsb,cols[1]);
        }
      }

      printf("\n"); // newline after one block
  }
Esempio n. 8
0
void arkanoid::Game::draw_level_nr(){
	use_color(4);
	mvprintw(actual_max_row - 1, round(actual_max_col * (static_cast<float>(3)/static_cast<float>(4))) - 9, "Livello: %d", level_nr);
	refresh();
}
Esempio n. 9
0
void arkanoid::Game::draw_health(){
	use_color(4);
	mvprintw(actual_max_row - 1, (actual_max_col / 4) - 6, "Vite: %d", health);
	refresh();
}