#include "gbaio.h" // I got tired of seeing 0x00, 0x01... everywhere, so I'm using a "feature" of C to temporarily redefine // the characters 'O' (capital Oh) and '_' (underscore). Everywhere in the shapes that I want 0x01 (white) // I use an 'O' instead, and everywhere I want 0x00 (transparent) I use an underscore. Notice that the // comma is also included. #define O 0x01, #define _ 0x00, char die1[] = { _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ O O _ _ _ _ _ _ O O _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ }; char die2[] = { O O _ _ _ _ _ _ O O _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ O O _ _ _ _ _ _ O O }; char die3[] = { O O _ _ _ _ _ _ O O _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ O O _ _ _ _ _ _ O O _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ O O _ _ _ _ _ _ O O }; char die4[] = { O O _ _ _ _ O O O O _ _ _ _ O O _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ O O _ _ _ _ O O O O _ _ _ _ O O }; char die5[] = { O O _ _ _ _ O O O O _ _ _ _ O O _ _ _ _ _ _ _ _ _ _ _ O O _ _ _ _ _ _ O O _ _ _ _ _ _ _ _ _ _ _ O O _ _ _ _ O O O O _ _ _ _ O O }; char die6[] = { O O _ _ _ _ O O O O _ _ _ _ O O _ _ _ _ _ _ _ _ O O _ _ _ _ O O O O _ _ _ _ O O _ _ _ _ _ _ _ _ O O _ _ _ _ O O O O _ _ _ _ O O }; // This undefines the 'O' and '_' so that they go back to being normal characters. #undef O #undef _ int main(void) { int roll, die_image; start_game(); load_image(1, die1, IMAGE_8x8); load_image(2, die2, IMAGE_8x8); load_image(3, die3, IMAGE_8x8); load_image(4, die4, IMAGE_8x8); load_image(5, die5, IMAGE_8x8); load_image(6, die6, IMAGE_8x8); die_image = 1; while (1) { // check for input start_input(); if (button_held(A_BUTTON)) roll = YES; else roll = NO; // change things if (roll == YES) die_image = rand(1, 6); // draw things start_drawing(); set_sprite_image(0, die_image); draw_sprite(0, 116, 76); } return 0; }