示例#1
0
文件: client.c 项目: adc/TEXTserver
void move_right(struct plyr *p) {
  p->x++;
  if(p->x >= SZ_X) {
    p->x = 0;
    update_loc(p, p->worldx+1, p->worldy);
  } 
}
示例#2
0
文件: client.c 项目: adc/TEXTserver
void move_down(struct plyr *p) {
  p->y++;
  if(p->y >= SZ_Y){
    p->y = 0;
    update_loc(p, p->worldx, p->worldy+1);
  }
}
示例#3
0
文件: client.c 项目: adc/TEXTserver
void move_left(struct plyr *p) {
  p->x--;
  if(p->x<0){
     p->x = SZ_X-1;
     update_loc(p, p->worldx-1, p->worldy);
  }
}
示例#4
0
文件: client.c 项目: adc/TEXTserver
void move_up(struct plyr *p) {
  p->y--;
  if(p->y < 0){
    p->y = SZ_Y-1;
    update_loc(p, p->worldx, p->worldy-1);
  }
}
示例#5
0
//Func: in_thread()
//This function is used in the call for pthread_create()
//it calls other function and set up a mission for each thread
void* in_thread(void *in_targv){
	struct timeval t_start;
	struct timeval t_end;
	thread_argv *ad_targv = in_targv;
	thread_argv targv = *ad_targv;
	gettimeofday(&t_start,NULL);
	update_loc(targv.num_astr, ad_targv->astr, *(targv.t_info));
	calc_f(targv.num_astr, ad_targv->astr, *(targv.t_info));
	total_f(targv.num_astr, ad_targv->astr, *(targv.t_info));
	calc_acc(targv.num_astr, ad_targv->astr, *(targv.t_info));
	calc_velo(targv.num_astr, ad_targv->astr, *(targv.t_info), targv.t);
	calc_s(targv.num_astr, ad_targv->astr, *(targv.t_info), targv.t);
	// mutex_lock pls - I like to live dangerously
	gettimeofday(&t_end,NULL);
	ad_targv->proc_t = t_end.tv_usec - t_start.tv_usec;
	pthread_barrier_wait(&barrier);
	return NULL;
}