0 Members and 5 Guests are viewing this topic.
GrayGetPlane returns a pointer to the grayscale plane plane. Valid values for plane are LIGHT_PLANE and DARK_PLANE. To draw in black, draw in both planes. Note: Do not assume that any plane is on 0x4C00 when in grayscale mode, due to hardware version 2 support. Also do not assume that the 2 grayscale planes are consecutive, this is not the case on hardware version 1.
#define MAP_X 20#define MAP_Y 12
#include <tigcclib.h>#define MAP_X 20#define MAP_Y 12
unsigned char game_sprites[2][8] = //array of sprites{ //Grass 0b00000000, 0b00101000, 0b00010000, 0b00000000, 0b00000101, 0b00000010, 0b01010000, 0b00100000,},{ //tree 0b00000000, 0b00000000, 0b00111110, 0b01111111, 0b01111111, 0b01111111, 0b00111110, 0b00001000,}unsigned char map[8][8] = { {1,1,1,1,1,1,1,1}, {1,0,0,0,0,0,0,1}, {1,0,0,0,0,0,0,1}, {1,0,0,0,0,0,0,1}, {1,0,0,0,0,0,0,1}, {1,0,0,0,0,0,0,1}, {1,0,0,0,0,0,0,1}, {1,1,1,1,1,1,1,1},};//0 = Grass and 1 = Tree//Drawing:int tilemap_x, tilemap_y;int lcd_x, lcd_y;unsigned char* pSprite;unsigned char sprite_index;// initialize the lcd Y value since we starting the first rowlcd_y = 0;for (tilemap_y = 0; tilemap_y < 8; tilemap_y++){ // initialize the lcd X value since we are starting a new collumn lcd_x = 0; for (tilemap_x = 0; tilemap_x < 8; tilemap_x++) { // first, get the sprite index from the tilemap sprite_index = game_tilemap[tilemap_y][tilemap_x]; // second, get the pointer (address) to the sprite pSprite = &game_sprites[sprite_index][0]; // draw the sprite to the screen Sprite8 (lcd_x, lcd_y, 8, pSprite, LCD_MEM, SPRT_RPLC); // --> TIGCC lib // increment the lcd X position in preparation for next sprite lcd_x = lcd_x + 8; } // increment the lcd Y position in preparation for next row of sprites lcd_y = lcd_y + 8;}
int i, j; unsigned char ** map = malloc(MAP_Y * sizeof(unsigned char)); for (i = 0; i < MAP_Y; i++) { map[i] = malloc(MAP_X * sizeof(unsigned char)); }
for (i = 0; i < MAP_Y ; i++) { free(map[i]); } free(map);
int i, j; unsigned char ** map = malloc(MAP_Y * sizeof(unsigned char)); for (i = 0; i < MAP_Y; i++) { printf("%d",i); ngetchx(); //Here map[i] = malloc(MAP_X * sizeof(unsigned char)); }
unsigned char *map = malloc(MAP_X * MAP_Y * sizeof(unsigned char));