static void compute_stars_position (int last_room, int room) { struct pos p; p.room = room; int i, min_x = INT_MAX, min_y = INT_MAX, max_x = INT_MIN, max_y = INT_MIN; for (p.floor = FLOORS; p.floor >= -1; p.floor--) for (p.place = -1; p.place < PLACES; p.place++) { struct stars_bitmap *sb = &stars_bitmap[p.floor + 1][p.place + 1]; if (sb->b) { al_destroy_bitmap (sb->b); sb->b = NULL; } if (con (&p)->bg != BALCONY) continue; for (i = 0; i < STARS; i++) { struct star *s = &star[p.floor + 1][p.place + 1][i]; star_coord (&p, i, s); min_x = min_int (min_x, s->x); min_y = min_int (min_y, s->y); max_x = max_int (max_x, s->x); max_y = max_int (max_y, s->y); s->color = next_color (s->color); } sb->b = create_bitmap (max_x - min_x + 1, max_y - min_y + 1); clear_bitmap (sb->b, TRANSPARENT_COLOR); sb->c.room = room; sb->c.x = min_x; sb->c.y = min_y; redraw_stars_bitmap (star[p.floor + 1][p.place + 1], sb, STARS, vm); } }
void generate_stars_for_pos (struct pos *p) { struct pos np; npos (p, &np); int x, y; if (! mr_coord (np.room, -1, &x, &y)) return; struct stars *stars = &mr.cell[x][y].stars[np.floor][np.place]; destroy_bitmap (stars->b); stars->b = NULL; if (stars->s) al_free (stars->s); stars->s = NULL; stars->count = 0; if (con (&np)->bg != BALCONY) return; stars->count = 3 + prandom_pos (&np, 5); stars->s = xcalloc (stars->count, sizeof (* stars->s)); int i, min_x = INT_MAX, min_y = INT_MAX, max_x = INT_MIN, max_y = INT_MIN; for (i = 0; i < stars->count; i++) { struct star *s = &stars->s[i]; star_coord (&np, i, s); min_x = min_int (min_x, s->x); min_y = min_int (min_y, s->y); max_x = max_int (max_x, s->x); max_y = max_int (max_y, s->y); s->color = next_color (s->color); } stars->b = create_bitmap (max_x - min_x + 1, max_y - min_y + 1); clear_bitmap (stars->b, TRANSPARENT_COLOR); new_coord (&stars->c, np.l, np.room, min_x, min_y); redraw_stars_bitmap (stars, vm); }