diff --git a/.gitignore b/.gitignore index 600d2d3..6d0ee45 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.vscode \ No newline at end of file +.vscode +.DS_Store \ No newline at end of file diff --git a/test.c b/test.c index cdb8d11..309d2dd 100644 --- a/test.c +++ b/test.c @@ -23,11 +23,11 @@ void initGso(GameSpriteObject *gso) { lastFreeTileValue = *(gso->lastFreeTilePointer); tileSum = gso->width * gso->height; - set_sprite_data(lastFreeTileValue, tileSum, gb_tile_data/*gso->tileDataPointer*/); + set_sprite_data(lastFreeTileValue, tileSum, gso->tileDataPointer); // Refresh lastFreeTile value - *(gso->lastFreeTilePointer) = lastFreeTileValue + tileSum; // replace += + *(gso->lastFreeTilePointer) += tileSum; // Link tiles and sprites - for (i = 0; i < tileSum; i++) { + for (i = lastFreeTileValue; i < lastFreeTileValue + tileSum; i++) { set_sprite_tile(i, i); } } @@ -37,8 +37,9 @@ void newGso(GameSpriteObject *gsoPointer, UINT8 height, UINT8 *tileDataPointer, UINT8 *lastFreeTilePointer) { - // Without this line height === 0 ¯\_(ツ)_/¯ + // Without this lines some params === 0 ¯\_(ツ)_/¯ gsoPointer->height; + gsoPointer->tileDataPointer; gsoPointer->width = width; gsoPointer->height = height; @@ -49,27 +50,18 @@ void newGso(GameSpriteObject *gsoPointer, initGso(gsoPointer); } -void shift_sprite(UBYTE x, UBYTE y) -{ - UBYTE i, j, c = 0; +// Work correctly with 8*8 sprites +void moveGso(GameSpriteObject *gso, UINT8 x, UINT8 y) { + UBYTE i, j, c; + c = gso->firstTileNum; - for (i = 0; i < 3; ++i) { - for (j = 0; j < 3; ++j) { + for (i = 0; i < gso->height; ++i) { + for (j = 0; j < gso->width; ++j) { move_sprite(c++, x + 8 * j, y + 8 * i); } } } -void init_sprite(unsigned char *tile_data) -{ - UBYTE i; - set_sprite_data(0, 9, tile_data); - - for (i = 0; i < 9; ++i) { - set_sprite_tile(i, i); - } -} - void main() { const JUMP_DELAY = 15; @@ -89,18 +81,29 @@ void main() UINT8 lastFreeTile = 0; - UINT8 playerWidth = 3; - UINT8 playerHeight = 3; - UINT8 *playerTileDataPointer = &gb_tile_data; + UINT8 playerWidth = flbird_tile_map_width; + UINT8 playerHeight = flbird_tile_map_height; + UINT8 *playerTileDataPointer = &flbird_tile_data; GameSpriteObject player; + GameSpriteObject pipeBottom; + GameSpriteObject pipeBody; + newGso(&player, playerWidth, playerHeight, playerTileDataPointer, &lastFreeTile); + newGso(&pipeBottom, fltopbottom_tile_map_width, fltopbottom_tile_map_height, fltopbottom_tile_data, &lastFreeTile); + moveGso(&pipeBottom, 70, 56); + + // Sprite graphic have a restriction: only 40 tiles on screen. + // Defenitely need to use background layer + // set_bkg_data(0, flbody_tile_count, flbody_tile_data); + // set_bkg_tiles() + SPRITES_8x8; SHOW_BKG; SHOW_SPRITES; DISPLAY_ON; - + while(resume) { j = joypad(); if (j & J_A && !delay) { @@ -111,9 +114,9 @@ void main() } if (j & J_RIGHT) - x++; + x+=3; if (j & J_LEFT) - x--; + x-=3; if (clock() > delaying) delay = FALSE; t = clock() - time_backup; @@ -124,7 +127,7 @@ void main() y = yd + vcoord; y = gh - y; - shift_sprite(x, y); + moveGso(&player, x, y); if (y < 10 || y > GRAPHICS_HEIGHT) { resume = 0; printf("FAGGOT"); diff --git a/test.gb b/test.gb index 8fcb824..acb7548 100644 Binary files a/test.gb and b/test.gb differ diff --git a/tiledata.h b/tiledata.h index 1e8c6d5..e165713 100644 --- a/tiledata.h +++ b/tiledata.h @@ -18,12 +18,12 @@ // // // // ///////////////// -const int gb_tile_map_size = 0x09; -const int gb_tile_map_width = 0x03; -const int gb_tile_map_height = 0x03; +const int flbird_tile_map_size = 0x09; +const int flbird_tile_map_width = 0x03; +const int flbird_tile_map_height = 0x03; -const int gb_tile_data_size = 0x90; -const int gb_tile_count = 0x09; +const int flbird_tile_data_size = 0x90; +const int flbird_tile_count = 0x09; // //////////////// // // // @@ -31,7 +31,7 @@ const int gb_tile_count = 0x09; // // // // //////////////// -const unsigned char gb_map_data[] = { +const unsigned char flbird_map_data[] = { 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08 }; @@ -41,7 +41,7 @@ const unsigned char gb_map_data[] = { // // // // ///////////////// -const unsigned char gb_tile_data[] = { +const unsigned char flbird_tile_data[] = { 0x00,0x00,0x02,0x00,0x03,0x03,0x0C,0x00,0x0C,0x04,0x7F,0x3E,0xFF,0x00,0xC1,0x81, 0xFF,0x7F,0xFF,0x04,0x84,0x04,0x1C,0x00,0x18,0x08,0x18,0x08,0x98,0x08,0x98,0x08, 0x80,0x80,0xC0,0x00,0x60,0x40,0x30,0x00,0x30,0x00,0x68,0x48,0x6C,0x48,0x68,0x48, @@ -51,4 +51,161 @@ const unsigned char gb_tile_data[] = { 0x0F,0x06,0x0F,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xFF,0x03,0xFF,0x00,0xFC,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xF8,0xF8,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; - \ No newline at end of file + +// /////////////////////// +// // // +// // File Attributes // +// // // +// /////////////////////// + +// Filename: flbody.png +// Pixel Width: 40px +// Pixel Height: 8px + +// ///////////////// +// // // +// // Constants // +// // // +// ///////////////// + +const int flbody_tile_map_size = 0x05; +const int flbody_tile_map_width = 0x05; +const int flbody_tile_map_height = 0x01; + +const int flbody_tile_data_size = 0x50; +const int flbody_tile_count = 0x05; + +// //////////////// +// // // +// // Map Data // +// // // +// //////////////// + +const unsigned char flbody_map_data[] ={ + 0x00,0x01,0x02,0x03,0x04 +}; + +// ///////////////// +// // // +// // Tile Data // +// // // +// ///////////////// + +const unsigned char flbody_tile_data[] ={ + 0x60,0x20,0x60,0x20,0x60,0x20,0x60,0x20,0x60,0x20,0x60,0x20,0x60,0x20,0x60,0x20, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00, + 0xAE,0x1E,0xAE,0x1E,0xAE,0x1E,0xAE,0x1E,0xAE,0x1E,0xAE,0x1E,0xAE,0x1E,0xAE,0x1E}; + +// /////////////////////// +// // // +// // File Attributes // +// // // +// /////////////////////// + +// Filename: fltopbottom.png +// Pixel Width: 40px +// Pixel Height: 24px + +// ///////////////// +// // // +// // Constants // +// // // +// ///////////////// + +const int fltopbottom_tile_map_size = 0x0F; +const int fltopbottom_tile_map_width = 0x05; +const int fltopbottom_tile_map_height = 0x03; + +const int fltopbottom_tile_data_size = 0xF0; +const int fltopbottom_tile_count = 0x0F; + +// //////////////// +// // // +// // Map Data // +// // // +// //////////////// + +const unsigned char fltopbottom_map_data[] ={ + 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E +}; + +// ///////////////// +// // // +// // Tile Data // +// // // +// ///////////////// + +const unsigned char fltopbottom_tile_data[] ={ + 0x60,0x20,0x60,0x20,0x60,0x20,0x60,0x20,0x60,0x20,0xE3,0x70,0xFF,0xFF,0xFF,0xFF, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x01,0xFF,0xFF,0xFF,0xFF, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xAE,0x1E,0xAE,0x1E,0xAE,0x1E,0xAE,0x1E,0xAE,0x1E,0xBE,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xC0,0xC0,0xC0,0x80,0xC0,0x80,0xC0,0x80,0xC0,0x80,0xC0,0x80,0xC0,0x80,0xC0,0x80, + 0x9F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xB3,0x4F,0xD3,0x0F,0xC3,0x0F,0xC3,0x0F,0xC3,0x0F,0xC3,0x0F,0xC3,0x0F,0xC3,0x0F, + 0xC0,0x80,0xC0,0x80,0xC0,0x80,0xC0,0x80,0xC0,0x80,0x80,0xC0,0xD0,0xE0,0xFF,0xFF, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0xFF,0xFF, + 0xC3,0x0F,0xC3,0x0F,0xC3,0x0F,0xC3,0x0F,0x4B,0x07,0x03,0x07,0x17,0x0F,0xFF,0xFF}; + +// /////////////////////// +// // // +// // File Attributes // +// // // +// /////////////////////// + +// Filename: flbottomtop.png +// Pixel Width: 40px +// Pixel Height: 24px + +// ///////////////// +// // // +// // Constants // +// // // +// ///////////////// + +const int flbottomtop_tile_map_size = 0x0F; +const int flbottomtop_tile_map_width = 0x05; +const int flbottomtop_tile_map_height = 0x03; + +const int flbottomtop_tile_data_size = 0xF0; +const int flbottomtop_tile_count = 0x0F; + +// //////////////// +// // // +// // Map Data // +// // // +// //////////////// + +const unsigned char flbottomtop_map_data[] ={ + 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E +}; + +// ///////////////// +// // // +// // Tile Data // +// // // +// ///////////////// + +const unsigned char flbottomtop_tile_data[] ={ + 0xFF,0xFF,0xD0,0xE0,0x80,0xC0,0xC0,0x80,0xC0,0x80,0xC0,0x80,0xC0,0x80,0xC0,0x80, + 0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0xFF,0x17,0x0F,0x03,0x07,0x4B,0x07,0xC3,0x0F,0xC3,0x0F,0xC3,0x0F,0xC3,0x0F, + 0xC0,0x80,0xC0,0x80,0xC0,0x80,0xC0,0x80,0xC0,0x80,0xC0,0x80,0xC0,0x80,0xC0,0xC0, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9F,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00, + 0xC3,0x0F,0xC3,0x0F,0xC3,0x0F,0xC3,0x0F,0xC3,0x0F,0xC3,0x0F,0xD3,0x0F,0xB3,0x4F, + 0xFF,0xFF,0xFF,0xFF,0xE3,0x70,0x60,0x20,0x60,0x20,0x60,0x20,0x60,0x20,0x60,0x20, + 0xFF,0xFF,0xFF,0xFF,0xFE,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0xFF,0xFF,0xFF,0x01,0xFF,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00, + 0xFF,0xFF,0xFF,0xFF,0xBE,0xFF,0xAE,0x1E,0xAE,0x1E,0xAE,0x1E,0xAE,0x1E,0xAE,0x1E};