예제 #1
0
파일: Interface.cpp 프로젝트: octol/kexx2
void Interface::draw(sdlc::Font& font, sdlc::Screen& screen)
{
    // player 1
    int e = player_state_.energy(1);
    int eMax = player_state_.energy_max(1);
    int s = player_state_.score(1);

    if (!e) {
        screen.print(20, 440, "dead", font);
    } else {
        draw_energy(20, 440, e, eMax, font, screen);
    }

    draw_score(20, 20, s, font, screen);
    draw_weapons(20, 40, player_state_, 1, font, screen);

    // player 2
    e = player_state_.energy(2);
    eMax = player_state_.energy_max(2);
    s = player_state_.score(2);
    if (num_of_players_ >= 2) {
        if (!e) {
            screen.print(560, 440, "dead", font);
        } else {
            draw_energy(560, 440, e, eMax, font, screen);
        }

        draw_score(400, 20, s, font, screen);
        draw_weapons(400, 40, player_state_, 2, font, screen);
    }
}
예제 #2
0
파일: main.c 프로젝트: Gwagwa7/Arkanoid
static void	draw_stuff(t_game *game)
{
	draw_board(game);
	draw_blocks(game);
	draw_ball(game);
	draw_score(game->score, 1.8f, -1.6f);
	draw_score(game->life, 0.2f, -1.6f);
}
예제 #3
0
파일: snake.c 프로젝트: macrosheep/snake
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;
}
예제 #4
0
파일: update.c 프로젝트: MaxLeiter/pong
void score(bool player) {
	if (player) {
		left_score++;
	} else {
		right_score++;
	}

	ball_motion.x = -ball_motion.x;

	if (ball_motion.y > 1) {
		ball_motion.y = 1;
	} else if (ball_motion.y < -1) {
		ball_motion.y = -1;
	}

	ball.x = DISPLAY_WIDTH / 2 - (ball_width / 2);
	ball.y = DISPLAY_HEIGHT / 2 - (ball_height / 2);

	if (game_running) {
		screen_clear(screen);
		draw_actors();
		draw_score();
		draw_string(screen, 40, 10, "SCORE");
		screen_draw(screen);
		ksleep(1000);
	}
}
void draw_score_board(long long int score)
{
    curr_score=score;
    glPushMatrix();
    glTranslatef(SCORE_BOARD_PADDING, height - SCORE_BOARD_HEIGHT - 20, 0);
    glColor3f(0.0,0.0,0.0);
    glBegin(GL_POLYGON);
        glVertex2f(0, 0);
        glVertex2f(SCORE_BOARD_WIDTH, 0);
        glVertex2f(SCORE_BOARD_WIDTH, SCORE_BOARD_HEIGHT);
        glVertex2f(0, SCORE_BOARD_HEIGHT);
    glEnd();
    glLineWidth(5);
    glColor3f(0,0,1);
    glBegin(GL_LINE_STRIP);
        glVertex2f(0, 0);
        glVertex2f(SCORE_BOARD_WIDTH, 0);
        glVertex2f(SCORE_BOARD_WIDTH, SCORE_BOARD_HEIGHT);
        glVertex2f(0, SCORE_BOARD_HEIGHT);
        glVertex2f(0,0);
    glEnd();
    glLineWidth(1);
    glColor3f(1,0.98,0);
        glPushMatrix();
            glTranslatef(8,8,0);
            glScalef(0.2,0.2,1);
            draw_score(curr_score);
        glPopMatrix();
    glPopMatrix();
}
예제 #6
0
void block_reached_bottom(nstate *state)
{
	int x, y, nr;

	if(!block_is_all_in_well(state)) {
		state->state = STATE_STOPPED;
		return;
	}

	for(y = WELL_HEIGHT - 1; y; y--) {
		nr = 0;
		for(x = 0; x < WELL_WIDTH; x++) {
			if(!state->blocks[0][y][x]) {
				nr = 1;
				break;
			}
		}
		if(nr) continue;
		msleep(DELETE_LINE_DELAY);
		delete_line(state, y);
		state->score += SCORE_INCREMENT;
		if((LEVELS > (state->level + 1)) && (((state->level + 1) *
					LEVEL_DIVISOR) <= state->score))
			state->level++;
		draw_score(state);
		y++;
	}

	choose_new_shape(state);
	draw_next_shape(state);
}
예제 #7
0
파일: engine.c 프로젝트: gsrr/Python
/**	Draws the Game Over screen.
 *
 *	Besides drawing 'Game Over', it highlights where the player died.
 */
