コード例 #1
0
ファイル: radar.c プロジェクト: AlexsJones/gridfire_c
/*-----------------------------------------------------------------------------
 *  There is a bug here that needs to be fully resolved where a game object is destroyed whilst the radar_draw is attempting to get the object position
 *-----------------------------------------------------------------------------*/
void radar_draw(sfRenderWindow *main_window,jnx_list *draw_queue)
{
  sfRenderWindow_drawRectangleShape(main_window,radar_background,NULL);

  jnx_node *draw_queue_head = draw_queue->head;
  while(draw_queue_head)
  {
    game_object *current_obj = draw_queue_head->_data;
    if(current_obj)
    {
      sfSprite *obj_blip = radar_blip_from_object(current_obj);
      if(obj_blip != NULL){
        sfRenderWindow_drawSprite(main_window,obj_blip,NULL);
        sfSprite_destroy(obj_blip);
      }
    }
    draw_queue_head = draw_queue_head->next_node;
  }
}
コード例 #2
0
ファイル: cartographer.c プロジェクト: AlexsJones/gridfire_c
void cartographer_update()
{

  /*-----------------------------------------------------------------------------
   *  Warning, may slow down game loop if there are alot of objects here
   *-----------------------------------------------------------------------------*/
  jnx_node *head = object_list->head;
  jnx_list *new_draw = jnx_list_create();
  while(head)
  {
    game_object *current = head->_data;
    if(current->health > 0)
    {
      //still an active object
      jnx_list_add(new_draw,current);
    }
    else
    {
      if(strcmp(current->object_type,"player")  == 0)
      {
        /*-----------------------------------------------------------------------------
         *  If the player has been killed we'll call a clean up function to end the game
         *-----------------------------------------------------------------------------*/
        game_end();	
      }
      JNX_LOG(NULL,"Object %s at %g %g has been removed as health was %d\n", current->object_type,current->position.x, current->position.y, current->health);
      //remove the object
      play_sound(sound_lexplosion);

      /*-----------------------------------------------------------------------------
       *  Add our soon to be lost object to the score board
       *-----------------------------------------------------------------------------*/
      printf("adding object for destruction %s with health %d\n",current->object_type,current->health);
      //Possible bug here if the player starts in reach of enemy ships and they start blowing up before game time	
      score_add_destroyed_obj(current);
      sfSprite_destroy(current->sprite);
      free(current);
    }
    head = head->next_node;
  }
  object_list = new_draw;
}
コード例 #3
0
ファイル: SFSprite_cstub.c プロジェクト: LorantK/PC2R
CAMLprim value
caml_sfSprite_destroy(value sprite)
{
    sfSprite_destroy(SfSprite_val(sprite));
    return Val_unit;
}