Images are the visual building blocks of your game. Use images to draw on screen, or as sources for sprites and fonts. Images can be read from a file or created empty and can be used directly or provide frames for sprites or characters for fonts.
The simplest form of creating an image is by using create_image():
struct image* image; image = create_image("path/to/image.png");
Images can also be used as a drawing target instead of the screen:
draw_on_image(image); // draw images, sprites or text draw_on_screen();
You will have to explicitly get rid of any image you create using destroy_image():
Not doing so will result a memory leak.
struct image *
create_target_image(int width, int height, struct color color)¶
Create an image that can be used to draw other images or sprites on.
- image pointer or NULL on failure
The width of the blank image
The height of the blank image
The default color of the target image
void set_blend_mode(struct image * image, enum blend_mode blend_mode)
Set the method to use when drawing an image
image The blend method will work for
The blend method to apply
doxygenfunction: Cannot find function “load_image” in doxygen xml output for project “project0” from directory: ../build/doxygen/xml/
cleanup_image(struct image *image)¶
Cleanup any initialized image resources Cleanup will free all internally allocated resources for this image, making it ready for deallocation.
Existing image to cleanup
pixels_collide(struct image *img1, struct rectangle *rect1, struct image *img2, struct rectangle *rect2)¶
Test if two images have colliding pixels
- 1 if collision was found 0 if no collisions were found -1 when error occured
First image to test
Area in first image to test
Second image to test
Area in second image to test