void engine_show_game_over ()
{
	attron (COLOR_PAIR (RED_BLACK));
	mvaddch (snake.body[0].y, snake.body[0].x, 'x');

	mvprintw (3, 22,  " _______  _______  __   __  _______ ");
	mvprintw (4, 22,  "|       ||   _   ||  |_|  ||       |");
	mvprintw (5, 22,  "|    ___||  |_|  ||       ||    ___|");
	mvprintw (6, 22,  "|   | __ |       ||       ||   |___ ");
	mvprintw (7, 22,  "|   ||  ||       ||       ||    ___|");
	mvprintw (8, 22,  "|   |_| ||   _   || ||_|| ||   |___ ");
	mvprintw (9, 22,  "|_______||__| |__||_|   |_||_______|");
	mvprintw (10, 22, " _______  __   __  _______  ______  ");
	mvprintw (11, 22, "|       ||  | |  ||       ||    _ | ");
	mvprintw (12, 22, "|   _   ||  |_|  ||    ___||   | || ");
	mvprintw (13, 22, "|  | |  ||       ||   |___ |   |_|| ");
	mvprintw (14, 22, "|  |_|  ||       ||    ___||    __ |");
	mvprintw (15, 22, "|       | |     | |   |___ |   |  ||");
	mvprintw (16, 22, "|_______|  |___|  |_______||___|  ||");
	mvprintw (17, 28,       "Press <enter> to retry");
	mvprintw (18, 31,          "<m> to Main Menu");
	draw_score ();

	refresh ();
}
예제 #8
0
파일: invaders.c 프로젝트: miloh/f1rmware
void ram(void) {
	while(1) {
		if (!screen_intro()){
      setTextColor(0xff,0x00);
      return;
    }
		game.rokets = 3;
		game.level = 1;
		game.score = 0;
		init_game();
		screen_level();
		while (game.rokets>=0) {
			////checkISP();
			lcdFill(0x00);
			check_end();
			move_ufo();
			move_shot();
			move_shots();
			move_player();
			move_enemy();
			draw_score();
			draw_ufo();
			draw_bunker();
			draw_player();
			draw_enemy();
			draw_shots();
			//        draw_status();
			lcdDisplay();
			delayms(12);
		}
		if (!screen_gameover())
      setTextColor(0xff,0x00);
      return;
	}
}
예제 #9
0
파일: r0type.c 프로젝트: andrmuel/r0ket
static void draw_game(void){
  draw_ship();
  draw_shots();
  draw_score();
  make_asteroids();
  detect_collitions();
  draw_environ();
}
예제 #10
0
static void screen_level() {
	lcdFill(0);
	draw_score();
	font = &Font_7x8;
	int dx = DoString(20,32, "Level ");
	DoInt(dx,32,game.level);
	lcdDisplay();
	delayms_queue(500);
}
예제 #11
0
void
level_draw(LEVEL *level)
{
  draw_score(level->score);
  asteroid_draw_list(level->asteroids);

  if(level->saucer)
    saucer_draw(level->saucer);
}
예제 #12
0
파일: invaders.c 프로젝트: miloh/f1rmware
static void screen_level() {
	lcdFill(0x00);
	draw_score();
	setIntFont(&Font_7x8);
	lcdSetCrsr(20,32);
  setTextColor(0x00,0xff);
	lcdPrint("Level ");
	lcdPrint(IntToStr(game.level,3,0));
	lcdDisplay();
	delayms_queue(500);
}
예제 #13
0
void new_game(nstate *state)
{
	clear_well(state);
	if(state->score > state->hiscore) state->hiscore = state->score;
	state->score = 0;
	state->level = 0;
	draw_score(state);
	choose_new_shape(state);
	draw_next_shape(state);
	draw_well(state, 1);
	if(state->state == STATE_NEWGAME) state->state = STATE_RUNNING;
}
예제 #14
0
void start_level(int l)
{
  init_level(l);   /* Initalize the snake */
  game_state = SNAKE_PLAYING;
  if(global_snake.score < 60)
  	game_speed = start_speed + 10;
  nibble.active = 0;
  nibble.x = 0;
  nibble.y = 0;

  draw_score();
}
예제 #15
0
파일: eatem.cpp 프로젝트: UIKit0/Eat--em
void draw_scene()
{
	glClearColor(0.0, 0.0, 0.0, 0.0);
	glClear(GL_COLOR_BUFFER_BIT);
	
	if (firstdraw == true || reset == true)
	{
		if (firstdraw == true)
		{
			timer = SDL_AddTimer(timer_speed, game_timer, 0);
			setfield("ghostmap.txt", ghostfield);
			setfield("pacmap-inversion.txt", ghostrun);
			pacman.next_x = pacman.x + 1;
		}
		setfield("pacmap.txt", playfield);
		//initialize ghosts
		g_blinky.status = ST_BLINKY;
		g_pinky.status = ST_PINKY;
		g_inky.status = ST_INKY;
		g_clyde.status = ST_CLYDE;
		g_blinky.direction = ST_LEFT;
		g_pinky.direction = ST_LEFT;
		g_inky.direction = ST_LEFT;
		g_clyde.direction = ST_LEFT;
		g_blinky.has_los = false;
		g_pinky.has_los = false;
		g_inky.has_los = false;
		g_clyde.has_los = false;
		g_blinky.x = 43;
		g_blinky.y = 8;
		g_pinky.x = 53;
		g_pinky.y = 15;
		g_inky.x = 51;
		g_inky.y = 22;
		g_clyde.x = 57;
		g_clyde.y = 22;
	}
	Ai::encompassing();
	//displayfield(ghostfield);
	draw_playfield();
	draw_pacman();
	draw_ghosts();
	draw_score();
	
	SDL_GL_SwapBuffers();
	int error = glGetError();
	if (error != 0)
	{
		fileout << "Error: " << error << endl << flush;
		cout << "Error: " << error << endl << flush;
	}
}
예제 #16
0
파일: engine.c 프로젝트: gsrr/Python
/**	Completely draws the screen during game.
 *
 * 	The usleep() function interrupts the program for 'n' microseconds.
 * 	It was difficult to get a stable value for the game progression.
 *
 *	@note This is the main function of this file because it shows
 * 	      logically how the process of drawing the screen sould be
 */
