|
|
@@ -17,8 +17,11 @@ enum { |
|
|
|
signal_left_control, signal_count |
|
|
|
}; |
|
|
|
|
|
|
|
static Texture2D * render_texture; |
|
|
|
static int render_texture_count = 0; |
|
|
|
static int texture_count = 0; |
|
|
|
static int sound_count = 0; |
|
|
|
|
|
|
|
static Texture2D * texture_array; |
|
|
|
static Sound * sound_array; |
|
|
|
|
|
|
|
static Font font = { 0 }; |
|
|
|
static Font mono = { 0 }; |
|
|
@@ -34,7 +37,10 @@ static void no_logging (int msgType, const char * text, va_list args) { |
|
|
|
} |
|
|
|
|
|
|
|
static void render_clean_up (void) { |
|
|
|
free (render_texture); |
|
|
|
free (texture_array); |
|
|
|
free (sound_array); |
|
|
|
|
|
|
|
CloseAudioDevice (); |
|
|
|
|
|
|
|
CloseWindow (); |
|
|
|
} |
|
|
@@ -59,10 +65,16 @@ extern void render_vector (int x1, int y1, int x2, int y2); |
|
|
|
extern void engine_configure (void); |
|
|
|
extern void engine_synchronize (void); |
|
|
|
|
|
|
|
extern int import_sprite (char * path); |
|
|
|
extern int import_texture (char * path); |
|
|
|
extern int import_sound (char * path); |
|
|
|
|
|
|
|
extern int sprite_width (int index); |
|
|
|
extern int sprite_height (int index); |
|
|
|
|
|
|
|
extern void play_sound (int index); |
|
|
|
extern void stop_sound (int index); |
|
|
|
extern void loop_sound (int index); |
|
|
|
|
|
|
|
int cursor_x = 0; |
|
|
|
int cursor_y = 0; |
|
|
|
int cursor_mode = 0; |
|
|
@@ -88,7 +100,7 @@ void render_sprite (int sprite, int x, int y, int u, int v, int width, int heigh |
|
|
|
destination.width = (width < 0) ? -width : width; |
|
|
|
destination.height = (height < 0) ? -height : height; |
|
|
|
|
|
|
|
DrawTexturePro (render_texture [sprite], source, destination, dump, 0.0, tint); |
|
|
|
DrawTexturePro (texture_array [sprite], source, destination, dump, 0.0, tint); |
|
|
|
} |
|
|
|
|
|
|
|
void render_string (char * string, int x, int y, int colour, int choose) { |
|
|
@@ -116,6 +128,8 @@ void engine_configure (void) { |
|
|
|
InitWindow (1800, 900, "Chads of Might & Magic"); |
|
|
|
SetTargetFPS (60); |
|
|
|
|
|
|
|
InitAudioDevice (); |
|
|
|
|
|
|
|
font = LoadFont ("./sprite/font/gothic.ttf"); |
|
|
|
mono = LoadFont ("./sprite/font/mono.ttf"); |
|
|
|
|
|
|
@@ -181,28 +195,50 @@ void engine_synchronize (void) { |
|
|
|
ClearBackground (background); |
|
|
|
} |
|
|
|
|
|
|
|
int import_sprite (char * path) { |
|
|
|
++render_texture_count; |
|
|
|
int import_texture (char * path) { |
|
|
|
++texture_count; |
|
|
|
|
|
|
|
render_texture = realloc (render_texture, (unsigned long int) render_texture_count * sizeof (* render_texture)); |
|
|
|
texture_array = realloc (texture_array, (unsigned long int) texture_count * sizeof (* texture_array)); |
|
|
|
|
|
|
|
render_texture [render_texture_count - 1] = LoadTexture (path); |
|
|
|
texture_array [texture_count - 1] = LoadTexture (path); |
|
|
|
|
|
|
|
if ((render_texture [render_texture_count - 1].width == 0) || (render_texture [render_texture_count - 1].height == 0)) { |
|
|
|
if ((texture_array [texture_count - 1].width == 0) || (texture_array [texture_count - 1].height == 0)) { |
|
|
|
printf ("\033[1;31m%3i : '%60s' := %3i, %3i;\033[0m\n", |
|
|
|
render_texture_count - 1, |
|
|
|
texture_count - 1, |
|
|
|
path, |
|
|
|
render_texture [render_texture_count - 1].width, |
|
|
|
render_texture [render_texture_count - 1].height); |
|
|
|
texture_array [texture_count - 1].width, |
|
|
|
texture_array [texture_count - 1].height); |
|
|
|
} |
|
|
|
|
|
|
|
return (render_texture_count - 1); |
|
|
|
return (texture_count - 1); |
|
|
|
} |
|
|
|
|
|
|
|
int import_sound (char * path) { |
|
|
|
++sound_count; |
|
|
|
|
|
|
|
sound_array = realloc (sound_array, (unsigned long int) sound_count * sizeof (* sound_array)); |
|
|
|
|
|
|
|
sound_array [sound_count - 1] = LoadSound (path); |
|
|
|
|
|
|
|
return (sound_count - 1); |
|
|
|
} |
|
|
|
|
|
|
|
int sprite_width (int index) { |
|
|
|
return (render_texture [index].width); |
|
|
|
return (texture_array [index].width); |
|
|
|
} |
|
|
|
|
|
|
|
int sprite_height (int index) { |
|
|
|
return (render_texture [index].height); |
|
|
|
return (texture_array [index].height); |
|
|
|
} |
|
|
|
|
|
|
|
void play_sound (int index) { |
|
|
|
PlaySound (sound_array [index]); |
|
|
|
} |
|
|
|
|
|
|
|
void stop_sound (int index) { |
|
|
|
StopSound (sound_array [index]); |
|
|
|
} |
|
|
|
|
|
|
|
void loop_sound (int index) { |
|
|
|
PlaySound (sound_array [index]); |
|
|
|
} |