- Treballant en el editor de posició i tamany del bitmap

This commit is contained in:
2024-09-18 23:11:26 +02:00
parent 99d0583833
commit 1c53f49125
6 changed files with 137 additions and 23 deletions

View File

@@ -0,0 +1,61 @@
#include "m_editor_bitmap.h"
#include "jdraw.h"
#include "jinput.h"
#include <SDL2/SDL.h>
#include "room.h"
#include "actor.h"
#include "m_game.h"
namespace modules
{
namespace editor_bitmap
{
int edit_mode = EDITING_BITMAP_POS;
draw::surface *surf = nullptr;
void init(int editing)
{
edit_mode = editing;
draw::resetViewport();
surf = draw::getSurface(actor::getSelected()->bmp);
}
bool loop()
{
if (input::keyPressed(SDL_SCANCODE_ESCAPE)) return false;
const int tx = (520-surf->w)/2;
const int ty = (240-surf->h)/2;
draw::cls(PAPER);
draw::setSource(surf);
draw::color(BLUE);
draw::setViewport(tx, ty, surf->w, surf->h);
draw::fillrect(0, 0, surf->w, surf->h);
draw::color(BLUE+LIGHT);
int x=0, y=0;
while(y*32<surf->h)
{
draw::fillrect(x, y*32, 32, 32);
x+=64; if (x>=surf->w) { y++; x = (y%2==0) ? 0 : 32; }
}
draw::resetViewport();
draw::color(WHITE);
draw::rect(((520-surf->w)/2)-1, ((240-surf->h)/2)-1, surf->w+2, surf->h+2);
draw::draw((520-surf->w)/2, (240-surf->h)/2, surf->w, surf->h, 0, 0, 0);
draw::setViewport(tx, ty, surf->w, surf->h);
draw::color(RED+LIGHT);
draw::hline(0, actor::getSelected()->bmp_rect.y, surf->w);
draw::vline(actor::getSelected()->bmp_rect.x, 0, surf->h);
draw::color(YELLOW);
draw::hline(0, actor::getSelected()->bmp_rect.y+actor::getSelected()->bmp_rect.h, surf->w);
draw::vline(actor::getSelected()->bmp_rect.x+actor::getSelected()->bmp_rect.w, 0, surf->h);
draw::resetViewport();
draw::render();
return true;
}
}
}