コード例 #1
0
ファイル: main.c プロジェクト: GeekJosh/Pebble-Gaptime
//updates time display
static void updateTime(TimeUnits unitsChanged) {
	//get time
	time_t temp = time(NULL);
	the_time = localtime(&temp);

	//hand to update
	int hand;
	
	//update SunTimes if enabled and day changes
	if((invertTime.type == SUNRISE || invertTime.type == SUNSET) && (unitsChanged & DAY_UNIT) != 0) {
		updateSunTimes();
	}
	
	//instruct pebble to redraw neccessary layers
	if((unitsChanged & HOUR_UNIT) != 0 || the_time->tm_min % 10 == 0) {
		hand = get_hand_order('H');
		if(hand > -1) {
			s_hand_angle[hand] = TRIG_MAX_ANGLE * (((the_time->tm_hour % 12) * 6) + (the_time->tm_min / 10)) / (12 * 6);
			draw_hand(hand);
		}
	}

	if((unitsChanged & MINUTE_UNIT) != 0) {
		hand = get_hand_order('M');
		if(hand > -1) {
			s_hand_angle[hand] = TRIG_MAX_ANGLE * the_time->tm_min / 60;
			draw_hand(hand);
		}

		//update text time layer
		static char buffer[] = "00:00";
		// Write the current hours and minutes into the buffer
		if(clock_is_24h_style() == true) {
    		// Use 24 hour format
    		strftime(buffer, sizeof(buffer), "%H:%M", the_time);
		} else {
			// Use 12 hour format
			strftime(buffer, sizeof(buffer), "%I:%M", the_time);
		}
		text_layer_set_text(s_text_time, buffer);
		
		//invert face if neccessary
		if(invertTime.type == TIME || invertTime.type == SUNRISE || invertTime.type == SUNSET) {
			s_inverted = ((the_time->tm_hour * 60) + the_time->tm_min >= (invertTime.onHour * 60) + invertTime.onMin && (the_time->tm_hour * 60) + the_time->tm_min < (invertTime.offHour *60) + invertTime.offMin);
			invert_face();
		} 
		
		//try to update SunTimes every 20 minutes if not updated in last 12 hours
		if((invertTime.type == SUNRISE || invertTime.type == SUNSET) && (invertTime.updateHour == 255 || (the_time->tm_min % 20 == 0 && ((the_time->tm_hour * 60) + the_time->tm_min) - ((invertTime.updateHour * 60) + invertTime.updateMin) >= 60))) {
			updateSunTimes();
		}
	}

	hand = get_hand_order('S');
	if(hand > -1) {
		s_hand_angle[hand] = TRIG_MAX_ANGLE * the_time->tm_sec / 60;
		draw_hand(hand);
	}
}
コード例 #2
0
ファイル: wright_chrono.c プロジェクト: Quikrobot/rosewright
void chrono_second_layer_update_callback(Layer *me, GContext *ctx) {
  //  app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "chrono_second_layer");

  if (config.second_hand || chrono_data.running || chrono_data.hold_ms != 0) {
    draw_hand(&chrono_second_cache, &chrono_second_hand_def, current_placement.chrono_second_hand_index, ctx);
  }
}
コード例 #3
0
ファイル: uno.c プロジェクト: tmacwill/uno
int main(int argc, char* argv[]) {
    // fire up gtk
    gtk_init(&argc, &argv);

    // create main window
    GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size(GTK_WINDOW(window), WINDOW_WIDTH, WINDOW_HEIGHT);
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
    gtk_window_set_title(GTK_WINDOW(window), "CS50 Uno");

    // container for cards
    container = gtk_fixed_new();
    gtk_container_add(GTK_CONTAINER(window), container);

    // when x is pressed, quite app
    g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);

    // deal a random hand and display it
    deal_random_hand(5);
    draw_hand();

    // enter main loop
    gtk_widget_show_all(window);
    gtk_main();

    return 0;
}
コード例 #4
0
void Clock::draw() const 
{ cwin << Circle(center, radius); 
  int i; 
  const double HOUR_TICK_LENGTH = 0.2; 
  const double MINUTE_TICK_LENGTH = 0.1; 
  const double HOUR_HAND_LENGTH = 0.6; 
  const double MINUTE_HAND_LENGTH = 0.75; 
  for (i = 0; i < 12; i++) 
  { draw_tick(i * 5, HOUR_TICK_LENGTH); 
    int j; 
    for (j = 1; j <= 4; j++) draw_tick(i*5 + j, MINUTE_TICK_LENGTH); 
  } 
  draw_hand(current_time.get_minutes(), MINUTE_HAND_LENGTH); 
  draw_hand((current_time.get_hours() + 
  current_time.get_minutes()/60.0)*5, HOUR_HAND_LENGTH); 
} 
コード例 #5
0
ファイル: wright.c プロジェクト: docsmooth/laughingman
void second_layer_update_callback(Layer *me, GContext *ctx) {
  //  app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "second_layer");

  if (config.second_hand) {
    draw_hand(&second_cache, &second_hand_def, current_placement.second_hand_index, ctx);
  }
}
コード例 #6
0
ファイル: uno.c プロジェクト: tmacwill/uno
/**
 * Play the given card
 *
 * @param card Card to play
 * @return False if card cannot be played, true otherwise
 *
 */
