Example #1
0
void pge_init() {
  s_initd = false;

  data_init();

  const int buffer_size = 64;
  comm_init(buffer_size, buffer_size);

  s_digits[0] = digit_create(GPoint(-HOURS_OFFSET, 0), 0);
  s_digits[1] = digit_create(GPoint(-HOURS_OFFSET + (5 * SEGMENT_SIZE.w), 0), 0);
  s_digits[2] = digit_create(GPoint(MINS_OFFSET, 7 * SEGMENT_SIZE.h), 0);
  s_digits[3] = digit_create(GPoint(MINS_OFFSET + (5 * SEGMENT_SIZE.w), 7 * SEGMENT_SIZE.h), 0);

  pge_isometric_set_projection_offset(PROJECTION_OFFSET);
  pge_set_framerate(FRAME_RATE_HIGH);
  pge_begin(pge_logic, pge_render, NULL);

  tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);

  time_t temp = time(NULL);
  struct tm *t = localtime(&temp);
  tick_handler(t, MINUTE_UNIT);

  main_reload_config();

  // Fast forward - save power when lots of notifications
  while(digits_are_animating()) {
    pge_logic();
  }
  app_focus_service_subscribe(focus_handler);

  // If no animations
  if(!data_get_animations()) {
    pge_manual_advance();

    // Don't animate after this
    pge_pause();
  }
}
Example #2
0
void pge_init() {
  // Allocate
  for(int z = 0; z < GRID_DEPTH; z++) {
    for(int y = 0; y < GRID_HEIGHT; y++) {
      for(int x = 0; x < GRID_WIDTH; x++) {
        s_block_array[vec2i(Vec3(x, y, z))] = block_create(Vec3(x * BLOCK_SIZE, y * BLOCK_SIZE, z * BLOCK_SIZE), GSize(BLOCK_SIZE, BLOCK_SIZE), COLOR_INVISIBLE);
      }
    }
  }
  for(int i = 0; i < MAX_CLOUDS; i++) {
    s_cloud_array[i] = cloud_create(Vec3(0, 0, SKY_HEIGHT), GSize(BLOCK_SIZE, BLOCK_SIZE), Vec3(GRID_WIDTH * BLOCK_SIZE, GRID_HEIGHT * BLOCK_SIZE, SKY_HEIGHT));
  }

  // Set up world
  generate_world();

  // Set up engine
  pge_isometric_set_projection_offset(PBL_IF_ROUND_ELSE(GPoint(90, 110), GPoint(72, 80)));
  pge_isometric_set_enabled(true);
  pge_set_framerate(FRAME_RATE_IDLE);
  pge_begin(GColorBlack, logic, render, click);
  s_main_window = pge_get_window();

  s_status_layer = text_layer_create(grect_inset(
    layer_get_bounds((window_get_root_layer(s_main_window))),
    PBL_IF_ROUND_ELSE(GEdgeInsets(30, 0, 130, 0), GEdgeInsets(0, 0, 150, 0))));
  text_layer_set_background_color(s_status_layer, GColorBlack);
  text_layer_set_text_color(s_status_layer, GColorWhite);
  text_layer_set_text_alignment(s_status_layer, PBL_IF_ROUND_ELSE(GTextAlignmentCenter, GTextAlignmentLeft));
  layer_add_child(window_get_root_layer(s_main_window), text_layer_get_layer(s_status_layer));
  update_status_text();

#ifdef BENCHMARK
  APP_LOG(APP_LOG_LEVEL_INFO, "Heap free: %dB after creating %d blocks (Size: %dB)", (int)heap_bytes_free(), (GRID_WIDTH * GRID_HEIGHT * GRID_DEPTH), get_world_size());
#endif
}