void engine_show_screen ()
{
	draw_background ();
	draw_borders ();
	draw_fruit ();
	draw_player ();
	draw_fruit_bonus();
	draw_score ();

	usleep (REFRESH_DELAY);

	refresh();
}
예제 #17
0
void start_game(void)
{
  current_level = 0;

  global_snake.lives = 3;
  global_snake.score = 0;

  game_speed = start_speed;

  start_level(current_level);
  draw_score();
  do_frame(1);
}
예제 #18
0
int main()
{
	g_level = 0;
	g_nEnemy = 1;	//	敵機数:1
	init();
	draw_map();
	draw_car();
	draw_enemy();
	draw_score();
	g_db.swap();		//	表示バッファ切り替え
	getchar();
	return 0;
}
예제 #19
0
void draw_sceen(double teta){
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();
    gluLookAt(300,0,0,0,0,0,0,0,1);

    glPushMatrix();
    glRotated(10,0,1,0);
    draw_cubes_ship(teta);
    draw_score();
    glPopMatrix();
    glFlush();
    SDL_GL_SwapBuffers();
}
예제 #20
0
파일: ofApp.cpp 프로젝트: Iwanaka/shooter
//--------------------------------------------------------------
void ofApp::draw(){

	if(game_state=="start"){

		start_screen.draw(0,0,ofGetWidth(),ofGetHeight());//初期画面の描画
		draw_score();//score表示

	}else if(game_state=="tutorial"){
		tutorial_screen.draw(0,0,ofGetWidth(),ofGetHeight());

	}else if(game_state=="game"){//ゲーム画面の描画

		game_screen.draw(0,0,ofGetWidth(),ofGetHeight());
		player_1.draw();//player1を表示
		draw_lives();//draw_livesを表示
		draw_score();//score表示
		boss_1.draw();


		//Enemyのvectorによる配列
		for(int i=0;i<enemies.size();i++){
			enemies[i].draw();
		}
		//Bulletのvectorによる配列
		for(int i=0;i<bullets.size();i++){
			bullets[i].draw();
		}
		//bonusesのvectorによる配列
		for(int i=0;i<bonuses.size();i++){
			bonuses[i].draw();
		}

	}else if(game_state=="end"){//終了画面の描画
		end_screen.draw(0,0,ofGetWidth(),ofGetHeight());
		draw_score();
	}
}
예제 #21
0
void handle_exposure_event(nstate *state)
{
	GR_EVENT_EXPOSURE *event = &state->event.exposure;

	if(event->wid == state->score_window) {
		draw_score(state);
		return;
	}
	if(event->wid == state->next_shape_window) {
		draw_next_shape(state);
		return;
	}
	if(event->wid == state->new_game_button) {
		draw_new_game_button(state);
		return;
	}
	if(event->wid == state->pause_continue_button) {
		draw_pause_continue_button(state);
		return;
	}
	if(event->wid == state->anticlockwise_button) {
		draw_anticlockwise_button(state);
		return;
	}
	if(event->wid == state->clockwise_button) {
		draw_clockwise_button(state);
		return;
	}
	if(event->wid == state->left_button) {
		draw_left_button(state);
		return;
	}
	if(event->wid == state->right_button) {
		draw_right_button(state);
		return;
	}
	if(event->wid == state->drop_button) {
		draw_drop_button(state);
		return;
	}
	if(event->wid == state->well_window) {
		draw_well(state, 1);
		return;
	}
}
예제 #22
0
파일: score.c 프로젝트: shaftoes/carlaga
void do_score()
{
    static int lastscore, lastlevel, lastships;
#ifdef SOUND
    static int lastsounds;
#endif
    if (lastscore != score) 
    {
	if ((score > 0) && (score >= nextBonus)) 
        {
	    ships++;
	    extrax = 0 - extraImage->width/2;
	    extray = WINHEIGHT/2;
	    drawExtra = 1;
	    if (nextBonus < BONUSSHIPSCORE)
		nextBonus = BONUSSHIPSCORE;
	    else
		nextBonus += BONUSSHIPSCORE;
	}
    }

#ifdef SOUND
    if (lastscore != score || lastlevel != level || lastships != ships || lastsounds != playSounds) 
#else
    if (lastscore != score || lastlevel != level || lastships != ships) 
#endif
    {
    	W_ClearArea(shellWin, 0, 0, WINWIDTH, W_Textheight + 1);
	draw_score();
	lastscore=score;
	lastlevel=level;
	lastships=ships;
#ifdef SOUND
        lastsounds=playSounds;
#endif
    }

    if (drawExtra) 
    {
	extrax += 10;
	W_DrawImage(baseWin, extrax-(extraImage->width/2), extray-(extraImage->height/2), 0, extraImage, W_White);
	if((extrax-(int)extraImage->width/2) > WINWIDTH)
	    drawExtra = 0;
    }
}
예제 #23
0
void do_snake_advance(void)
{
  switch(advance_snake())
    {
    case MOVE_LEGAL:
      do_frame(0);
      break;
      
    case MOVE_NIBBLE:
      if ((global_snake.score % LEVEL_SCORE) == 0)
		{
	  	current_level++;
	  	game_state = SNAKE_NEXTLEVEL;
        if(global_snake.score > 60)
    		global_snake.lives ++;
	  	draw_string((char *) nextlevel, 2);
	  	show_buffer();
		}
      else
		{
        /* As it's not just a point : */
        nibble.active = 0;
        do_frame(0);
	  	draw_score();
		}
      
      break;
      
    case MOVE_ILLEGAL:
      global_snake.lives--;
      //global_snake.score = 0;
      if (!global_snake.lives)
		end_game();
      else
		{
	  	game_state = SNAKE_NEXTLEVEL;
	  	draw_string((char *) snakedied, 2);
	  	show_buffer();
		}
      
      break;
    }
}
예제 #24
0
int				draw_score(int n, float offset_x, float offset_y)
{
	if (n < INT_MAX)
	{
		if (n >= 0)
		{
			if (n >= 10)
			{
				draw_text(offset_x, offset_y, n % 10);
				offset_x = offset_x - 0.15;
				return (draw_score(n / 10, offset_x, offset_y));
			}
			else
				draw_text(offset_x, offset_y, n);
		}
	}
	else if (n == INT_MAX)
		draw_text(offset_x, offset_y, INT_MAX);
	return (0);
}
예제 #25
0
파일: terminal.c 프로젝트: nicocoffo/zabar
void reset_terminal(void){
	clear_terminal();
	
	set_display_attribute(BAR_COLOUR);
	draw_horizontal_line(1,1,WIDTH);
	set_display_attribute(BAR_COLOUR);
	draw_vertical_line(40,1,HEIGHT);
	
	move_cursor(TITLE_X,TITLE_Y);
	printf_P(PSTR("FROGGER"));
	
	draw_lives();
	draw_score();
	draw_level();
	draw_time(16);
	display_scores();
	draw_status(0);
	draw_frog();
	
	set_display_attribute(8);
}
예제 #26
0
파일: draw.c 프로젝트: akabab/atari
void				draw_level(t_level *level)
{
	t_list_node		*cursor;
	t_brick			*cur_brick;

	cursor = level->brick_list;
	while (cursor)
	{
		cur_brick = (t_brick *)cursor->value;
		if (cur_brick->val > 0)
			draw_brick(cur_brick);
		cursor = cursor->next;
	}
	update_ball(level->ball, level->brick_list);
	draw_ball(level->ball);
	update_pad(level->pad, level->ball);
	draw_pad(level->pad);
	draw_level_border();
	draw_lives(level->lives);
	draw_score(level->score);
}
예제 #27
0
void draw()
{
	int i;
	for(i=lewa_sciana; i<=prawa_sciana; i++)
	{
		PCD8544_DrawPixel(i, gorna_sciana,PCD8544_Pixel_Set);
		PCD8544_DrawPixel(i, dolna_sciana,PCD8544_Pixel_Set);
	}

	for(i=gorna_sciana; i<=dolna_sciana; i++)
	{
		PCD8544_DrawPixel(lewa_sciana, i,PCD8544_Pixel_Set);
		PCD8544_DrawPixel(prawa_sciana, i,PCD8544_Pixel_Set);
	}
	draw_snake();
	draw_apple();

	draw_score();

	PCD8544_Refresh();

}
예제 #28
0
int main()
{
	//mciSendString(TEXT("open button57.mp3"), NULL, 0, NULL);
	//mciSendString(TEXT("open s-burst01.mp3"), NULL, 0, NULL);
	//mciSendString(TEXT("open one23.mp3"), NULL, 0, NULL);
	for (;;) {
		bool rc = game();
		g_db.setCursorPos(0, CONS_HT - 1);
		g_db.setColor(COL_GRAY, COL_BLACK);
		//if( rc ) {
		//	g_db.write("!!! GOOD JOB !!!");
		//} else {
			g_db.write("GAME OVER.");
		//}
		g_db.write(" Try Again ? [y/n] ");
		draw_map();
		draw_enemy();
		draw_car();
		draw_score();
		g_db.swap();
		for (;;) {
			if( isKeyPressed('N') )
				return 0;
			if( isKeyPressed('Y') )
				break;
			Sleep(LOOP_INTERVAL);		//	10ミリ秒ウェイト
		}
		g_db.setCursorPos(0, CONS_HT - 1);
		for (int i = 0; i < CONS_WD - 1; ++i) {
			g_db.write(" ");
		}
		g_db.swap();
		g_db.setCursorPos(0, CONS_HT - 1);
		for (int i = 0; i < CONS_WD - 1; ++i) {
			g_db.write(" ");
		}
	}
	return 0;
}
예제 #29
0
파일: jeu.c 프로젝트: BullPaf/Pacman
/*Fonction du jeu*/
void jouer(Pacman *pac, Fantome *ftm, Input in, config *cfg, int level, score_message **msg_list)
{
	int i;
	SDL_Delay(DELAY);
	set_pac_target(pac); //Cherche l'endroit ou aller pour pacman
	//Fonction de déplacement de pacman
	pac->controllerFonction(in, *cfg, pac->controlled_by, &(pac->position), &(pac->cur_direction), &(pac->nb_keys), &(pac->speed), &(pac->num_image), pac->target);
	for(i=0; i<NB_GHOST; i++)
	{
		set_ftm_target(ftm+i, pac->position);
		ftm[i].controllerFonction(in, *cfg, ftm[i].controlled_by, &(ftm[i].position), &(ftm[i].cur_direction), &(ftm[i].nb_keys), &(ftm[i].speed), &(ftm[i].num_image), ftm[i].target);
	}
	updatePacman(pac);
	updateGhosts(ftm);
	SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
	draw_level();
	draw_pac_infos(pac);
	draw_score(pac->score, level);
	affiche_pacman(pac);
	affiche_fantomes(ftm);
	action(pac, ftm, msg_list);
	display_messages(msg_list);
	SDL_Flip(screen);
}
예제 #30
0
/**
 * Mouse button press callback
 *
 */
