Ejemplo n.º 1
0
int main(int argc, char **argv)
{
	double start = when(), finish = 0.0;
	int size = 768, i;
	int gt_count = 0;

	/* Initialize the hotplate with specific pixel temperatures */
	Hotplate* hp = hp_initialize(size, size);
	hp_fill(hp, 50.0);
	hp_hline(hp, 0,      0, size-1,   0.0);
	hp_hline(hp, size-1, 0, size-1, 100.0);
	hp_vline(hp, 0,      0, size-1,   0.0);
	hp_vline(hp, size-1, 0, size-1,   0.0);
	hp_etch_hotspots(hp);
	
	hp_copy_to_source(hp);
	
	for(i = 0; i < 500; i++) // should be 359
	{
		hp_calculate_heat_transfer(hp);
		hp_etch_hotspots(hp);
		if (hp_is_steady_state(hp)) break;
		hp_swap(hp);
		// printf("%d ", i); fflush(stdout);
	}
	
	// hp_dump(hp);
	
	finish = when();
	gt_count = hp_cells_greater_than(hp, 50.0f);
	hp_destroy(hp);
	printf("Completed %d iterations in %f seconds.\n", i, finish - start);
	printf("%d cells had a value greater than 50.0.\n", gt_count);
}
Ejemplo n.º 2
0
void hp_step(){
  
  hword color = COLOR_WHITE;
  
  switch (game_get_state()) {
  case START:
    hp_initialize();
    stock_initialize();
    break;
    
  case RUNNING:
    draw_box(&hpbar, hpbar.x, hpbar.y, COLOR_RED);
    if(hp == 0){
      stock_lose();
      if(stock_count == 0){
	game_set_state(DEAD);
	break;
      }
      game_set_state(MISS);
    }
    break;
    
  case MISS:    
    if(stock_count == 0)
      game_set_state(DEAD);
    hp = 50;
    hpbar.width = hp;   
    break;
    
  case DEAD:
    break;
    
  case RESTART:
    hp_initialize();
    stock_initialize();
    break;
    
  case CLEAR:
    break;
    
  }
  
}