예제 #1
0
void main()
{
	char radius[50];
	srand(time(NULL));
	allegro_init();
	install_keyboard();
	set_color_depth(32);
	set_gfx_mode( GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);

	line(screen, 320 , 0, 320, 480, makecol(255,255,0 ));
    line(screen, 0 , 240, 640, 240, makecol(255,255,0 ));
	circle (screen, 320,240,300, makecol(0,0,255));
	circle (screen, 320,240,200, makecol(0,0,255));
	circle (screen, 320,240,100, makecol(0,0,255));
	textout_ex(screen, font, "Probabilistic Machine by Tuyama",50,10, makecol(255,0,0), -1);

	while( !key[KEY_ESC]){

		moveCircle();
		raddius = sqrt((double)((x-320)*(x-320)+(y-240)*(y-240)));
		textout_ex(screen, font, "radius: ", 30, 30, makecol(255,0,0), -1);
		if (t%100==0)
		{
			rectfill(screen, 90, 25, 150, 40, makecol(0, 0, 0));
			textout_ex(screen, font, itoa(raddius, radius, 10), 100, 30, makecol(255,0,0), -1);
		}
		t+=1;

	}    
}
예제 #2
0
void moveShapes(Shape** shapes, int n, int distX, int distY) {
  for (int i = 0; i < n; ++i) {
    struct Shape* s = shapes[i];
    switch (s->type_) {
      case Shape::square:
        moveSquare((struct Square*)s, distX, distY);
        break;
      case Shape::circle:
        moveCircle((struct Circle*)s, distX, distY);
        break;
      case Shape::rhomb:
        moveRhomb((struct Rhomb*)s, distX, distY);
        break;
      default:
        assert(0);
        std::exit(0);
    }
  }
}