X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=tools%2Fdunger%2Fsrc%2Flevel.c;h=582592422bacaa4da6ff863c4548042063495c72;hb=d2306fabd6ad4a568174fe0f17dec0b24c202eac;hp=6fb5706f60570eaa1810ec96d15fc1adc316e842;hpb=5f481bfc3af614919e31b97bfd4af1f8b829c4c2;p=vrlugburz diff --git a/tools/dunger/src/level.c b/tools/dunger/src/level.c index 6fb5706..5825924 100644 --- a/tools/dunger/src/level.c +++ b/tools/dunger/src/level.c @@ -1,13 +1,8 @@ #include #include #include -#include #include "level.h" -extern int view_width, view_height; -extern float view_panx, view_pany, view_zoom; - - struct level *create_level(int xsz, int ysz) { struct level *lvl; @@ -30,53 +25,3 @@ void free_level(struct level *lvl) free(lvl->cells); free(lvl); } - -#define LTHICK 0.5f -static void draw_cell(struct level *lvl, struct cell *cell) -{ - int cidx, row, col; - float x, y, xsz, ysz, sz; - static const float colors[][3] = {{0, 0, 0}, {0.6, 0.6, 0.6}, {0.4, 0.2, 0.1}}; - - xsz = view_zoom * view_width / lvl->width; - ysz = view_zoom * view_height / lvl->height; - sz = xsz > ysz ? ysz : xsz; - - cidx = cell - lvl->cells; - row = cidx / lvl->width; - col = cidx % lvl->width; - - x = col * sz - view_panx; - y = row * sz - view_pany; - - glColor3f(1, 1, 1); - glVertex2f(x, y); - glVertex2f(x + sz, y); - glVertex2f(x + sz, y + sz); - glVertex2f(x, y + sz); - - x += LTHICK; - y += LTHICK; - sz -= LTHICK * 2.0f; - - glColor3fv(colors[cell->type]); - glVertex2f(x, y); - glVertex2f(x + sz, y); - glVertex2f(x + sz, y + sz); - glVertex2f(x, y + sz); -} - -void draw_level(struct level *lvl) -{ - int i, j; - struct cell *cell; - - glBegin(GL_QUADS); - cell = lvl->cells; - for(i=0; iheight; i++) { - for(j=0; jwidth; j++) { - draw_cell(lvl, cell++); - } - } - glEnd(); -}