Documentation de la bibliothèque MLV-0.5

MLV_animation.h

Aller à la documentation de ce fichier.
00001 /*
00002  *   This file is part of the MLV Library.
00003  *
00004  *   Copyright (C) 2010 Adrien Boussicault, Marc Zipstein
00005  *
00006  *
00007  *    This Library is free software: you can redistribute it and/or modify
00008  *    it under the terms of the GNU General Public License as published by
00009  *    the Free Software Foundation, either version 3 of the License, or
00010  *    (at your option) any later version.
00011  *
00012  *    This Library is distributed in the hope that it will be useful,
00013  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *    GNU General Public License for more details.
00016  *
00017  *    You should have received a copy of the GNU General Public License
00018  *    along with this Library.  If not, see <http://www.gnu.org/licenses/>.
00019  */
00020 
00034 #ifndef __MLV_ANIMATION_H__
00035 #define __MLV_ANIMATION_H__
00036 
00037 #include "MLV_image.h"
00038 #include "MLV_audio.h"
00039 
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043 
00045 //    Animation data
00047 
00052 typedef struct _MLV_Animation_sequence MLV_Animation_sequence;
00053 
00082 MLV_Animation_sequence* MLV_create_animation_sequence(
00083         unsigned int nb_frames, unsigned int nb_layers, unsigned int nb_channels
00084 );
00085 
00089 void MLV_free_animation_sequence( MLV_Animation_sequence* animation );
00090 
00104 void MLV_change_frame_in_animation_sequence(
00105         MLV_Image** array_of_images, MLV_Sound** array_of_sounds, unsigned int delay,
00106         MLV_Animation_sequence* animation, unsigned int position
00107 );
00108 
00119 void MLV_change_frame_image_in_animation_sequence(
00120         MLV_Image* image, MLV_Animation_sequence* animation, unsigned int position,
00121         unsigned int layer
00122 );
00123 
00134 void MLV_change_frame_sound_in_animation_sequence(
00135         MLV_Sound* sound, MLV_Animation_sequence* animation, unsigned int position,
00136         unsigned int channel
00137 );
00138 
00146 void MLV_change_frame_delay_in_animation_sequence(
00147         unsigned int delay, MLV_Animation_sequence* animation, unsigned int position
00148 );
00149 
00160 void MLV_get_frame_from_animation_sequence(
00161         MLV_Animation_sequence* animation, unsigned int position,
00162         unsigned int layer,
00163         MLV_Image** image, unsigned int* delay
00164 );
00165 
00175 int MLV_get_frame_delay_from_animation_sequence(
00176         MLV_Animation_sequence* animation, unsigned int position
00177 );
00178 
00189 MLV_Image* MLV_get_frame_image_from_animation_sequence(
00190         MLV_Animation_sequence* animation, unsigned int position,
00191         unsigned int layer
00192 );
00193 
00194 
00195 
00196 
00198 //    Animation engine
00200 
00244 typedef struct _MLV_Animation MLV_Animation;
00245 
00246 
00255 MLV_Animation* MLV_create_animation( MLV_Animation_sequence* animation );
00256 
00262 void MLV_free_animation( MLV_Animation* animation );
00263 
00269 void MLV_play_animation( MLV_Animation* animation );
00270 
00276 void MLV_play_revert_animation( MLV_Animation* animation );
00277 
00283 void MLV_stop_animation( MLV_Animation* animation );
00284 
00291 void MLV_rewind_animation( MLV_Animation* animation );
00292 
00298 void MLV_next_frame( MLV_Animation* animation );
00299 
00305 void MLV_previous_frame( MLV_Animation* animation );
00306 
00318 void MLV_update_animation( MLV_Animation* animation );
00319 
00327 void MLV_change_sound_volume_on_animation(
00328         MLV_Animation* animation, unsigned int channel, float volume
00329 );
00330 
00337 void MLV_turn_on_sound_on_animation(
00338         MLV_Animation* animation, unsigned int channel
00339 );
00340 
00347 void MLV_turn_off_sound_on_animation(
00348         MLV_Animation* animation, unsigned int channel
00349 );
00350 
00351 
00353 //    Drawing animation
00355 
00367 void MLV_draw_animation(
00368         MLV_Animation* animation, unsigned int layer,
00369         int x, int y
00370 );
00371 
00389 void MLV_draw_partial_animation(
00390         MLV_Animation* animation, unsigned int layer,
00391         int source_x, int source_y, int source_width, int source_height,
00392         MLV_Image* image,
00393         int x, int y
00394 );
00395 
00408 void MLV_draw_animation_on_image(
00409         MLV_Animation* animation, unsigned int layer,
00410         MLV_Image* image,
00411         int x, int y
00412 );
00413 
00431 void MLV_draw_partial_animation_on_image(
00432         MLV_Animation* animation, unsigned int layer,
00433         int source_x, int source_y, int source_width, int source_height,
00434         MLV_Image* image,
00435         int x, int y
00436 );
00437 
00438 
00439 
00440 
00442 //    Loading animations from files
00444 
00449 typedef struct _MLV_Animation_book MLV_Animation_book;
00450 
00451 
00470 MLV_Animation_book* MLV_load_animation_book(
00471         const char* xml_file,
00472         const char* image_directory,
00473         const char* sound_directory
00474 );
00475 
00481 void MLV_free_animation_book(
00482         MLV_Animation_book* animation_book
00483 );
00484 
00491 int MLV_get_number_of_animation_sequences(
00492         MLV_Animation_book* animation_book
00493 );
00494 
00502 MLV_Animation_sequence* MLV_get_animation_from_id(
00503         MLV_Animation_book* animation_book,
00504         int id
00505 );
00506 
00514 MLV_Animation_sequence* MLV_get_animation_from_name(
00515         MLV_Animation_book* animation_book,
00516         const char* name
00517 );
00518 
00527 const char* MLV_get_name_from_id_animation(
00528         MLV_Animation_book* animation_book, int id_animation
00529 );
00530 
00545 void MLV_add_frame_in_animation_sequence(
00546         MLV_Image** array_of_images, MLV_Sound** array_of_sounds,  unsigned int delay,
00547         MLV_Animation_sequence* animation_sequence
00548 );
00549 
00550 #ifdef __cplusplus
00551 }
00552 #endif
00553 
00554 #endif
00555