gint
scorearea_button_press (GtkWidget * widget, GdkEventButton * event)
{
  DenemoProject *gui = Denemo.project;
  if (gui == NULL || gui->movement == NULL)
    return FALSE;
  gboolean left = (event->button != 3);
  //if the cursor is at a system separator start dragging it
  gint allocated_height = get_widget_height (Denemo.scorearea);
  gint line_height = allocated_height * gui->movement->system_height;
  gint line_num = ((int) event->y) / line_height;
  last_event_x = event->x_root;
  last_event_y = event->y_root;
  //g_debug("diff %d\n", line_height - ((int)event->y)%line_height);

  if (dragging_separator == FALSE)
    if (line_height - ((int) event->y - 8) % line_height < 12)
      {
        if (Denemo.prefs.learning)
          MouseGestureShow(_("Dragging line separator."), _("This will allow the display to show more music, split into lines. The typeset score is not affected."),
            MouseGesture);
        dragging_separator = TRUE;
        return TRUE;
      }
  dragging_separator = FALSE;

  if(gui->movement->recording)
    {
     //g_debug("audio %f %f\n", event->x, event->y);


      if(event->y < 20*gui->movement->zoom /* see draw.c for this value, the note onsets are drawn in the top 20 pixels */)
        {
            if (event->type==GDK_2BUTTON_PRESS)
                {
                    gui->movement->marked_onset_position = (gint)event->x/gui->movement->zoom;
                    if(gui->movement->marked_onset_position < (gui->leftmargin+35) + SPACE_FOR_TIME + gui->movement->maxkeywidth) {
                         if (Denemo.prefs.learning)
                            MouseGestureShow(_("Double Click Note Onset"), _("This represents detected note onsets which occur\nbefore the start of the score.\nIf they are just noise,\nor if you are working on just a portion of the audio that is ok.\nOtherwise drag with left mouse button to synchronize\nwith the start of the score."),
          MouseGesture);

                    }
                    gtk_widget_queue_draw(Denemo.scorearea);
                    return TRUE;
                } else
                {
                    gdk_window_set_cursor (gtk_widget_get_window (Denemo.window), gdk_cursor_new (left?GDK_SB_H_DOUBLE_ARROW:GDK_X_CURSOR));
                    left? (dragging_audio = TRUE) : (dragging_tempo = TRUE);
                     if (Denemo.prefs.learning)
                     left? MouseGestureShow(_("Left Drag Note Onset"), _("This moves the audio to synchronize the start with the score.\nYou can use the Leadin button for this too."),
          MouseGesture) :
                        MouseGestureShow(_("Right Drag Note Onset"), _("This changes the tempo of the score.\nUse this to synchronize the beat after setting the start"),
          MouseGesture);
                    gtk_widget_queue_draw(Denemo.scorearea);
                    return TRUE;
                }
        }

    }


  //g_debug("before %f %f\n", event->x, event->y);
  transform_coords (&event->x, &event->y);
  //g_debug("after %f %f\n", event->x, event->y);


  gtk_widget_grab_focus (widget);
  gint key = gui->movement->maxkeywidth;
  gint cmajor = key ? 0 : 5;    //allow some area for keysig in C-major

  if (gui->lefts[line_num] == 0)
    return TRUE;                //On an empty system at the bottom where there is not enough room to draw another staff.

  struct placement_info pi;
  pi.the_staff = NULL;
  if (event->y < 0)
    get_placement_from_coordinates (&pi, event->x, 0, gui->lefts[line_num], gui->rights[line_num], gui->scales[line_num]);
  else
    get_placement_from_coordinates (&pi, event->x, event->y, gui->lefts[line_num], gui->rights[line_num], gui->scales[line_num]);
  if (pi.the_staff == NULL)
    return TRUE;                //could not place the cursor
  change_staff (gui->movement, pi.staff_number, pi.the_staff);


  if (left && (gui->movement->leftmeasurenum > 1) && (event->x < (gui->leftmargin+35) + SPACE_FOR_TIME + key) && (event->x > gui->leftmargin))
    {
      if (Denemo.prefs.learning)
        MouseGestureShow(_("Press Left."), _("This moved the cursor to the measure offscreen left. The display is shifted to place that measure on screen."),
          MouseGesture);
      set_currentmeasurenum (gui, gui->movement->leftmeasurenum - 1);
      write_status (gui);
      draw_score_area();
      return TRUE;
    }
  else if (pi.nextmeasure)
    {
      if ((pi.at_edge) && ((pi.the_obj==NULL) || ((pi.the_obj->next == NULL) && (pi.offend))))//crashed here with the_obj 0x131 !!!
        {
          if ((gui->movement->currentmeasurenum != gui->movement->rightmeasurenum) &&
                (!set_currentmeasurenum (gui, gui->movement->rightmeasurenum + 1)))
              set_currentmeasurenum (gui, gui->movement->rightmeasurenum);
          else if ((gui->movement->cursor_appending) &&
                (!set_currentmeasurenum (gui, gui->movement->rightmeasurenum + 1)))
              set_currentmeasurenum (gui, gui->movement->rightmeasurenum);




          if (gui->movement->currentmeasurenum != gui->movement->rightmeasurenum) {
            if (Denemo.prefs.learning)
              MouseGestureShow(_("Press Left."), _("This moved the cursor to the measure off-screen right. The display is shifted to move the cursor to the middle."),
                MouseGesture);
          write_status (gui);
          return TRUE;
        }
        }
    }


  if (pi.the_measure != NULL)
    {                           /*don't place cursor in a place that is not there */
      //gui->movement->currentstaffnum = pi.staff_number;
      //gui->movement->currentstaff = pi.the_staff;
      gui->movement->currentmeasurenum = pi.measure_number;
      gui->movement->currentmeasure = pi.the_measure;
      gui->movement->currentobject = pi.the_obj;
      gui->movement->cursor_x = pi.cursor_x;
      gui->movement->cursor_appending = (gui->movement->cursor_x == (gint) (g_list_length ((objnode *) ((DenemoMeasure*)gui->movement->currentmeasure->data)->objects)));
      set_cursor_y_from_click (gui, event->y);
      if (event->type==GDK_2BUTTON_PRESS)
                {
                    if(gui->movement->recording &&  !g_strcmp0 (((DenemoStaff *) gui->movement->currentstaff->data)->denemo_name->str, DENEMO_CLICK_TRACK_NAME))
                        {
                            gui->movement->marked_onset_position = (gint)event->x/gui->movement->zoom;
                            if (Denemo.prefs.learning)
                                MouseGestureShow(_("Double Click on Click Track"), _("This will mark the MIDI note onset."), MouseGesture);
                            return TRUE;

                        }

                    else
                        {
                          if (Denemo.prefs.learning)
                            MouseGestureShow(_("Double Click."), _("This gives information about the object at the cursor. Click on a notehead for information about a note in a chord."),
                              MouseGesture);
                                    display_current_object();
                                    return TRUE;
                        }
                }
            else
                {
                  if (Denemo.prefs.learning)
                    MouseGestureShow(_("Press Left."), _("This moved the cursor to the object position clicked. The cursor height becomes the clicked point."),
                      MouseGesture);
                            write_status (gui);
               }
            }

  gint offset = (gint) get_click_height (gui, event->y);

   if ((((DenemoStaff *) gui->movement->currentstaff->data)->voicecontrol != DENEMO_PRIMARY)
        && (gui->movement->leftmeasurenum == 1) && (event->x > gui->leftmargin)
        && ((event->x < (gui->leftmargin+35) + SPACE_FOR_TIME + key)))
    {
          infodialog(_("The clef shown here affects the display only (as this voice is displayed on the staff above)."
          " You can change the display clef using the clef menu."
          "\nWarning! you will get confused if you set the key signature or time signature of a voice different "
          "to the staff it is typeset on. Run the Staff/Voice property editor to adjust any inconsistencies."));

    }
  if ((((DenemoStaff *) gui->movement->currentstaff->data)->voicecontrol == DENEMO_PRIMARY) && (gui->movement->leftmeasurenum == 1) && (event->x > gui->leftmargin))
    {
      if (event->x < (gui->leftmargin+35) - cmajor)
        {
        if (offset<-10)
            {
                if (Denemo.prefs.learning)
                MouseGestureShow(_("Left on Staff name."), _("This pops up the built-in staff properties. For other properties of the current staff see the staff menu or the tools icon before the clef."),
                  MouseGesture);
                staff_properties_change_cb (NULL, NULL);
            }
        else
            {
              if (Denemo.prefs.learning)
                MouseGestureShow(_("Left on initial Clef."), _("This pops up the initial clef menu."),
                  MouseGesture);
              popup_menu ("/InitialClefEditPopup");
            }
          return TRUE;
        }
      else if (event->x < (gui->leftmargin+35) + key + cmajor)
        {
          if (left)
            {
              if (offset > 0 && (offset < STAFF_HEIGHT / 2))
                {
                  if (Denemo.prefs.learning)
                    MouseGestureShow(_("Left Click on blue."), _("This adds one sharp."),
                      MouseGesture);
                if ((gui->movement->currentmeasure->next==NULL)  || confirm (_("Initial Key Signature Change"), _("Sharpen Keysignature?")))
                  call_out_to_guile ("(d-SharpenInitialKeysigs)");
                }
              else if (offset > 0 && (offset < STAFF_HEIGHT))
                {
                  if (Denemo.prefs.learning)
                    MouseGestureShow(_("Left Click on red."), _("This adds one flat."),
                      MouseGesture);
                  if ((gui->movement->currentmeasure->next==NULL) || confirm (_("Initial Key Signature Change"), _("Flatten Keysignature?")))
                    call_out_to_guile ("(d-FlattenInitialKeysigs)");
                }
            }
          else
            {
              if (Denemo.prefs.learning)
                MouseGestureShow(_("Right Click on key."), _("This pops up the key signature menu."),
                    MouseGesture);
              popup_menu ("/InitialKeyEditPopup");
            }
          return TRUE;
        }
      else if (event->x < (gui->leftmargin+35) + SPACE_FOR_TIME + key)
        {
          if (Denemo.prefs.learning)
            MouseGestureShow(_("Click on Time."), _("This pops up the time signature menu."),
                    MouseGesture);
          popup_menu ("/InitialTimeEditPopup");
          return TRUE;
        }
    }

  if (event->x < gui->leftmargin)
    {
       if (gui->braces)
        {
                gint width = BRACEWIDTH * g_list_length (gui->braces);
                //gint count = (gui->leftmargin - event->x)/BRACEWIDTH;
                if ((gui->leftmargin - event->x) < width)
                {
                    gint count = 1 + (width - gui->leftmargin + event->x)/BRACEWIDTH;


                    if ((count>0) && (count <= g_list_length (gui->braces)))
                        {
                            DenemoBrace *brace = (DenemoBrace*)g_list_nth_data (gui->braces, count-1);
                            gint choice = choose_option (_("Editing Staff Groups (Braces)"), _("Edit Start Brace"), _("Edit End Brace"));
                            gint staffnum = choice?brace->startstaff:brace->endstaff;
                            //g_print ("Count is %d for start at %d\n", count, staffnum);
                            GtkWidget *menuitem = gtk_ui_manager_get_widget (Denemo.ui_manager, "/ObjectMenu/StaffMenu/StaffGroupings");
                            goto_movement_staff_obj (NULL, -1, staffnum, 1, 0, 0);
                            if (menuitem)
                                if (choice)
                                    gtk_menu_popup (GTK_MENU (gtk_menu_item_get_submenu (GTK_MENU_ITEM (menuitem))), NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME);
                                else
                                {
                                    if (staff_directive_get_tag ("BraceEnd"))
                                        call_out_to_guile ("(d-BraceEnd)");
                                    else
                                        warningdialog (_( "This staff grouping has no End Brace so it finishes on the lowest staff. Use the Staffs/Voices->Staff Groupings menu to place an End Brace on the desired staff"));
                                }
                            //note the popup returns as soon as the menu is popped up, so we can't go back to the original position.

                        }

                    return TRUE;
                }

        }

      if (pi.staff_number == gui->movement->currentstaffnum)
        {
          gint offset = (gint) get_click_height (gui, event->y);
          if (offset < STAFF_HEIGHT / 2)
            {
              if (((DenemoStaff *) gui->movement->currentstaff->data)->staff_directives, 1)
                {
                  if (Denemo.prefs.learning)
                    MouseGestureShow(_("Click on Staff Directives."), _("This pops up the staff directives menu for editing"),
                      MouseGesture);
                  edit_staff_properties ();//gtk_menu_popup (((DenemoStaff *) gui->movement->currentstaff->data)->staffmenu, NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time ());
                }
              return TRUE;
            }
          else if (((DenemoStaff *) gui->movement->currentstaff->data)->voice_directives, 1)
            {
              if (Denemo.prefs.learning)
                MouseGestureShow(_("Click on Voice Directives."), _("This pops up the voice directives menu for editing"),
                    MouseGesture);
              edit_voice_properties ();//gtk_menu_popup (((DenemoStaff *) gui->movement->currentstaff->data)->voicemenu, NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time ());
              return TRUE;
            }
        }
    }

  if (left)
    {
      if (!(GDK_SHIFT_MASK & event->state))
        gui->movement->markstaffnum = 0;
      lh_down = TRUE;
    }
  else
    {
      if (gui->movement->cursor_appending && (event->state==0))
        {
          if (Denemo.prefs.learning)
           {

                    MouseGestureShow(_("Right Click Appending."), _("This pops up the append menu"),
                        MouseGesture);

           }
          popup_menu ("/NoteAppendPopup");
          return TRUE;
        }

        if ((GDK_CONTROL_MASK & event->state) == GDK_CONTROL_MASK) {
            if (Denemo.prefs.learning)
                    MouseGestureShow(_("Control-Right Click."), _("This pops up menu for inserting barlines and many other sorts of objects"),
                        MouseGesture);
            gtk_menu_popup (GTK_MENU (gtk_widget_get_parent(gtk_ui_manager_get_widget (Denemo.ui_manager, "/ObjectMenu/Directives/Markings"))),
                            NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time ());
            return TRUE;
        }
      if ((GDK_SHIFT_MASK & event->state) == GDK_SHIFT_MASK) {
            if (Denemo.prefs.learning)
                    MouseGestureShow(_("Shift-Right Click."), _("This allows editing the directives/attributes of the object at the cursor"),
                        MouseGesture);
            call_out_to_guile ("(d-EditSimilar 'once)");
            return TRUE;
        }
    }



  if (left && (GDK_SHIFT_MASK & event->state) && (GDK_CONTROL_MASK & event->state))
  {
     // if current object is directive, start dragging its graphic, dragging_display=TRUE

      DenemoObject *obj;
      if (Denemo.prefs.learning)
                    MouseGestureShow(_("Control-Shift-Drag."), _("This allows dragging objects in the display.\nAll sorts of directives such as staccato dots, ornaments, repeat marks etc can be dragged if the display is too cluttered.\nThe typeset score is unaffected.\nClick on a notehead to drag things attached to the notehead,\nor off the noteheads for things attached to the whole chord."),
                        MouseGesture);

    last_directive = get_next_directive_at_cursor ();
    if(last_directive)
        {
            score_status (Denemo.project, TRUE);
            return TRUE;
        }
    infodialog (_("Control-Shift-Drag is used to tidy up the Denemo display. Useful if Denemo has created a clutter with your input music.\nIf you have several things attached to one object you can move them in turn by dragging them in turn.\nNotes, Slurs and Ties are fixed but most other things can be moved to make the input music clear. Does not affect the typeset score!\nNB! if you have dragged something to one side of a note you have to control-shift-click on the note itself to drag it back - it is where the cursor is that counts."));
    return TRUE;
 }






  set_cursor_for (event->state | (left ? GDK_BUTTON1_MASK : GDK_BUTTON3_MASK));




  //displayhelper(Denemo.project);
  draw_score(NULL);//this is needed to refresh cached values such as the prevailing time signature, before the command is invoked

  perform_command (event->state | (left ? GDK_BUTTON1_MASK : GDK_BUTTON3_MASK), GESTURE_PRESS, left);

  return TRUE;
}