- Ja carrega els nivells i funciona un poc, pero com els vertices no estàn ordenats peta. TBD: ordenar clockwise els vertices de cada sector
This commit is contained in:
28
draw.cpp
28
draw.cpp
@@ -28,6 +28,11 @@ namespace draw
|
||||
debug::init(sdl_renderer);
|
||||
}
|
||||
|
||||
void cls()
|
||||
{
|
||||
memset(screen, 0, 320*240);
|
||||
}
|
||||
|
||||
surface_t *newsurf(int w, int h)
|
||||
{
|
||||
surface_t *surf = (surface_t*)malloc(sizeof(surface_t));
|
||||
@@ -107,11 +112,17 @@ namespace draw
|
||||
|
||||
void drawsurf(int x, int y, surface_t *src, surface_t *dst)
|
||||
{
|
||||
int w = src->w; if (x+w > dst->w) w = dst->w-x;
|
||||
int h = src->h; if (y+h > dst->h) h = dst->h-y;
|
||||
for (int py=0;py<h;++py)
|
||||
for (int px=0;px<w;++px)
|
||||
dst->pixels[(px+x)+(py+y)*dst->w] = src->pixels[x+y*src->w];
|
||||
int sw = src->w; int dx = x; int sx = 0;
|
||||
if (x < 0) { sw = sw+x; sx=-x; dx=0; }
|
||||
if (dx+sw > dst->w) sw = dst->w-dx;
|
||||
|
||||
int sh = src->h; int dy = y; int sy = 0;
|
||||
if (y < 0) { sh = sh+y; sy=-y; dy=0; }
|
||||
if (dy+sh > dst->h) sh = dst->h-dy;
|
||||
|
||||
for (int py=0;py<sh;++py)
|
||||
for (int px=0;px<sw;++px)
|
||||
dst->pixels[(px+dx)+(py+dy)*dst->w] = src->pixels[(sx+px)+(sy+py)*src->w];
|
||||
}
|
||||
|
||||
void line(int x1, int y1, int x2, int y2, Uint8 color)
|
||||
@@ -161,14 +172,15 @@ namespace draw
|
||||
|
||||
namespace map
|
||||
{
|
||||
float zoom = 8;
|
||||
void putp(int x, int y, Uint8 color)
|
||||
{
|
||||
draw::putp(160+(x/8), 120+(y/8), color);
|
||||
draw::putp(160+(x/zoom), 120+(y/zoom), color);
|
||||
}
|
||||
|
||||
void line(int x1, int y1, int x2, int y2, Uint8 color)
|
||||
void line(int x1, int y1, int x2, int y2, Uint8 color, int ox, int oy)
|
||||
{
|
||||
draw::line(160+(x1/8), 120+(y1/8), 160+(x2/8), 120+(y2/8), color);
|
||||
draw::line(160+(x1/zoom)-ox/zoom, 120+(-y1/zoom)+oy/zoom, 160+(x2/zoom)-ox/zoom, 120+(-y2/zoom)+oy/zoom, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user