void set_badguys(int y, int x) { int startx = x; int tempx, tempy; while(y>bgSet.starty) { while(x!=75) { if(bgSet.coords[x][y]!=-1) { pthread_mutex_lock(&mutex); bgSet.coords[x][y] = 1; pthread_mutex_unlock(&mutex); } x+=5; } y-=4; x = startx; } bgSet.starty+=1; draw_badguys(); }
/* draws the entire view */ void draw_view() { int SCREEN_W = al_get_display_width(); int SCREEN_H = al_get_display_height(); int (*project)(float *f, int *i, int c); int r, g, b; ALLEGRO_COLOR c; int i, n, x, y; float point[6]; int ipoint[6]; al_clear_to_color(makecol(0, 0, 0)); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ONE, al_map_rgba_f(1, 1, 1, 1)); for (i=0; i<4; i++) { view_left = viewinfo[i].pos[0] * SCREEN_W; view_top = viewinfo[i].pos[1] * SCREEN_H; view_right = viewinfo[i].pos[2] * SCREEN_W; view_bottom = viewinfo[i].pos[3] * SCREEN_H; if ((view_right > view_left) && (view_bottom > view_top) && (view_right > 0) && (view_bottom > 0) && (view_left < SCREEN_W) && (view_top < SCREEN_H)) { switch (i) { case 0: /* flat projection, green */ project = project_flat; r = 0; g = 255; b = 0; break; case 1: /* spherical coordinates, yellow */ project = project_spherical; r = 255; g = 255; b = 0; break; case 2: /* inside a tube, blue */ project = project_tube; r = 0; g = 0; b = 255; break; case 3: /* surface of cylinder, red */ project = project_cylinder; r = 255; g = 0; b = 0; break; default: /* oops! */ assert(FALSE); return; } if (!no_grid) { c = makecol(r/5, g/5, b/5); n = (low_detail) ? 8 : 16; for (x=0; x<=n; x++) { for (y=0; y<=n; y++) { point[0] = (float)x / n; point[1] = (float)y / n; point[2] = (float)(x+1) / n; point[3] = (float)y / n; point[4] = (float)x / n; point[5] = (float)(y+1) / n; if (project(point, ipoint, 6)) { if (x < n) line(ipoint[0], ipoint[1], ipoint[2], ipoint[3], c); if ((y < n) && ((x < n) || (i == 0))) line(ipoint[0], ipoint[1], ipoint[4], ipoint[5], c); } } } } draw_player(r, g, b, project); draw_badguys(r, g, b, project); draw_bullets(r, g, b, project); draw_explode(r, g, b, project); } } solid_mode(); draw_message(); textprintf(font, 4, 4, makecol(128, 128, 128), "Lives: %d", lives); textprintf(font, 4, 16, makecol(128, 128, 128), "Score: %d", score); textprintf(font, 4, 28, makecol(128, 128, 128), "Hiscore: %d", get_hiscore()); al_flip_display(); }