X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=tools%2Fdunger%2Fsrc%2Flevel.c;h=582592422bacaa4da6ff863c4548042063495c72;hb=d2306fabd6ad4a568174fe0f17dec0b24c202eac;hp=f61f3f6a36e4c42d00d0fbf6bf2158108a4706fd;hpb=c91209078ac6e61e8543f506b504bca92b7f1a74;p=vrlugburz diff --git a/tools/dunger/src/level.c b/tools/dunger/src/level.c index f61f3f6..5825924 100644 --- a/tools/dunger/src/level.c +++ b/tools/dunger/src/level.c @@ -1,11 +1,8 @@ #include #include #include -#include #include "level.h" -extern int view_width, view_height; - struct level *create_level(int xsz, int ysz) { struct level *lvl; @@ -28,56 +25,3 @@ void free_level(struct level *lvl) free(lvl->cells); free(lvl); } - -static void draw_cell(float x, float y, float sz, struct cell *cell) -{ - static const float colors[][3] = {{0, 0, 0}, {0.6, 0.6, 0.6}, {0.4, 0.2, 0.1}}; - - if(cell) { - glColor3fv(colors[cell->type]); - } else { - glColor3f(1, 1, 1); - } - 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; - float x, y, dx, dy, cellsz; - struct cell *cell; - - dx = view_width / lvl->width; - dy = view_height / lvl->height; - cellsz = dx > dy ? dy : dx; - - glBegin(GL_QUADS); - cell = lvl->cells; - y = 0; - for(i=0; iheight; i++) { - x = 0; - for(j=0; jwidth; j++) { - draw_cell(x, y, cellsz, cell++); - x += cellsz; - } - y += cellsz; - } - glEnd(); - - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - glBegin(GL_QUADS); - y = 0; - for(i=0; iheight; i++) { - x = 0; - for(j=0; jwidth; j++) { - draw_cell(x, y, cellsz, 0); - x += cellsz; - } - y += cellsz; - } - glEnd(); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); -}