Example #1
0
void game_render(SDL_Surface *buffer, camera *camera, PLAYERS *players, float interpolation) {
  int w, h;

  SDL_Rect terrain_rect = {gsl_vector_get(camera->vector, 0), gsl_vector_get(camera->vector, 1), WIDTH * ZOOM_LEVEL, HEIGHT * ZOOM_LEVEL}; 
  SDL_BlitSurface(background, &terrain_rect, buffer, NULL);

  player *pl;
  division *div;
  unit *un;

  for(int i = 0; i < players->num; i++) {
    pl = players->players[i];
    for(int j = 0; j < pl->num_divisions; j++) {
      div = pl->divisions[j];
      for(int k = 0; k < div->size; k++) {
        un = div->units[k];
        display_unit(buffer, camera, un, pl->color, interpolation);
        /* displays the closest node
        ai_node *closest = find_closest_node(un->vector);
        if(closest == NULL) {
          printf("couldn't find a node for (%f, %f)\n",
              gsl_vector_get(un->vector, 0),
              gsl_vector_get(un->vector, 1));
        } else {
          //printf("closest to (%f, %f) -> (%d, %d)\n", 
          //  gsl_vector_get(un->vector, 0),
          //  gsl_vector_get(un->vector, 1),
          //  closest->x, closest->y);
          gsl_vector *v = calculate_display_position(closest->x, closest->y, camera);
          filledCircleRGBA(buffer, gsl_vector_get(v, 0), gsl_vector_get(v, 1), 3, 0, 0xff, 0, 0xff);
          gsl_vector_free(v);
        }*/
      }
    }
  }

  // display the title in the upper left 
  SDL_BlitSurface(title, NULL, buffer, NULL);

  // display the zoom level in the bottom left
  char zoom[7];
  snprintf(zoom, 7, "Zoom %i", ZOOM_LEVEL);
  TTF_SizeUTF8(font, zoom, &w, &h);
  SDL_Surface *zoom_surf = draw_text(zoom);
  SDL_Rect zo = { 0, HEIGHT - h, w, h };
  SDL_BlitSurface(zoom_surf, NULL, buffer, &zo);
  SDL_FreeSurface(zoom_surf);

  if(paused) {
    paused_state.render(buffer, camera, players, interpolation);
  } else {
    update_camera_position(camera);
  }

}
Example #2
0
void print_card_info(comedi_t *card)
{

  //We get the number of ranges for this card
  int n_ranges;
  int chan=1;
  n_ranges=comedi_get_n_ranges( card, SUBDEV, chan);
  printf("This card have %d ranges\n",n_ranges);
  int i;
  
  //We display information about these ranges
  comedi_range *act_range;
  for(i=0;i<n_ranges;i++)
    {
      act_range=comedi_get_range( card, SUBDEV, chan,i);
      printf("range %d\t min %f\t max %f\t unit: %s\n",i,act_range->min,act_range->max,display_unit(act_range->unit));
    }

  //We get the maxdata
  int maxdata;
  maxdata=comedi_get_maxdata(card,SUBDEV,chan);
  printf("maximum data value %d\n",maxdata);

}