Back to Evolution Project page
#ifndef SPRITE #define SPRITE #include <stdio.h> #include <stdlib.h> #include <glib.h> #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #define SPRITE_TYPE_SPRITE 1 #define SPRITE_TYPE_GROUND 2 #define SPRITE_TYPE_NONE 0 #define SPRITE_TYPE_SPRITE_STRING "sprite" #define SPRITE_TYPE_GROUND_STRING "ground" #define UNIT_WIDTH 20 #define UNIT_HEIGHT 20 #define CURRENT_FILE_MAJORVERSION 1 #define CURRENT_FILE_MINORVERSION 0 //Format of header of the file that store the map of level on disk //The size of this structure should be 1024 typedef struct file_header { long int major_version, minor_version; //version of file format long int level_width, level_height; //width and height of map long int num_sprites_on_screen; //number of sprites on screen long int num_grounds_on_screen; //number of grounds on screen char reserved[1000]; //Bytes remaining to complete 1024 } file_header; //sprite structure typedef struct sprite { int id; char name[300]; char filename[1000]; char filename_tga[1000]; char description[1000]; int sizex, sizey; int width_pixels, height_pixels; int type; //Type of the sprite void *pixmap; //GdkPixmap or CL_Surface void *mask; //GdkBitmap } sprite; typedef struct sprite_unit { int unitx, unity; int sprite_id; struct sprite *sprite; } sprite_unit; typedef struct unit { int sprite_id; int draw_here; //boolean - indicate if the sprite should be drawed in this unit. sprite_unit *sp_unit; } unit; typedef struct rect { int x, y, sx, sy; } rect; #define CONFIG_FILENAME "/etc/evolution.config" #define LEVELEDITORFILE "sprite_list.rc" gchar sprites_dir[1000]; gchar sprites_dir_home[1000]; GList* sprite_list; //List of "ground" sprites GList* sprite_list_sp; //List of "sprite" sprites GList *sp_unit_list; //List of ground on the screen GList *sp_unit_list_sp; //List of sprites on the screen unit *level; //Array of ground units unit *levelsp; //Array of sprite units int level_width, level_height; //Width and height in units void read_sprite_from_file(FILE* f, sprite* sp, gchar *sp_dir); void read_all_sprites(char* filename, gchar *sp_dir); void print_sprite_info(sprite* sp); int get_unit_from_pixelx(int pixels); int get_unit_from_pixely(int pixels); sprite *get_sprite_from_id(GList *splist, int id); sprite_unit *sprite_unit_add(GList **unit_list, sprite *sp, int x, int y); int can_place_sprite_on_unit(sprite *sp, int x, int y); void delete_sprite_unit(sprite_unit *sp_unit); //returns the rect to be updated rect add_sprite_on_unit(sprite *sp, int x, int y); rect delete_sprite_on_unit(unit *unitmap, int x, int y); //Function to open and save the files... int save_level_to_file(FILE *f); int open_level_from_file(FILE *f); void resize_array_of_units(void); //(Re)initialize array of units... void update_list_of_units(void); //Updates values in list of sprites and ground on screen, to save a file. int file_exists(gchar *fn); //Returns 1 if the current file exists... void read_config(void); void init_variables(void); #ifdef __cplusplus } #endif /* __cplusplus */ #endif //SPRITE