- [FIX] Ficar correctament el color transparent al volcar a pantalla
- [NEW] Rejilla de tiles
This commit is contained in:
@@ -564,6 +564,22 @@ namespace draw
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void draw(const int dx, const int dy, const int w, const int h, const int sx, const int sy, const int zoom)
|
||||||
|
{
|
||||||
|
// Si no hi ha superficie d'oritge especificada, no fem res, o petarà el mame
|
||||||
|
if (source == nullptr) return;
|
||||||
|
|
||||||
|
for (int y=0; y<h; ++y) {
|
||||||
|
for (int x=0; x<w; ++x) {
|
||||||
|
const uint8_t pixel = pget(source, sx+x, sy+y);
|
||||||
|
for (int zx=0; zx<zoom; ++zx)
|
||||||
|
for (int zy=0; zy<zoom; ++zy) {
|
||||||
|
pset(destination, dx+zx+x*zoom, dy+zy+y*zoom, pixel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Pinta tota la superficie "source" en la superficie "destination", posició (x,y).
|
// Pinta tota la superficie "source" en la superficie "destination", posició (x,y).
|
||||||
void draw(const int x, const int y)
|
void draw(const int x, const int y)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -124,6 +124,16 @@ namespace draw
|
|||||||
/// @param flip si s'ha de fer flip en hortizontal o vertical (o ambdos)
|
/// @param flip si s'ha de fer flip en hortizontal o vertical (o ambdos)
|
||||||
void draw(const int dx, const int dy, const int w, const int h, const int sx, const int sy, const draw::flip flip = draw::flip::none);
|
void draw(const int dx, const int dy, const int w, const int h, const int sx, const int sy, const draw::flip flip = draw::flip::none);
|
||||||
|
|
||||||
|
/// @brief Pinta un troç de la superficie "source" en la superficie "destination", amb zoom.
|
||||||
|
/// @param dx coordenada x de la destinació
|
||||||
|
/// @param dy coordenada y de la destinació
|
||||||
|
/// @param w ample del quadrat d'oritge a pintar
|
||||||
|
/// @param h alt del quadrat d'oritge a pintar
|
||||||
|
/// @param sx coordenada x de l'oritge
|
||||||
|
/// @param sy coordenada y de l'oritge
|
||||||
|
/// @param zoom zoom a aplicar al pintar
|
||||||
|
void draw(const int dx, const int dy, const int w, const int h, const int sx, const int sy, const int zoom);
|
||||||
|
|
||||||
/// @brief Pinta tota la superficie "source" en la superficie "destination", posició (x,y).
|
/// @brief Pinta tota la superficie "source" en la superficie "destination", posició (x,y).
|
||||||
/// @param x coordenada x de la destinació
|
/// @param x coordenada x de la destinació
|
||||||
/// @param y coordenada y de la destinació
|
/// @param y coordenada y de la destinació
|
||||||
|
|||||||
@@ -17,8 +17,12 @@ void game::init()
|
|||||||
|
|
||||||
bool loop()
|
bool loop()
|
||||||
{
|
{
|
||||||
draw::cls(0);
|
//draw::cls(0);
|
||||||
rooms::drawFullMap();
|
//rooms::drawFullMap();
|
||||||
|
rooms::draw();
|
||||||
|
draw::color(COLOR_BRIGHT_BLACK);
|
||||||
|
for (int i=0; i<=32; ++i) draw::vline(64+i*16, 48, 256);
|
||||||
|
for (int i=0; i<=16; ++i) draw::hline(64, 48+i*16, 512);
|
||||||
draw::render();
|
draw::render();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace rooms
|
|||||||
std::string current_room = "";
|
std::string current_room = "";
|
||||||
std::map<std::string, room_t> rooms;
|
std::map<std::string, room_t> rooms;
|
||||||
int full_map_x = 0, full_map_y = 0;
|
int full_map_x = 0, full_map_y = 0;
|
||||||
|
draw::surface *map_surface {nullptr};
|
||||||
|
|
||||||
static const char *paletteMap[] = {
|
static const char *paletteMap[] = {
|
||||||
"black", "bright_black", "blue", "bright_blue",
|
"black", "bright_black", "blue", "bright_blue",
|
||||||
@@ -284,6 +285,10 @@ namespace rooms
|
|||||||
detectFullMapOffset("01", 0, 0);
|
detectFullMapOffset("01", 0, 0);
|
||||||
full_map_x++;
|
full_map_x++;
|
||||||
full_map_y++;
|
full_map_y++;
|
||||||
|
|
||||||
|
if (map_surface) draw::freeSurface(map_surface);
|
||||||
|
map_surface = draw::createSurface(256,128);
|
||||||
|
|
||||||
/*for (auto &item : rooms)
|
/*for (auto &item : rooms)
|
||||||
{
|
{
|
||||||
room_t &room = item.second;
|
room_t &room = item.second;
|
||||||
@@ -295,17 +300,23 @@ namespace rooms
|
|||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
room_t &room = rooms["01"];
|
||||||
|
for (int y=0; y<16; ++y) {
|
||||||
|
for (int x=0; x<32; ++x)
|
||||||
|
std::cout << std::to_string(room.tiles[x][y]) << ",";
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw()
|
void draw()
|
||||||
{
|
{
|
||||||
room_t &room = rooms["02"];
|
room_t &room = rooms["01"];
|
||||||
|
|
||||||
draw::cls(room.border);
|
|
||||||
draw::setViewport(32, 24, 256, 128);
|
|
||||||
draw::cls(room.bgColor);
|
|
||||||
|
|
||||||
|
draw::setTrans(16);
|
||||||
|
draw::setDestination(map_surface);
|
||||||
|
draw::resetViewport();
|
||||||
draw::setSource(room.tileSetFile);
|
draw::setSource(room.tileSetFile);
|
||||||
|
draw::cls(room.bgColor);
|
||||||
|
|
||||||
for (int y=0; y<16; ++y) {
|
for (int y=0; y<16; ++y) {
|
||||||
for (int x=0; x<32; ++x) {
|
for (int x=0; x<32; ++x) {
|
||||||
@@ -317,6 +328,7 @@ namespace rooms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
draw::setTrans(0);
|
||||||
for (auto enemy : room.enemies)
|
for (auto enemy : room.enemies)
|
||||||
{
|
{
|
||||||
enemies::enemy_t &anim = enemies::get(enemy.animation);
|
enemies::enemy_t &anim = enemies::get(enemy.animation);
|
||||||
@@ -327,10 +339,18 @@ namespace rooms
|
|||||||
draw::restorecol(1);
|
draw::restorecol(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
draw::setTrans(16);
|
||||||
|
draw::setDestination(nullptr);
|
||||||
|
draw::setSource(map_surface);
|
||||||
|
draw::cls(COLOR_BRIGHT_BLACK);
|
||||||
|
draw::color(room.border);
|
||||||
|
draw::fillrect(48, 32, 512+32, 256+32);
|
||||||
|
draw::setViewport(64, 48, 512, 256);
|
||||||
|
draw::draw(0, 0, 256, 128, 0, 0, 2);
|
||||||
draw::resetViewport();
|
draw::resetViewport();
|
||||||
|
|
||||||
draw::setSource(room.thumbnail);
|
//draw::setSource(room.thumbnail);
|
||||||
draw::draw();
|
//draw::draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawFullMap()
|
void drawFullMap()
|
||||||
|
|||||||
Reference in New Issue
Block a user