예제 #1
0
파일: paddle.cpp 프로젝트: gmwilli5/pong
 void paddle::move()
 {
     /*if(dirc!=up&&dirc!=down){
         return;
     }
     //else{
         if(dirc==up){
             move_down();
             return;
         }
         if(dirc==down){
             move_up();
             return;
         }
     //}*/
     //std::cout<<dirc<<"\n";
     //move_down();
     if(*dirc==up){
         move_up();
     }
     if(*dirc==down){
         move_down();
     }
     switch(*dirc){
         std::cout<<50<<"\n";
         case up:
             move_up();
             break;
         case down:
             move_down();
             break;
         default:
             break;
     }
 }
예제 #2
0
void* fctThreadForme(void* param)
{
   //printf("--Thread forme\n");

   S_FORME *forme;
   forme = param;

   pthread_mutex_lock(&mutexAttShift);
   AttShift = 1;
   pthread_mutex_unlock(&mutexAttShift);
   while(haut == 0)// && rotation == 0 && droite == 0 && gauche == 0)
      {
         pthread_cond_wait(&condEvent, &mutexEvent);
         pthread_mutex_lock(&mutexAttShift);
         while(AttShift == 0)
            pthread_cond_wait(&condAttShift, &mutexAttShift);
         pthread_mutex_unlock(&mutexAttShift);

         if(haut == 19)
            {
               while(move_up(forme) == 0);
               haut--;
            }

         else if(haut > 0)
            {
               if(move_up(forme) == 0)
                  haut--;
               /*int i, j;
               for (i = 0; i < NB_LIGNE; i++)
                  {
                     for (j = 0; j < NB_COLONNE; j++)
                        printf("%4d ", tab[i][j]);
                     printf("\n");
                  }
                  printf("\n");printf("\n");printf("\n");*/
            }
                    
         if(gauche > 0)
            {
               move_left(forme);
               gauche--;
            }
       
         if(droite > 0)
            {
               move_right(forme);
               droite--;
            }
         
         if(rotation > 0)
            {
               move_rotation(forme);
               rotation--;
            }
      }
   pthread_exit(NULL);
   
}
예제 #3
0
void		f_move_up(t_env *e)
{
	e->mod_tab[e->cursor] /= 2;
	move_up(e);
	while (e->mod_tab[e->cursor] == 0)
		move_up(e);
	e->mod_tab[e->cursor] *= 2;
}
예제 #4
0
void
on_joystick_event (gint eventtype, gint button)
{
    /*the focus is not set: another windows has been opened
     or this is an init event */
    if (!joystick_focus || (eventtype & JS_EVENT_INIT))
        return;

    GMAMEUI_DEBUG ("joy: event=%i, button=%i", eventtype, button);

    if ((eventtype & JS_EVENT_BUTTON) && (button < joydata->num_buttons)) {
        GMAMEUI_DEBUG ("Joystick button %i %s", button, (joydata->buttons[button])?"pressed":"released");
        /* Button released*/
        if (joydata->buttons[button] == 0)
            switch (button) {
            case 0:
// FIXME TODO				play_game (gui_prefs.current_game);
                break;
            case 1:
                toggle_expand ();
                break;
            }
    } else if ( (eventtype & JS_EVENT_AXIS) && (button < joydata->num_axis)) {
        if (repeat_source_id)
            g_source_remove (repeat_source_id);

        /* LEFT and RIGHT directions
        * (even Axis number)
        */
        if (! (button & 1)) {
            if (joydata->axis[button] > (AXIS_MAX / 2)) {
                GMAMEUI_DEBUG ("Joystick axis %i pushed right", button);
                move_down (row_number ());
                repeat_source_id = g_timeout_add (10 * JOY_TIMEOUT,
                                                  (GSourceFunc) joy_right_repetition, NULL);
            } else if (joydata->axis[button] < (AXIS_MIN / 2)) {
                GMAMEUI_DEBUG ("Joystick axis %i pushed left", button);
                move_up (row_number ());
                repeat_source_id = g_timeout_add (10 * JOY_TIMEOUT,
                                                  (GSourceFunc) joy_left_repetition, NULL);
            }
        } else {
            /* UP and DOWN directions */
            if (joydata->axis[button] > (AXIS_MAX / 2)) {
                GMAMEUI_DEBUG ("Joystick axis %i pushed down", button);
                move_down (1);
                repeat_source_id = g_timeout_add (10 * JOY_TIMEOUT,
                                                  (GSourceFunc) joy_down_repetition, NULL);

            } else if (joydata->axis[button] < (AXIS_MIN / 2)) {
                GMAMEUI_DEBUG ("Joystick axis %i pushed up", button);
                move_up (1);
                repeat_source_id = g_timeout_add (10 * JOY_TIMEOUT,
                                                  (GSourceFunc) joy_up_repetition, NULL);
            }
        }
    }
}
예제 #5
0
파일: elevator.c 프로젝트: sigmax6/sigmav
void show_message(void)
{	
	int loop = 5;
	int new_get = 0;
	int des_get = 0;
	int next_floor = 0;
	
	printf("#%d : stop\n", floor);

	while(1)
	{
		if(state == UP)
		{
			next_floor = get_up_next_floor();
			if(next_floor == floor)
			{ open_door(UP, next_floor); }
			else if(next_floor > floor)
			{ move_up(); }
			else if(next_floor < 1)
			{ move_stop(); }
		}
		else if(state == DOWN)
		{
			next_floor = get_down_next_floor();
			if(next_floor == floor)
			{ open_door(DOWN, next_floor); }
			else if(next_floor < floor)
			{ move_down(); }
			else if(next_floor > NUM)
			{ move_stop(); }
		}
		else if(state == STOP)
		{
			if(open_flag)
			{
				open_door(NONE, 0);
				open_flag = 0;
			}
			else
			{
				next_floor = get_up_next_floor();
				if(next_floor == floor)
				{ open_door(UP, next_floor); }
				else if(next_floor > floor)
				{ move_up(); }
				else if(next_floor < 1)
				{
					next_floor = get_down_next_floor();
					if(next_floor == floor)
					{ open_door(DOWN, next_floor); }
					else if(next_floor < floor)
					{ move_down(); }				
				}
			}
		}
	}	
}
예제 #6
0
static void scroll_page_up(){
	  menu_list_data *data;

      data = (menu_list_data *)   ssd_dialog_get_current_data();
      if( (data->CurrentIndex - data->num_rows) < 0)
      	return;
	  move_up();
	  data->CurrentIndex -= data->num_rows -2;
	  move_up();
}
예제 #7
0
int	act_up(char *param, t_client *client, t_info *info)
{
  (void)param;
  move_up(client, client->direction, info);
  SEND(client->buf_write, OK);
  return (0);
}
예제 #8
0
static void
key_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
    Evas_Event_Key_Down *ev;
    app_t *app;
    const char *k;

    ev = (Evas_Event_Key_Down *)event_info;
    app = (app_t *)data;

    k = ev->keyname;

    if (eq(k, "Down"))
        move_down(app);
    else if (eq(k, "Up"))
        move_up(app);
    else if (eq(k, "Escape"))
        ecore_main_loop_quit();
    else if (eq(k, "f") || eq(k, "F6")) {
        if (ecore_evas_fullscreen_get(app->ee)) {
            ecore_evas_fullscreen_set(app->ee, 0);
            ecore_evas_cursor_set(app->ee, NULL, 0, 0, 0);
        } else {
            ecore_evas_fullscreen_set(app->ee, 1);
            ecore_evas_cursor_set(app->ee, " ", 999, 0, 0);
        }
    }
}
예제 #9
0
파일: main.c 프로젝트: acazuc/42_ft_select
static void		read_stdin(t_env *env)
{
	char	buffer[20];
	int		rd;

	ft_memset(buffer, 0, 20);
	rd = read(0, buffer, 20);
	if (rd == 1 && buffer[0] == 27)
		error_quit(NULL);
	else if (rd == 1 && buffer[0] == 10)
		return_selected(env);
	else if ((rd == 1 && buffer[0] == 127)
			|| !ft_strcmp(buffer, env->key_code_delete))
		delete_current(env);
	else if (rd == 1 && buffer[0] == ' ')
	{
		if (env->curr)
			env->curr->item->selected = !env->curr->item->selected;
	}
	else if (!ft_strcmp(buffer, env->key_code_down))
		move_down(env);
	else if (!ft_strcmp(buffer, env->key_code_up))
		move_up(env);
	else if (!ft_strcmp(buffer, env->key_code_left))
		move_left(env);
	else if (!ft_strcmp(buffer, env->key_code_right))
		move_right(env);
}
예제 #10
0
파일: my2048.c 프로젝트: bnlb/C_Playground
void perform_user_action(int board[SIZE][SIZE]) {
  char key_pressed = getchar();

  switch((int)key_pressed) {
    case 104:  // 'h'
      move_left(board);
      break;
    case 108:  // 'l'
      move_right(board);
      break;
    case 107:  // 'k'
      move_up(board);
      break;
    case 106:  // 'j'
      move_down(board);
      break;
    case 114: // 'r'
      init_board(board);
      break;
    case 113: // 'q'
      exit(0);
    default:
      perform_user_action(board);
  }
}
예제 #11
0
파일: fillit6.c 프로젝트: andrpop/fillit
unsigned int	read_strings(int fd, t_input *i)
{
	unsigned int	ok;
	int				c;

	c = 0;
	set_nulls(i);
	ok = get_next_line(fd, &(i->a));
	ok = get_next_line(fd, &(i->b));
	ok = get_next_line(fd, &(i->c));
	ok = get_next_line(fd, &(i->d));
	if (!i->a || !i->b || !i->c || !i->d)
		return (-1);
	if (ft_strlen(i->a) != 4 || ft_strlen(i->b) != 4 ||
			ft_strlen(i->c) != 4 || ft_strlen(i->d) != 4)
		return (-1);
	move_up(i);
	while (i->a[0] == '.' && i->b[0] == '.' && i->c[0] == '.' &&
			i->d[0] == '.' && c < 4)
	{
		move(i);
		c++;
	}
	return (check_valid_piece(ok, i));
}
예제 #12
0
static int
do_move_up(void *data)
{
    app_t *app = data;

    move_up(app);
    return 1;
}
예제 #13
0
int	act_up(t_info *info, t_client *client, char *param)
{
  (void)param;
  if (!client)
    return (-1);
  move_up(client, client->direction, info);
  return (0);
}
예제 #14
0
파일: heap.c 프로젝트: juanibraun/codeJIB
void move_up(HEAP* h, int i){
    int p = parent(i);
    
    if((p>=0) && (h->data[p]->value > h->data[i]->value)){
       swap(h, i, p);
       move_up(h,p);
    }       
}
예제 #15
0
파일: 2048_game.c 프로젝트: 2ion/2048_game
int main()
{
	init_curses();

	const char *exit_msg = "";
	srandom(time(NULL));

	struct game_t game = {0};
	int last_turn = game.turns;

	get_highscore_filepath(&game);
	load_highscore(&game);

	place_tile(&game);
	place_tile(&game);

	while (1) {
		print_game(&game);

		if (lose_game(game)) {
			exit_msg = "lost";
			goto lose;
		}

		last_turn = game.turns;

		switch (getch()) {
    case 'h': case KEY_LEFT:  case 'a': move_left(&game); break;
    case 'j': case KEY_DOWN:  case 's': move_down(&game); break;
    case 'k': case KEY_UP:    case 'w': move_up(&game);   break;
    case 'l': case KEY_RIGHT: case 'd': move_right(&game);break;
		case 'q':
			exit_msg = "quit";
			goto end;
		}

		if (last_turn != game.turns)
			place_tile(&game);
	}

lose:
	move(7, 0);
	printw("You lose! Press q to quit.");
	while (getch() != 'q');
end:
	endwin();
	if(game.score > game.highscore)
	{
		game.highscore = game.score;
		save_highscore(&game);
	}
	printf("You %s after scoring %d points in %d turns, "
		"with largest tile %d. The local highscore is %d points.\n",
		exit_msg, game.score, game.turns,
		1 << max_tile((tile_t *)game.board), game.highscore);
	free(game.highscorefile);
	return 0;
}
예제 #16
0
int LOOK() {

    char FileName[40];
    sprintf(FileName, "%d LOOK.txt", App.direction);
    FILE *fp = fopen(FileName, "w");

    fprintf(fp, "Start POS: %d\n", App.CurrentApp);
    fprintf(fp, "\nCurrent rndLoop  sum\n\n");

    while (Power) {
	while (App.QueueSize) {

	    switch (App.direction) {
		case UP:
		    while (App.QueueSize) {

			pthread_mutex_lock(&crit_m);

			if (move_up() == FALSE) {
			    App.direction = DOWN;
			    fprintf(fp, "direction changed \n");
			    break;
			    // Κάνουμε Break από το for γιατί θέλουμε να αλλάξουμε κατεύθυνση.
			}
			fprintf(fp, "%d     %d     %d\n", App.CurrentApp, App.CurrentRND, App.sum);
			pthread_mutex_unlock(&crit_m);
			if (Power) {
			    sleep(1);
			}
		    }
		    pthread_mutex_unlock(&crit_m);
		    break; //case break

		default:
		    while (App.QueueSize) {

			pthread_mutex_lock(&crit_m);
			if (move_down() == FALSE) {
			    App.direction = UP;
			    fprintf(fp, "direction changed \n");
			    break;
			    // Κάνουμε Break από το for γιατί θέλουμε να αλλάξουμε κατεύθυνση.
			}
			fprintf(fp, "%d     %d     %d\n", App.CurrentApp, App.CurrentRND, App.sum);
			pthread_mutex_unlock(&crit_m);
			if (Power) {
			    sleep(1);
			}
		    }
		    pthread_mutex_unlock(&crit_m);
		    break; //case break
	    }
	}
    }

    fclose(fp);
    return TRUE;
}
예제 #17
0
void thread_function(){
    if(ros::ok()){
        open_fingers();
        move_to_grasp_point(-0.24, 0.366, -0.003, 0.064, -0.658, -0.035, 0.75);
        close_fingers();
        move_up(0.4);
        end_program = true;
    }
}
예제 #18
0
void SantaMap::move(const char movement) {
    switch(movement) {
        case '<': move_left(); break;
        case '^': move_up(); break;
        case '>': move_right(); break;
        case 'v': move_down(); break;
    }
    increment_counter_if_new_visited_house();
}
예제 #19
0
파일: 2048.c 프로젝트: hos3in/2048
int main(int argc, const char *argv[])
{
	char game[3][3]={0};
	char key;
	show_game(game,3);
	printf("\n");
	while(scanf(" %c",&key)){
		switch(key){
			case 'w':
				{
			//	printf("%s\033[k");
				system("clear");
				sort_up(game,3);
				move_up(game,3);
				randfunc(game,3);
			        show_game(game,3);
				}
				break;
			case 'a':
				{
		//		printf("%s\033[1J");
				system("clear");  
				sort_left(game,3);
				move_left(game,3);
			        randfunc(game,3);
				show_game(game,3);

				}
				break;

			case 'd':
				{
			//	printf("%s\033[1k");
					system("clear");
					sort_right(game,3);
					move_right(game,3);
					randfunc(game,3);
					show_game(game,3);
				}
				break;
			
			case 's':
				{
		//		printf("%s\033[1J");
				system("clear");  
				sort_down(game,3);
				move_down(game,3);
				randfunc(game,3);
			        show_game(game,3);
				}
				break;

		}
		
	}
	return 0;
}
예제 #20
0
int lose_game(struct game_t test_game)
{
	int start_turns = test_game.turns;
	move_left(&test_game);
	move_up(&test_game);
	move_down(&test_game);
	move_right(&test_game);
	return test_game.turns == start_turns;
}
예제 #21
0
int		check_scale_boss(t_struct *st)
{
  if (st->boss.y - st->heros.y < 0)
    return (move_down(st));
  else
    if (st->boss.y - st->heros.y > 0)
      return (move_up(st));
    else
      return (0);
}
예제 #22
0
static void
mouse_down_arrow_up(void *d, Evas *e, Evas_Object *obj, void *event_info)
{
    app_t *app = d;

    if (app->mouse_down_anim)
        ecore_animator_del(app->mouse_down_anim);

    app->mouse_down_anim = ecore_animator_add(do_move_up, app);
    move_up(app);
}
예제 #23
0
파일: heap.c 프로젝트: juanibraun/codeJIB
extern int heap_addItem(HEAP* h, ITEM* p){
    if(h->index +1 >= h->size){
        return 1;
    }else{
        h->index+=1;
        h->data[h->index] = p;
        p->label = h->index;
        move_up(h, h->index);
        return 0;
    }
}
예제 #24
0
int C_SCAN() {

    char FileName[40];
    sprintf(FileName, "%d C-SCAN.txt", App.direction);
    FILE *fp = fopen(FileName, "w");

    fprintf(fp, "Start POS: %d\n", App.CurrentApp);
    fprintf(fp, "\nCurrent rndLoop  sum\n\n");

    switch (App.direction) {
	case UP:
	    while (Power) {
		while (App.QueueSize) {

		    pthread_mutex_lock(&crit_m);

		    if (move_up() == FALSE) {
			App.sum += abs(App.CurrentApp - MaxBlockRange);
			App.CurrentApp = 0;
			fprintf(fp, "Cycle\n");
		    }
		    fprintf(fp, "%d     %d     %d\n", App.CurrentApp, App.CurrentRND, App.sum);
		    pthread_mutex_unlock(&crit_m);
		    if (Power) {
			sleep(1);
		    }
		}
	    }
	    break; //case break

	default:
	    while (Power) {
		while (App.QueueSize) {

		    pthread_mutex_lock(&crit_m);

		    if (move_down() == FALSE) {
			App.sum += abs(App.CurrentApp + 1);
			App.CurrentApp = MaxBlockRange - 1;
			fprintf(fp, "Cycle\n");
		    }
		    fprintf(fp, "%d     %d     %d\n", App.CurrentApp, App.CurrentRND, App.sum);
		    pthread_mutex_unlock(&crit_m);
		    if (Power) {
			sleep(1);
		    }
		}
	    }
	    break; //case break
    }
    fclose(fp);
    return TRUE;
}
예제 #25
0
파일: move.c 프로젝트: tlepeche/Projets
void		check_move(char *buf, int *y, int *x, t_win *win)
{
	if (buf[0] == 27)
	{
		move_up(buf[2], y, x, win);
		move_down(buf[2], y, x, win);
		move_left(buf[2], y, x, win);
		move_right(buf[2], y, x, win);
		if (!buf[1] && !buf[2])
			leave_term();
	}
}
예제 #26
0
// move()
// ... 기존의 머리는 몸통으로 바꾸어 출력하고
// ... 진행방향에 따라 알맞는 move함수를 호출한다.
//
void Snake::move()
{
    putchar_at_xy(head().X, head().Y, 'o');

    switch (direction_)
    {
    case UP:    move_up();    break;
    case DOWN:  move_down();  break;
    case LEFT:  move_left();  break;
    case RIGHT: move_right(); break;
    }
}
예제 #27
0
int key_event_update()
{
	int ret;
	char buf[100];
    while(1){ //Auto Driving Loop
        switch(c){
            case 65://up
                sprintf(buf, "UP    ");
                gotoxy(22, 43, buf, strlen(buf));
                ret = move_up();
                break;
            case 66://down
                sprintf(buf, "DOWN  ");
                gotoxy(22, 43, buf, strlen(buf));
                ret = move_down();
                break;
            case 67://right
                sprintf(buf, "RIGHT ");
                gotoxy(22, 43, buf, strlen(buf));
                ret = move_right();
                break;
            case 68://left
                sprintf(buf, "LEFT ");
                gotoxy(22, 43, buf, strlen(buf));
                ret = move_left();
                break;
            default:
                ret = 1;
                break;
        }
        gotoxy_none(24,5);
        if(ret == 1){
            //Artificial Intillegence Contorlling Object
            if(direction_guider() == -1){
            	blink_grid_hit();
                return -1; // Computer Can't Proceed Further, Grid Lock
            }
            c = new_direction;
        }else if(ret == 0){ // AI Will Not allow us to hit any frid unless, Object stands on the GRID
            //Human Intillegence Contorlling Object
            c = fgetc(stdin); //Key Board Input
            fflush(stdin);
            if(c =='x'){
                return -1;
            }
        }else{
            // Invalid Input    
        }
        continue;
    }

}
예제 #28
0
static BOOL OnKeyPressed (SsdWidget widget, const char* utf8char, uint32_t flags){
   BOOL        key_handled = TRUE;

   if( KEY_IS_ENTER)
   {
      widget->callback(widget, SSD_BUTTON_SHORT_CLICK);
      return TRUE;
   }

    if( KEYBOARD_VIRTUAL_KEY & flags)
   {
      switch( *utf8char) {

         case VK_Arrow_up:
               move_up();
            break;

         case VK_Arrow_down:
            move_down();
            break;

         default:
            key_handled = FALSE;
      }

   }
   else
   {
      assert(utf8char);
      assert(*utf8char);

      // Other special keys:
      if( KEYBOARD_ASCII & flags)
      {
         switch(*utf8char)
         {
            case TAB_KEY:
                move_down();
               break;

            default:
               key_handled = FALSE;
         }
      }
   }

   if( key_handled)
      roadmap_screen_redraw ();

   return key_handled;
}
예제 #29
0
파일: pacman.cpp 프로젝트: kalgecin/pacman
void pacman::handle_events(SDL_Event &event){
    if(event.type == SDL_KEYDOWN){
        SDL_PumpEvents();
        Uint8 *keystates = SDL_GetKeyState( NULL );
        if(keystates[SDLK_UP])
            move_up(40);
        if(keystates[SDLK_DOWN])
            move_down(40);
        if(keystates[SDLK_RIGHT])
            move_right(40);
        if(keystates[SDLK_LEFT])
            move_left(40);
    }
}
예제 #30
0
int main()
{
	init_curses();

	const char *exit_msg = "";
	srand(time(NULL));

	struct game_t game = {0};
	int last_turn = game.turns;

	place_tile(&game);
	place_tile(&game);

	while (1) {
		print_game(&game);

		if (lose_game(game)) {
			exit_msg = "lost";
			goto lose;
		}

		last_turn = game.turns;

		switch (getch()) {
		case 'h': case KEY_LEFT: move_left(&game); break;
		case 'j': case KEY_DOWN: move_down(&game); break;
		case 'k': case KEY_UP: move_up(&game); break;
		case 'l': case KEY_RIGHT: move_right(&game); break;
		case 'q':
			exit_msg = "quit";
			goto end;
		}

		if (last_turn != game.turns)
			place_tile(&game);
	}

lose:
	move(7, 0);
	printw("You lose! Press q to quit.");
	while (getch() != 'q');
end:
	endwin();
	printf("You %s after scoring %d points in %d turns, "
		"with largest tile %d\n",
		exit_msg, game.score, game.turns,
		1 << max_tile((tile_t *)game.board));
	return 0;
}