int play(struct card_t* card) {
    // if either value or color matches, then move is valid
    if (card->value == up_card.value || card->color == up_card.color) {
        // change the up card
        up_card.type = card->type;
        up_card.color = card->color;
        up_card.value = card->value;

        // clear game so we can remove the card that was played
        clear_container(container);
        remove_card(card);

        // draw the new game state
        draw_hand();

        return 1;
    }

    // illegal move
    return 0;
}
コード例 #7
0
static void
draw_time (cairo_t *cr, double width, double height, struct timeval *tv, int seconds)
{
    double  hour_angle, minute_angle, second_angle;
    struct tm	tm_ret;
    struct tm	*tm;
    tm = localtime_r (&tv->tv_sec, &tm_ret);
    
    second_angle = (tm->tm_sec + tv->tv_usec / 1000000.0) * 6.0;
    minute_angle = tm->tm_min * 6.0 + second_angle / 60.0;
    hour_angle = tm->tm_hour * 30.0 + minute_angle / 12.0;

    cairo_save (cr);
    {
	cairo_scale (cr, width, height);
	cairo_translate (cr, 0.5, 0.5);
	draw_hand (cr, hour_angle, HOUR_WIDTH, HOUR_LENGTH, 
		   HOUR_ALT, draw_hour);
	draw_hand (cr, minute_angle, MINUTE_WIDTH, MINUTE_LENGTH,
		   MINUTE_ALT, draw_minute);
	if (seconds)
	    draw_hand (cr, second_angle, SECOND_WIDTH, SECOND_LENGTH,
		       SECOND_ALT, draw_second);
	cairo_set_source_rgba (cr, 0, 0, 0, 0.3);
	cairo_fill (cr);
	
	cairo_set_source_rgba (cr, 0, 0, 0, 1);
	draw_hand (cr, hour_angle, HOUR_WIDTH, HOUR_LENGTH, 
		   0.0, draw_hour);
	cairo_fill (cr);
	draw_hand (cr, minute_angle, MINUTE_WIDTH, MINUTE_LENGTH,
		   0.0, draw_minute);
	cairo_fill (cr);
	if (seconds)
	    draw_hand (cr, second_angle, SECOND_WIDTH, SECOND_LENGTH,
		       0.0, draw_second);
	cairo_fill (cr);
    }
    cairo_restore (cr);
}
コード例 #8
0
/* Select from 3 available modes and process accordingly */
void mode_selection(XnPoint3D* handPointList, hand_h* rhand){

	//-------------------sculpting--------------------------
	if(is_mode(1)){
	
		checkRCursor(1, rhand);						//right
		//if(hasTwoHands()) checkLCursor(lhand);	//left
		

		//SELECTION
		if(is_state(1)){	
			float* cursor = getCursor();
			cursorX = cursor[0];
			cursorY = cursor[1];

			drawPickVMModel();
			processPick(cursorX, cursorY);
			set_state(2);	
		}
		//RENDER
		else {
			draw_hand(handPointList);	//draw every hands
			
			//show back buffer?
			if(!BACK_BUFF){
				drawVMModel();
			}
			else{ 
				drawPickVMModel();
			}
			set_state(1);
			glutSwapBuffers();
		}
	}
	
	//-------------------paint----------------------------
	else if(is_mode(2)) {
		checkRCursor(2, rhand); 

		//SELECTION
		if(is_state(1)){
			//update cursor for paint effect
			float* cursor = getCursor();
			cursorX = cursor[0];
			cursorY = cursor[1];

			drawPickVMModel();
			processPick(cursorX, cursorY);
			set_state(2);
		}
		//RENDER
		else {
			//////////////////////////////////////////////////** in gesture////////////////
			draw_hand(handPointList);

			
			if(!BACK_BUFF)
				drawVMModel();
			else drawPickVMModel();

			//back to select other mesh
			set_state(1);
			glutSwapBuffers();
		}
	}

	//------------------ Selection ------------------------
	else if(is_mode(3)) {
		checkRCursor(3, rhand);
		
		 if(is_state(1)){
			drawPickVMModel();

			set_state(2);
		}
		else {
			//////////////////////////////////////////////////** in gesture////////////////
			draw_hand(handPointList);
			if(!BACK_BUFF)
				drawVMModel();
			else drawPickVMModel();
			drawVMModel();
			glutSwapBuffers();
		}
		
	}

}
コード例 #9
0
ファイル: HUD.c プロジェクト: poulenque/St_V_2014
void sulfateuse_HUD(Game* game, int color,double time_offset){

	#ifdef VISEUR_ENABLED
	viseur(game);
	#endif

	double oscill_force=.5*sin(SDL_GetTicks()*.001)+.5*sin(SDL_GetTicks()*.00085);

	if(n==1){
		angle+=game->trigger_value*16.;
	}else{
		angle+=game->trigger_value*10.;
	}
	glGetError();
	for(int i=0;i<n;i++){
		double x=1-i*1./n;
		glPushMatrix();
				double real_rho=game->player->rho    +fake_rho;
				double real_theta=game->player->theta+fake_theta;
				glRotated(real_rho*(-4),1,0,0);
				glRotated(real_theta*.5, 0, 1, 0);
				double real_HUD_drho_compensation=HUD_drho_compensation+fake_HUD_drho_compensation;
				glTranslated(real_theta*(.05)+5,0,-real_HUD_drho_compensation*real_HUD_drho_compensation*0.0007-3);
				glRotated(80, 0, 1, 0);
				glRotated(70, 1, 0, 0);
				glRotated(real_theta*(1),0,0,1);
				glRotated(real_HUD_drho_compensation,0,1,0);

				// if(game->weapon==2){
					glTranslated(0,0,-1);
				// }else if (game->weapon==3){
					// glTranslated(0,1,-1);
				// }
				if(x*game->trigger_value){
					glTranslated(0,-x*game->fire_value,0);
					glRotated(-2*x*game->fire_value,0,0,1);
				}
				glLineWidth(3.0);

			// double c=.2;
			// switch(i){
			// 	case 0:
			// 		break;
			// 	case 1:
			// 		glTranslated(0,0,c);
			// 		break;
			// 	case 2:
			// 		glTranslated(0,c,0);
			// 		break;
			// 	case 3:
			// 		glTranslated(c,0,0);
			// 		break;
			// 	case 4:
			// 		glTranslated(0,c,c);
			// 		break;
			// 	case 5:
			// 		glTranslated(c,0,c);
			// 		break;
			// 	case 6:
			// 		glTranslated(c,c,0);
			// 		break;
			// 	case 7:
			// 		glTranslated(c,c,c);
			// 		break;
			// 	case 8:
			// 		// glTranslated();
			// 		break;
			// 	case 9:
			// 		// glTranslated();
			// 		break;
			// }
				draw_hand(  .3+.1*oscill_force,0,FALSE);
				// printf("%lf\n",i*game->trigger_value );
				draw_sulfateuse(0,angle-4*i*game->trigger_value,color);
				// draw_sulfateuse(0,angle-time_offset*game->trigger_value,color);
		// glTranslated(                               0, 1, -5+1*oscill_force);
		// glTranslated(-.3+.1*sin(SDL_GetTicks()*.0017), 0, 0);
		// draw_arrow(.2);
		glPopMatrix();

		if(i == 0)
			glAccum(GL_LOAD, 1.0 / n);
		else
			glAccum(GL_ACCUM, 1.0 / n);

	}
	glAccum(GL_RETURN, 1.0);
	if(glGetError()&GL_INVALID_OPERATION) {
		// gl accum not avaiable
		// printf("GLACCUM UNAVAIABLE\n");
		n=1;
	}

	// int n=20;
	// for(int i=0;i<n;i++){
	// 	draw();
	// 	if(i == 0)
	// 		glAccum(GL_LOAD, 1.0 / n);
	// 	else
	// 		glAccum(GL_ACCUM, 1.0 / n);
	// }
	// glAccum(GL_RETURN, 1.0);

}
コード例 #10
0
ファイル: HUD.c プロジェクト: poulenque/St_V_2014
void weapon_HUD_FIRE(Game* game, int mode,double time_offset){
	#ifdef VISEUR_ENABLED
	viseur(game);
	#endif


	glPushMatrix();
	BOW_GL_MATRIX();

	double time_pos=game->fire_value;
	time_pos=1-time_pos + time_offset;

	// time_pos=1;

	//FIRE
	if(time_pos<.1){
	// else {

		//time_pos entre 0 et 1
		time_pos=(time_pos)/.1;
		//time_pos exp entre 0 et 1
		time_pos=(exp( 1-time_pos )-1)/(exp(1)-1);

		// double time_pos=.5*((int)(time_/.15)%152)/152.;

		glTranslated(1*time_pos, 1.5-1+1*time_pos, 2.5);
		glRotated(-130*.5, 0, 1, 0);
		glRotated(-30*.5, 0, 0, 1);
		glRotated(10, 0, 1, 0);

		//ARROW
		glPushMatrix();
			glRotated(90, 0, 1, 0);
			glRotated(90, 1, 0, 0);
			glRotated(3, 1, 0, 0);
			glTranslated(0,.3,-8+5*time_pos);

			glTranslated(0,0,-1*(1-time_pos));

			draw_arrow_high_quality();
		glPopMatrix();

		//BOW + HAND
		draw_hand(.5*time_pos,2.+2-2*time_pos,TRUE);
		if(mode==2){
			draw_bow_v3(.2,.5*time_pos);
		}else if(mode==1){
			draw_bow_v2(.2,.5*time_pos);
		}else{
			draw_bow(.2,.5*time_pos);
		}



	}else if(time_pos<.3){
		//time_pos entre 0 et 1
		time_pos=(time_pos-.1)/.2;

		// double time_pos=.5*((int)(time_/.15)%152)/152.;

		glTranslated(0, 1.5-1, 2.5);
		glRotated(-130*.5, 0, 1, 0);
		glRotated(-30*.5, 0, 0, 1);
		glRotated(10, 0, 1, 0);

		glRotated(-40*time_pos, 1, 0, 0);
		// glRotated(-40*time_pos, 0, 0, 1);


		glTranslated(0, 0, -3*time_pos);

		draw_hand(0,2.+2,TRUE);
		if (mode==2){
			draw_bow_v3(.2,0);
		}else if(mode==1){
			draw_bow_v2(.2,0);
		}else{
			draw_bow(.2,0);
		}


	}else if(time_pos<.6){

		//time_pos entre 0 et 1
		time_pos=(time_pos-.3)/.3;
		// time_pos =1;

		// double time_pos=.5*((int)(time_/.15)%152)/152.;

				// glTranslated(-2*time_pos, 2*time_pos,3*time_pos);

		glTranslated(0, 1.5-1, 2.5);
		glRotated(-130*.5, 0, 1, 0);
		glRotated(-30*.5, 0, 0, 1);
		glRotated(10, 0, 1, 0);

		glRotated(-40, 1, 0, 0);

		glTranslated(0, 0, -3*time_pos);
		glRotated(20*time_pos, 0, 1, 0);

		// glTranslated(-2*time_pos, 0, 2*time_pos);

		// glRotated(-20*time_pos, 0, 1, 1);

		glRotated(20*time_pos, 1, 1, 0);

				// glRotated(30*time_pos, 0, 0, 1);

		glTranslated(0, 0, -3);

		draw_hand(0,2.+2-2*time_pos,TRUE);
		if (mode==2){
			draw_bow_v3(.2,0);
		}else if(mode==1){
			draw_bow_v2(.2,0);
		}else{
			draw_bow(.2,0);
		}

	}else{

		double oscill_force=.5*sin(SDL_GetTicks()*.001)+.5*sin(SDL_GetTicks()*.00085);
	
		//time_pos entre 0 et 1
		time_pos=(time_pos-.6)/.4;

		time_pos=1-time_pos;


		glTranslated(2*time_pos, 0, 0);
		glRotated(30*(time_pos), 0, 1, 0);
		glRotated(-0, 0, 0, 1);


		glPushMatrix();
			//ARROW
			glRotated(60, 0, 1, 0);
			glRotated(60, 1, 0, 0);
			// glTranslated(
			// 	-.3+.1*sin(SDL_GetTicks()*.0017*(1-time_pos)),
			// 	1-.7*time_pos,
			// 	-5+1*oscill_force*(1-time_pos)+2*time_pos
			// 	);
			glTranslated(
				-.3+.1*sin(SDL_GetTicks()*.0017),
				1,
				-5+1*oscill_force
				);

			glTranslated(5*time_pos,5*time_pos,0);

			glTranslated(-10*time_pos,0,0);
			// glRotated(-20+20*cos(SDL_GetTicks()*0.01), 1,-.3,0);
			glRotated(-40*time_pos, 1,0,0);
			glTranslated(10*time_pos,0,0);

			glTranslated(0,2*time_pos,2*time_pos);

			glTranslated(-3*time_pos,0,0);

			draw_arrow_high_quality();
				if(mode){
					glPushMatrix();
						glTranslated(-1.3,0,1.7);
						glRotated(10,0,1,0);
						draw_arrow_high_quality();
					glPopMatrix();
					glPushMatrix();
						glTranslated(1.3,0,1);
						glRotated(-10,0,1,0);
						draw_arrow_high_quality();
					glPopMatrix();

				}
		glPopMatrix();

		draw_hand(  .3+.1*oscill_force,0,FALSE);
		if(mode==2){
			draw_bow_v3(.2,.2+.1*oscill_force);
		}else if(mode==1){
			draw_bow_v2(.2,.2+.1*oscill_force);
		}else{
			draw_bow(.2,.2+.1*oscill_force);
		}


	}


	glPopMatrix();
}
コード例 #11
0
ファイル: HUD.c プロジェクト: poulenque/St_V_2014
void weapon_HUD_ARM(Game* game,int mode,double time_offset){
#define BOW_GL_MATRIX() \
	double real_rho=game->player->rho    +fake_rho;\
	double real_theta=game->player->theta+fake_theta;\
	glRotated(real_rho*(-4),1,0,0);\
	glRotated(real_theta*.5, 0.0, 1.0, 0.0);\
	double real_HUD_drho_compensation=HUD_drho_compensation+fake_HUD_drho_compensation;\
	glTranslated(0,0,-real_HUD_drho_compensation*real_HUD_drho_compensation*0.0007);\
	glTranslated(5,0,-3);\
	glTranslated(real_theta*(.05),0,0);\
	glRotated(80, 0, 1, 0);\
	glRotated(70, 1, 0, 0);\
	glRotated(real_theta*(1),0,0,1);\
	glRotated(real_HUD_drho_compensation,0,1,0);\
	glTranslated(0,0,-1);\
	glLineWidth(3.0)

	double time_pos=game->trigger_value+time_offset;


	#ifdef VISEUR_ENABLED
	viseur(game);
	#endif

	double oscill_force=.5*sin(SDL_GetTicks()*.001)+.5*sin(SDL_GetTicks()*.00085);

	glPushMatrix();
	BOW_GL_MATRIX();
			#define TEMP_MACRO() \
			glTranslated(0, 1.5*time_pos, 2*time_pos);\
			glRotated(-130*.5*time_pos, 0, 1, 0);\
			glRotated(-30*.5*time_pos, 0, 0, 1);

			glPushMatrix();
				TEMP_MACRO();

				//ARROW
				glRotated(60+30*time_pos, 0, 1, 0);
				glRotated(60+30*time_pos, 1, 0, 0);
				// glTranslated(
				// 	-.3+.1*sin(SDL_GetTicks()*.0017*(1-time_pos)),
				// 	1-.7*time_pos,
				// 	-5+1*oscill_force*(1-time_pos)+2*time_pos
				// 	);
				glTranslated(
					-.3+.1*sin(SDL_GetTicks()*.0017)*(1-time_pos)-.7*time_pos,
					1-.8*time_pos,
					-5+1*oscill_force*(1-time_pos)+2*time_pos
					);

				glScaled(1,1,1+.2*time_pos);
				draw_arrow_high_quality();
				if(mode){
					glPushMatrix();
						glTranslated(-1.7,0,1.5);
						glRotated(10,0,1,0);
						draw_arrow_high_quality();
					glPopMatrix();
					glPushMatrix();
						glTranslated(1.7,0,0.75);
						glRotated(-10,0,1,0);
						draw_arrow_high_quality();
					glPopMatrix();
					// glPushMatrix();
					// 	glTranslated(-1.3,0,1.7);
					// 	glRotated(10,0,1,0);
					// 	draw_arrow_high_quality();
					// glPopMatrix();
					// glPushMatrix();
					// 	glTranslated(1.3,0,1);
					// 	glRotated(-10,0,1,0);
					// 	draw_arrow_high_quality();
					// glPopMatrix();
				}if(mode==2){
					glPushMatrix();
						glTranslated(-3.2,0,3);
						glRotated(20,0,1,0);
						draw_arrow_high_quality();
					glPopMatrix();
					glPushMatrix();
						glTranslated(3.2,0,1.5);
						glRotated(-20,0,1,0);
						draw_arrow_high_quality();
					glPopMatrix();
				}
				glClear(GL_DEPTH_BUFFER_BIT);

			glPopMatrix();

			TEMP_MACRO();
			if(time_pos){//stable hands
				draw_hand(.3*time_pos,2*time_pos,TRUE);
				if(mode==2){
					draw_bow_v3(.2,.2+.6*time_pos);
				}else if(mode==1){
					draw_bow_v2(.2,.2+.6*time_pos);
				}else{
					draw_bow(.2,.2+.6*time_pos);
				}
			}else{//shaking hands
				draw_hand(  .3+.1*oscill_force,0,FALSE);
				if(mode==2){
					draw_bow_v3(.2,.2+.1*oscill_force);
				}else if(mode==1){
					draw_bow_v2(.2,.2+.1*oscill_force);
				}else{
					draw_bow(.2,.2+.1*oscill_force);
				}
					
					
			}

			#undef TEMP_MACRO


	// glTranslated(                               0, 1, -5+1*oscill_force);
	// glTranslated(-.3+.1*sin(SDL_GetTicks()*.0017), 0, 0);

	// draw_arrow(.2);
	glPopMatrix();
}
コード例 #12
0
ファイル: wright.c プロジェクト: docsmooth/laughingman
void minute_layer_update_callback(Layer *me, GContext *ctx) {
  //  app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "minute_layer");

  draw_hand(&minute_cache, &minute_hand_def, current_placement.minute_hand_index, ctx);
}