void DELETE(TERIS t) { char *p; int i,j; int x,y,m,n,temp=1; for(n=19;n>=0;n--) { temp=0; for(m=0;m<10;m++) { if(BOX[m][n]==0) temp=1; } if(temp==0) { move_words_down(t,n); score=score+10; show_score(); if(score>=230) {win=1;} for(i=0;i<10;i++) { for(j=n;j>0;j--) { BOX[i][j]=BOX[i][j-1]; } } } } }
void level::displayLife() { int mlife = playerShip->get_life(); glPushMatrix(); glLoadIdentity(); show_score(1.0,1.0,score); if (lifeDraw<mlife) { lifeDraw+=10; } else if (lifeDraw > mlife ) { lifeDraw-=10; } glBegin(GL_LINES); GLfloat myBcolor[]= {0.0,0.0,0.0}; GLfloat my1color[]= {0.0,1.0,0.0}; glColor3fv(myBcolor); glLineWidth(30); glVertex3f(-1.0,.999,0); glVertex3f(1.0,.999,0); glLineWidth(10); glColor3fv(my1color); glVertex3f(-0.9,1.,0); GLfloat mycolor[]= {0.66,0.0,0.0}; glColor3fv(mycolor); glVertex3f(lifeDraw/3000.0-0.9,1.,0); glEnd(); glPopMatrix(); }
void setup_level() { /* variables local to setup_level() */ int row,col; /* Set up global variables for new level */ snake_length=level+4; direction = right_key; firstpress = 1; /* Fill grid with blanks */ for(row=0;row<maxrow;row++) for(col=0;col<maxcol;col++) screen_grid[row][col]= ' '; /* Fill grid with Xs and food */ for(int i=0;i<obstacles*2;i++) { row= rand()%maxrow; col= rand()%maxcol; if(i<obstacles) screen_grid[row][col]='x'; else screen_grid[row][col]='.'; } /* Create snake array of length snake_length */ for(int i=0;i<snake_length;i++) { snake[i].row=snake_start_row; snake[i].col=snake_start_col+i; } /* Draw playing board */ draw_line(1,1); for(row=0;row<maxrow;row++) { gotoxy(1,row+2); textcolor(LIGHTBLUE); cprintf("|"); textcolor(WHITE); for(col=0;col<maxcol;col++) cprintf("%c",screen_grid[row][col]); textcolor(LIGHTBLUE); cprintf("|"); } draw_line(1,maxrow+2); show_score(); gotoxy(2,maxrow+5); textcolor(LIGHTRED); cprintf("~~ SNAKE GAME~~ Left: %c, Right: %c, Up: %c, Down: %c, Exit: x. Any key to start.", left_key,right_key,up_key,down_key); }
void gameover(char **tela, int score_global) { ///Finaliza o jogo mostrando o score. int op, i, count; FILE *score_file; char line[30]; score_t score; write_screen(tela, score_global); clear(); show_score(score_global); count = 0; init_pair(1, COLOR_RED, COLOR_YELLOW); bkgd(COLOR_PAIR(1)); score_file = fopen("score.sprite", "r"); while(!feof(score_file)) { fgets(line, COLUNAS, score_file); mvprintw(count, 0, "%s", line); count++; } fclose(score_file); score_file = fopen("score.txt", "r"); for(i = 0; i < 5; i++) { fgets(line, 30, score_file); sscanf(line, "%s %d %d %d %d", score.nome, &score.dia, &score.mes, &score.ano, &score.score); mvprintw(i + (count + 2), 0, "%d. %s %d/%d/%d %d ", (i + 1), score.nome, score.dia, score.mes, score.ano, score.score); } fclose(score_file); refresh(); while (1) { op = getch(); if(op == KEY_UP) { score_global = 0; tela = init_screen(COLUNAS, LINHAS); game_init(tela); } } }
int main(int ac, char *av[]) { bool show_only; extern char *Scorefile; int score_wfd; /* high score writable file descriptor */ int score_err = 0; /* hold errno from score file open */ int ch; extern int optind; gid_t gid; #ifdef FANCY char *sp; #endif if ((score_wfd = open(Scorefile, O_RDWR)) < 0) score_err = errno; /* revoke privs */ gid = getgid(); setresgid(gid, gid, gid); show_only = FALSE; while ((ch = getopt(ac, av, "srajt")) != -1) switch (ch) { case 's': show_only = TRUE; break; case 'r': Real_time = TRUE; /* Could be a command-line option */ tv.tv_sec = 3; tv.tv_usec = 0; FD_ZERO(&rset); break; case 'a': Start_level = 4; break; case 'j': Jump = TRUE; break; case 't': Teleport = TRUE; break; case '?': default: usage(); } ac -= optind; av += optind; if (ac > 1) usage(); if (ac == 1) { Scorefile = av[0]; if (score_wfd >= 0) close(score_wfd); /* This file requires no special privileges. */ if ((score_wfd = open(Scorefile, O_RDWR)) < 0) score_err = errno; #ifdef FANCY sp = strrchr(Scorefile, '/'); if (sp == NULL) sp = Scorefile; if (strcmp(sp, "pattern_roll") == 0) Pattern_roll = TRUE; else if (strcmp(sp, "stand_still") == 0) Stand_still = TRUE; if (Pattern_roll || Stand_still) Teleport = TRUE; #endif } if (show_only) { show_score(); exit(0); } if (score_wfd < 0) { warnx("%s: %s; no scores will be saved", Scorefile, strerror(score_err)); sleep(1); } initscr(); signal(SIGINT, quit); cbreak(); noecho(); nonl(); if (LINES != Y_SIZE || COLS != X_SIZE) { if (LINES < Y_SIZE || COLS < X_SIZE) { endwin(); errx(1, "Need at least a %dx%d screen", Y_SIZE, X_SIZE); } delwin(stdscr); stdscr = newwin(Y_SIZE, X_SIZE, 0, 0); } srandomdev(); do { init_field(); for (Level = Start_level; !Dead; Level++) { make_level(); play_level(); } move(My_pos.y, My_pos.x); printw("AARRrrgghhhh...."); refresh(); score(score_wfd); } while (another()); quit(0); /* NOT REACHED */ }
void timer(int num) { //不能在定时器里刷新屏幕,频率太高会显示不出来 if(game_state == GAME_RUNNING) { time_count++; //用于控制运动的速度 //背景移动 count_1++; if(count_1 == 4) { count_1 = 0; background.src_rect[0].y--; if(background.src_rect[0].y == 0) background.src_rect[0].y = 560; } //飞机移动,通过按键控制固定的速度 player.dst_rect.y += player.speed_y; player.dst_rect.x += player.speed_x; //检查飞机是否碰到边缘 check_edge(&player); //子弹运动 move_bullet(bullet); //敌人自动向下运动 int i, j; if(time_count%2 == 0) { for(i = 0; i < MAX_SMALL_ENEMY; i++) { if(small_enemy[i].life > 0 && small_enemy[i].pic_index == 0) { small_enemy[i].dst_rect.y += 2; } //敌人死亡之后,显示爆炸效果的图片 else if(small_enemy[i].life == 0 && small_enemy[i].pic_index != 0) { if(time_count%4 == 0) { //显示被射击之后的图像效果 small_enemy[i].pic_index++; //图像效果显示完之后,消失 if(small_enemy[i].pic_index == small_enemy[i].pic_num) { small_enemy[i].pic_index = 0; //分数增加 score_record += 100; } } } //到底端消失 if(small_enemy[i].dst_rect.y > SCREEN_HEIGHT) { small_enemy[i].life = 0; } } } //---------------中型飞机--------------- if(time_count%4 == 0) { for(i = 0; i < MAX_MID_ENEMY; i++) { if(mid_enemy[i].life > 0 && mid_enemy[i].pic_index == 0) { mid_enemy[i].dst_rect.y += 2; } else if(mid_enemy[i].life >= 0 && mid_enemy[i].pic_index != 0) { if(time_count%8 == 0) { //显示被射击之后的图像效果 if(mid_enemy[i].pic_index == 1 && mid_enemy[i].life > 0) { mid_enemy[i].pic_index = 0; mid_enemy[i].dst_rect.y += 2; } else if(mid_enemy[i].pic_index >= 1 && mid_enemy[i].life == 0) mid_enemy[i].pic_index++; //图像效果显示完之后,消失 if(mid_enemy[i].pic_index == mid_enemy[i].pic_num) { mid_enemy[i].pic_index = 0; score_record += 300; } } } //到底端消失 if(mid_enemy[i].dst_rect.y > SCREEN_HEIGHT) { mid_enemy[i].life = 0; } } } //--------------------大飞机----------------------- if(time_count%4 == 0) { for(i = 0; i < MAX_BIG_ENEMY; i++) { if(big_enemy[i].life > 0 && big_enemy[i].pic_index == 0) { big_enemy[i].dst_rect.y += 2; } else if(big_enemy[i].life >= 0 && big_enemy[i].pic_index != 0) { if(time_count%8 == 0) { //显示被射击之后的图像效果 if(big_enemy[i].pic_index == 1 && big_enemy[i].life > 0) { big_enemy[i].pic_index = 0; big_enemy[i].dst_rect.y += 2; } //死亡后显示被射击的效果 else if(big_enemy[i].pic_index >= 1 && big_enemy[i].life == 0) big_enemy[i].pic_index++; //图像效果显示完之后,消失 if(big_enemy[i].pic_index == big_enemy[i].pic_num) { big_enemy[i].pic_index = 0; score_record += 600; } } } //到底端消失 if(big_enemy[i].dst_rect.y > SCREEN_HEIGHT) { big_enemy[i].life = 0; } } } //将分数转化为字符串,并进行显示 show_score(); //玩家的飞机 if(time_count%2 == 0) { //死亡后显示爆炸效果 if(player.life == 0 && player.pic_index != 0) { if(time_count%4 == 0) { //显示被射击之后的图像效果 player.pic_index++; //图像效果显示完之后,消失 } } //到底端消失 if(player.dst_rect.y > (SCREEN_HEIGHT-player.src_rect[0].h)) { player.life = 0; player.dst_rect.y = 0; } } //飞机飞行动态 if(time_count == 10) { player.src_rect[0].x = 433; player.src_rect[0].y = 331; } else if(time_count > 50 && time_count < 100) { player.src_rect[0].x = 433; player.src_rect[0].y = 0; } else if(time_count == 100) time_count = 0; //自动射击 if(time_count %30 == 0) { // time_count = 0; if(auto_shot_flag) { shot_bullet(&player, bullet); } } } }
int main(int ac, char *av[]) { bool show_only; extern char Scorefile[PATH_MAX]; int score_wfd; /* high score writable file descriptor */ int score_err = 0; /* hold errno from score file open */ int ch; int ret; extern int optind; char *home; #ifdef FANCY char *sp; #endif if (pledge("stdio rpath wpath cpath tty", NULL) == -1) err(1, "pledge"); home = getenv("HOME"); if (home == NULL || *home == '\0') err(1, "getenv"); ret = snprintf(Scorefile, sizeof(Scorefile), "%s/%s", home, ".robots.scores"); if (ret < 0 || ret >= PATH_MAX) errc(1, ENAMETOOLONG, "%s/%s", home, ".robots.scores"); if ((score_wfd = open(Scorefile, O_RDWR | O_CREAT, 0666)) < 0) score_err = errno; show_only = FALSE; while ((ch = getopt(ac, av, "srajt")) != -1) switch (ch) { case 's': show_only = TRUE; break; case 'r': Real_time = TRUE; /* Could be a command-line option */ tv.tv_sec = 3; break; case 'a': Start_level = 4; break; case 'j': Jump = TRUE; break; case 't': Teleport = TRUE; break; case '?': default: usage(); } ac -= optind; av += optind; if (ac > 1) usage(); if (ac == 1) { if (strlcpy(Scorefile, av[0], sizeof(Scorefile)) >= sizeof(Scorefile)) errc(1, ENAMETOOLONG, "%s", av[0]); if (score_wfd >= 0) close(score_wfd); /* This file requires no special privileges. */ if ((score_wfd = open(Scorefile, O_RDWR | O_CREAT, 0666)) < 0) score_err = errno; #ifdef FANCY sp = strrchr(Scorefile, '/'); if (sp == NULL) sp = Scorefile; if (strcmp(sp, "pattern_roll") == 0) Pattern_roll = TRUE; else if (strcmp(sp, "stand_still") == 0) Stand_still = TRUE; if (Pattern_roll || Stand_still) Teleport = TRUE; #endif } if (show_only) { show_score(); return 0; } if (score_wfd < 0) { warnx("%s: %s; no scores will be saved", Scorefile, strerror(score_err)); sleep(1); } initscr(); signal(SIGINT, quit); cbreak(); noecho(); nonl(); if (LINES != Y_SIZE || COLS != X_SIZE) { if (LINES < Y_SIZE || COLS < X_SIZE) { endwin(); errx(1, "Need at least a %dx%d screen", Y_SIZE, X_SIZE); } delwin(stdscr); stdscr = newwin(Y_SIZE, X_SIZE, 0, 0); } do { init_field(); for (Level = Start_level; !Dead; Level++) { make_level(); play_level(); } if (My_pos.x > X_FIELDSIZE - 16) move(My_pos.y, X_FIELDSIZE - 16); else move(My_pos.y, My_pos.x); printw("AARRrrgghhhh...."); refresh(); score(score_wfd); } while (another()); quit(0); }
int main() { /* Variable declarations within main() only */ char keypress=0; do /* restart game loop */ { obstacles=4; level=1; score=0; speed=14; //randomize(); /* Ensure random seed initiated */ setup_level(); /* main loop */ do { delay(speed * pause_length / 50000); /*pause*/ /* If key has been hit, then check it is a direction key - if so, change direction */ if (kbhit()) { keypress=(char)getch(); if((keypress==right_key)||(keypress==left_key)|| (keypress==up_key)||(keypress==down_key)) direction = keypress; } /* Add a segment to the end of the snake */ add_segment(); /* Blank last segment of snake */ gotoxy(snake[0].col,snake[0].row); cprintf(" "); /* ... and remove it from the array */ for (int i=1;i<=snake_length;i++) snake[i-1]=snake[i]; /* Display snake in yellow */ textcolor(YELLOW); for (int i=0;i<=snake_length;i++) { gotoxy(snake[i].col,snake[i].row); cprintf("O"); } /* keeps cursor flashing in one place instead of following snake */ gotoxy(1,1); /* If first press on each level, pause until a key is pressed */ if (firstpress) { while(!kbhit()); firstpress = 0; } /* Collision detection - walls (bad!) */ if ((snake[snake_length-1].row>maxrow+1)||(snake[snake_length-1].row<=1)|| (snake[snake_length-1].col>maxcol+1)||(snake[snake_length-1].col<=1)|| /* Collision detection - obstacles (bad!) */ (screen_grid[snake[snake_length-1].row-2][snake[snake_length-1].col-2]=='x')) keypress='x'; /* i.e. exit loop - game over */ /* Collision detection - snake (bad!) */ for (int i=0;i<snake_length-1;i++) if ( (snake[snake_length-1].row)==(snake[i].row) && (snake[snake_length-1].col)==(snake[i].col)) { keypress='x'; /* i.e. exit loop - game over */ break; /* no need to check any more segments */ } /* Collision detection - food (good!) */ if (screen_grid[snake[snake_length-1].row-2][snake[snake_length-1].col-2]=='.') { /* increase score and length of snake */ score+=snake_length*obstacles; show_score(); snake_length++; add_segment(); /* if length of snake reaches certain size, onto next level */ if (snake_length==(level+3)*2) { score+=level*1000; obstacles+=2; level++; /* add to obstacles */ if ((level%5==0)&&(speed>1)) speed--; /* increase speed every 5 levels */ setup_level(); /* display next level */ } } } while (keypress!='x'); /* game over message */ if (score > high_score) high_score = score; show_score(); gotoxy(30,6); textcolor(LIGHTRED); cprintf("G A M E O V E R"); gotoxy(30,9); textcolor(YELLOW); cprintf("Another Game (y/n)? "); do keypress=getch(); while((keypress!='y')&&(keypress!='n')); } while (keypress=='y'); }
main() { int driver=0, mode=VESA_1024x768x8bit; int tickets=0; int key,i,j,m,n; char *p; TERIS t,q; initgraph(&driver, &mode, ""); draw_frame(); randomize(); new_teris(&t); new_teris(&q); show_next_teris(q); show_score(); while(!STOP) { show_teris(t); delay(1); tickets++; if(tickets>=MAX) { look1(t); if(OK==0) { show_teris(t); inbox(t); if(t.y==1) {STOP=0;break;} t=q; new_teris(&q); clear_next_teris(); show_next_teris(q); OK=1; } clear_teris(t); tickets=0; t.y++; setcolor(GREEN); rectangle(X0-1, Y0-1, X0+320, Y0+640); } while(bioskey(1)!=0) { key=bioskey(0); switch(key) { case UP: { judge_rotate(t); if(EN) { clear_teris(t); t.rotate++; if(t.rotate>=4) t.rotate=t.rotate%4; show_teris(t); } else EN=1; }break; case DOWN: { look1(t); if(OK==1) { clear_teris(t); t.y++; } if(OK==0) { show_teris(t); inbox(t); if(t.y==1) {STOP=0;break;} t=q; new_teris(&q); clear_next_teris(); show_next_teris(q); OK=1; } }break; case LEFT: { look3(t); if(YES) { clear_teris(t); t.x--; show_teris(t); } else YES=1; }break; case RIGHT: { look2(t); if(YES) { clear_teris(t); t.x++; show_teris(t); } else YES=1; }break; case ESC: { STOP=1; }break; } } DELETE(t); } if(!win) { for(i=0;i<10;i++) { for(j=0;j<20;j++) { if(BOX[i][j]==1) { m=X0+32*i; n=Y0+32*j; setfillstyle(SOLID_FILL, 0X0F); bar(m,n, m+32-1, n+32-1); setcolor(BLACK); rectangle(m, n, m+32, n+32); delay(1); } } } } else { for(i=0;i<10;i++) { for(j=0;j<20;j++) { if(BOX[i][j]==1) { m=X0+32*i; n=Y0+32*j; setfillstyle(SOLID_FILL, 0X0E); bar(m,n, m+32-1, n+32-1); setcolor(BLACK); rectangle(m, n, m+32, n+32); delay(1); } } } } getchar(); closegraph(); return 0; }
int main(int argc, char **argv) { const char *word; bool show_only; int score_wfd; /* high score writable file descriptor */ int score_err = 0; /* hold errno from score file open */ int maximum = 0; int ch, i; score_wfd = open(Scorefile, O_RDWR); if (score_wfd < 0) score_err = errno; else if (score_wfd < 3) exit(1); /* Revoke setgid privileges */ setgid(getgid()); show_only = false; Num_games = 1; while ((ch = getopt(argc, argv, "Aajnrst")) != -1) { switch (ch) { case 'A': Auto_bot = true; break; case 'a': Start_level = 4; break; case 'j': Jump = true; break; case 'n': Num_games++; break; case 'r': Real_time = true; break; case 's': show_only = true; break; case 't': Teleport = true; break; default: errx(1, "Usage: robots [-Aajnrst] [maximum] [scorefile]"); break; } } for (i = optind; i < argc; i++) { word = argv[i]; if (isdigit((unsigned char)word[0])) { maximum = atoi(word); } else { Scorefile = word; Max_per_uid = maximum; if (score_wfd >= 0) close(score_wfd); score_wfd = open(Scorefile, O_RDWR); if (score_wfd < 0) score_err = errno; #ifdef FANCY word = strrchr(Scorefile, '/'); if (word == NULL) word = Scorefile; if (strcmp(word, "pattern_roll") == 0) Pattern_roll = true; else if (strcmp(word, "stand_still") == 0) Stand_still = true; if (Pattern_roll || Stand_still) Teleport = true; #endif } } if (show_only) { show_score(); exit(0); /* NOTREACHED */ } if (score_wfd < 0) { errno = score_err; warn("%s", Scorefile); warnx("High scores will not be recorded!"); sleep(2); } if (!initscr()) errx(0, "couldn't initialize screen"); signal(SIGINT, quit); cbreak(); noecho(); nonl(); if (LINES != Y_SIZE || COLS != X_SIZE) { if (LINES < Y_SIZE || COLS < X_SIZE) { endwin(); printf("Need at least a %dx%d screen\n", Y_SIZE, X_SIZE); exit(1); } delwin(stdscr); stdscr = newwin(Y_SIZE, X_SIZE, 0, 0); } srandom(time(NULL)); if (Real_time) signal(SIGALRM, move_robots); do { while (Num_games--) { init_field(); for (Level = Start_level; !Dead; Level++) { make_level(); play_level(); if (Auto_bot) sleep(1); } move(My_pos.y, My_pos.x); printw("AARRrrgghhhh...."); refresh(); if (Auto_bot) sleep(1); score(score_wfd); if (Auto_bot) sleep(1); refresh(); } Num_games = 1; } while (!Auto_bot && another()); quit(0); /* NOTREACHED */ return(0); }
int start_game(){ char board[ BOARD_HEIGHT ][ BOARD_WIDTH ]; char mtx_brick[4][4]; int score = 0; int level = 0; int lines = 0; int tmp_lines = 0; char x, y; char brick; char next_brick; int vel = 10; timespec req; req.tv_sec = 0; req.tv_nsec = vel * PULSE; srand( time( 0 ) ); memset( board, 0, BOARD_HEIGHT * BOARD_WIDTH ); next_brick = rand() % 7 + 1; init_screen(); WINDOW* wboard = create_wboard(); WINDOW* wpreview = create_wpreview(); WINDOW* wscore = create_wscore(); show_title(); show_score( wscore, score, level, lines ); wait_start( wboard ); bool play = true; while( play ){ brick = next_brick; next_brick = rand() % 7 + 1; show_preview( wpreview, next_brick ); show_score( wscore, score, level, lines ); show_board( wboard, board ); x = ( ( BOARD_WIDTH / 3 ) % 2 == 0 ) ? BOARD_WIDTH / 3 : BOARD_WIDTH / 3 + 1; y = - 3; get_brick( brick, mtx_brick ); bool move = true; int delay = 0; while( move ){ switch( getch() ){ case KEY_UP: move_brick( wboard, board, mtx_brick, brick, &y, &x, ROTATE_R ); break; case 'z': move_brick( wboard, board, mtx_brick, brick, &y, &x, ROTATE_R ); break; case 'x': move_brick( wboard, board, mtx_brick, brick, &y, &x, ROTATE_L ); break; case KEY_DOWN: move_brick( wboard, board, mtx_brick, brick, &y, &x, DOWN ); break; case KEY_LEFT: move_brick( wboard, board, mtx_brick, brick, &y, &x, LEFT ); break; case KEY_RIGHT: move_brick( wboard, board, mtx_brick, brick, &y, &x, RIGHT ); break; case ' ': move_brick( wboard, board, mtx_brick, brick, &y, &x, BOTTOM ); break; case 27: play = move = false; break; case 'q': play = move = false; break; default: break; } // switch( getch() ) if( ++delay == DELAY_DOWN ){ move_brick( wboard, board, mtx_brick, brick, &y, &x, DOWN ); } if( delay == DELAY_BOTTOM ){ delay = 0; if( check_brick(mtx_brick, board, y + 1, x ) ){ move = false; if( y < 0 ) play = false; } } nanosleep( &req, 0 ); } // while( move ) set_board( board, mtx_brick, brick, y, x ); tmp_lines += check_lines( board, &score, &lines ); if( tmp_lines >= CH_LEV ){ req.tv_nsec = vel * PULSE; score += 1; level++; if( vel > 1 ) vel--; tmp_lines = tmp_lines % CH_LEV; } } // while( quit ) delwin( wboard ); delwin( wpreview ); delwin( wscore ); restore_screen(); return 0; }
int main(int argc, char **argv) { BrailleMusicEditor *editor; // allocate the memory needed by our BrailleMusicEditor struct editor = g_slice_new (BrailleMusicEditor); //initialize GTK+ libraries gtk_init(&argc, &argv); ev_init(); // Creation of the main window create_window("BMC",600,400, editor); editor->vbox = gtk_vbox_new(FALSE, 2); gtk_container_add(GTK_CONTAINER(editor->window), editor->vbox); //Creation of the menubar create_menubar(editor); gtk_box_pack_start(GTK_BOX(editor->vbox), editor->menubar, FALSE, FALSE, 0); // Creation of the toolbar create_toolbar(editor); gtk_box_pack_start(GTK_BOX(editor->vbox), editor->toolbar, FALSE, FALSE, 2); //Creation of the two text views with scrollbars editor->hbox = gtk_hbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(editor->vbox), editor->hbox); editor->edit_scrollbar = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(editor->edit_scrollbar), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start(GTK_BOX(editor->hbox),editor->edit_scrollbar, TRUE, TRUE, 5); editor->textview=gtk_source_view_new(); //show line number gtk_source_view_set_show_line_numbers(GTK_SOURCE_VIEW(editor->textview), TRUE); g_signal_connect(gtk_text_view_get_buffer(GTK_TEXT_VIEW(editor->textview)), "changed", G_CALLBACK(on_text_changed), editor); gtk_container_add(GTK_CONTAINER(editor->edit_scrollbar), editor->textview); //lexical coloration auto update g_signal_connect(gtk_text_view_get_buffer(GTK_TEXT_VIEW(editor->textview)), "changed", G_CALLBACK(coloration_update), editor); //score view editor->score_scrollbar = gtk_scrolled_window_new(NULL, NULL); gtk_box_pack_start(GTK_BOX(editor->hbox),editor->score_scrollbar, TRUE, TRUE, 5); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(editor->score_scrollbar), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); editor->score_view = ev_view_new(); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(editor->score_scrollbar), editor->score_view); show_score(editor); gtk_widget_grab_focus(editor->textview); //Creation of the message error views with scrollbar editor->error_scrollbar = gtk_scrolled_window_new(NULL, NULL); gtk_box_pack_start(GTK_BOX(editor->vbox),editor->error_scrollbar, FALSE, TRUE, 0); gtk_widget_set_size_request (editor->error_scrollbar, -1, 100); gtk_container_set_border_width(GTK_CONTAINER(editor->error_scrollbar), 5); editor->error_view = gtk_text_view_new(); gtk_text_view_set_editable(GTK_TEXT_VIEW(editor->error_view), FALSE); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(editor->error_scrollbar), editor->error_view); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(editor->error_scrollbar), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); // show the window gtk_widget_show_all(editor->window); // enter GTK+ main loop gtk_main(); // free memory we allocated for BrailleMusicEditor struct g_slice_free (BrailleMusicEditor, editor); return EXIT_SUCCESS; }