Wed Aug 09, 2017 10:18 pm
///////////////////////////////////////////////////////////////////////////////
///////////////////////////Pixel Color Includes////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
uint16_t palette[16]; // Should probably be 256, but I don't use many colors...
uint16_t pixel_data[2500];
//Extra integers for color palette
int a = 0xa; int b = 0xb; int c = 0xc;
int d = 0xd; int e = 0xe; int f = 0xf;
//////////////////////////////////////////////////////////////////////////////
///////////////////////////////Palette////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
palette[0] = 0;
palette[1] = BLACK;
palette[2] = BLUE;
palette[3] = BROWN;
palette[4] = DARKGREEN;
palette[5] = GREY;
palette[6] = PINK;
palette[7] = RED;
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
palette[8] = BEIGE;
palette[9] = GREEN;
palette[a]= DARKGREY;
palette[b] = LIGHTGREY;
palette[c] = YELLOW;
palette[d] = PURPLE;
palette[e] = WHITE;
palette[f] = ORANGE;
///////////////////////////////Player/////////////////////////////////////////
////////////////////////////Paul Atreades/////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
const byte paulfront[] = {
0x00,0x00,0x03,0x37,0x73,0x30,0x00,0x00,
0x00,0x00,0x37,0x33,0x33,0x73,0x00,0x00,
0x00,0x03,0x73,0x37,0x73,0x37,0x30,0x00,
0x00,0x73,0x76,0x63,0x36,0x67,0x37,0x00,
0x00,0x37,0x66,0x66,0x66,0x66,0x73,0x00,
0x01,0x63,0x63,0x36,0x63,0x36,0x36,0x10,
0x01,0x66,0x66,0x26,0x62,0x66,0x66,0x10,
0x00,0x11,0x66,0x26,0x62,0x66,0x11,0x00,
0x00,0x11,0x16,0x66,0x66,0x61,0x11,0x00,
0x01,0x66,0x11,0x66,0x66,0x11,0x66,0x10,
0x01,0x66,0x11,0x11,0x11,0x11,0x66,0x10,
0x00,0x11,0x12,0x21,0x12,0x21,0x11,0x00,
0x00,0x01,0x51,0x15,0x51,0x15,0x10,0x00,
0x00,0x01,0x52,0x21,0x12,0x25,0x10,0x00,
0x00,0x00,0x22,0x10,0x01,0x22,0x00,0x00,
0x00,0x00,0x11,0x10,0x01,0x11,0x00,0x00};
tft.writeRectNBPP(player_x, player_y,16,16,4,paulfrontw,palette);
Sat Sep 16, 2017 7:58 am
Mon Sep 25, 2017 9:09 pm
void Grafx_esp::drawTilemap(int x, int y, const uint16_t *tilemap, const uint8_t **spritesheet, uint16_t dx, uint16_t dy, uint16_t dw, uint16_t dh, uint16_t * palette){
//uint8_t tilemap_width = pgm_read_byte(tilemap);
//uint8_t tilemap_height = pgm_read_byte(tilemap + 1);
//uint8_t tile_width = pgm_read_byte(tilemap + 2);
//uint8_t tile_height = pgm_read_byte(tilemap + 3);
//tilemap += 4; // now the first tile is at tilemap
uint16_t tilemap_width = pgm_read_byte(tilemap)* 256 + pgm_read_byte(tilemap + 1);
uint16_t tilemap_height = pgm_read_byte(tilemap + 2)* 256 + pgm_read_byte(tilemap + 3);
uint16_t tile_width = pgm_read_byte(tilemap + 4);
uint16_t tile_height = pgm_read_byte(tilemap + 5);
tilemap += 6; // now the first tile is at tilemap
uint16_t ddw = dw + dx;
uint16_t ddh = dh + dy;
uint16_t maxDdx = (dw - x + tile_width - 1) / tile_width;
uint16_t maxDdy = (dh - y + tile_height - 1) / tile_height;
if (tilemap_width < maxDdx){
maxDdx = tilemap_width;
}
if (tilemap_height < maxDdy){
maxDdy = tilemap_height;
}
int16_t startDdx = (-x) / tile_width;
int16_t startDdy = (-y) / tile_height;
if (startDdx < 0){
startDdx = 0;
}
if (startDdy < 0){
startDdy = 0;
}
if (flagcollision)numcolision = 0; //Line 735 - clear numcolision - ADD by Summoner123
for (uint16_t ddy = startDdy; ddy < maxDdy; ddy++){
for (uint16_t ddx = startDdx; ddx < maxDdx; ddx++){
int16_t drawX = ddx*tile_width + x + dx;
int16_t drawY = ddy*tile_height + y + dy;
uint16_t tile = pgm_read_byte(tilemap + ddy*tilemap_width + ddx);
if (drawX >= dx && drawY >= dy && drawX <= (ddw - tile_width) && drawY <= (ddh - tile_height)){
writeRectNBPP(drawX, drawY,tile_width, tile_height, 4, spritesheet[tile], palette );
if (flagcollision){
solid[numcolision].x = drawX; //Save X coordinate - ADD by Summoner123
solid[numcolision].y = drawY; //Save Y coordinate - ADD by Summoner123
solid[numcolision].spritecol = spritesheet[tile]; //Save Sprite of tile - ADD by Summoner123
numcolision++; //Increment numcolision - ADD by Summoner123
}
}
else{ // we need to draw a partial bitmap
writeRect4BPPtm(drawX, drawY, tile_width, tile_height, spritesheet[tile], dx, dy, dw, dh, palette);
}
}
}
}