void WorldWeather::step() { time++; if (time > time_per_day) { time = time - time_per_day; } if (time % time_update == 0) { update_sky(); } }
void draw_map_with_buff_offset(min_block_type *map, int buff_off_x, int buff_off_y, int buffer_w, int buffer_h, int vx, int vy) { #define GET_BLOCK_FROM_THIS(x, y) GET_BLOCK_FROM_BUFFER(map, x, y, buff_off_x, buff_off_y, buffer_w, buffer_h) update_sky(); SDL_FillRect(surface, NULL, 0xFFFFFFFF); for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { min_block_type cb = GET_BLOCK_FROM_THIS(j, i); if (cb == BLCK_AIR) { int pu = GET_BLOCK_FROM_THIS(j - 1, i) != BLCK_AIR; int pl = GET_BLOCK_FROM_THIS(j, i - 1) != BLCK_AIR; int plu = GET_BLOCK_FROM_THIS(j - 1, i - 1) != BLCK_AIR; draw_block(cb, j, i, vx + j, vy + i, w, h, s_b_shadows[pu][plu][pl]); } else { draw_block(cb, j, i, vx + j, vy + i); } } } for(int i = 0; i < FLASHBACK_MAX; i++) { if((flashbacks[i].frames_left > 0) && (flashbacks[i].x >= vx) && (flashbacks[i].x < (vx + w)) && (flashbacks[i].y >= vy) && (flashbacks[i].y < (vy + h))) { if (flashbacks[i].inf == BLCK_AIR) { int pu = GET_BLOCK_FROM_THIS(flashbacks[i].x - vx - 1, flashbacks[i].y - vy) != BLCK_AIR; int pl = GET_BLOCK_FROM_THIS(flashbacks[i].x - vx, flashbacks[i].y - vy - 1) != BLCK_AIR; int plu = GET_BLOCK_FROM_THIS(flashbacks[i].x - vx - 1, flashbacks[i].y - vy - 1) != BLCK_AIR; draw_block(flashbacks[i].inf, flashbacks[i].x - vx, flashbacks[i].y - vy, flashbacks[i].x, flashbacks[i].y, w, h, s_b_shadows[pu][plu][pl]); } else { draw_block(flashbacks[i].inf, flashbacks[i].x - vx, flashbacks[i].y - vy, flashbacks[i].x, flashbacks[i].y); } // flashbacks[i].frames_left--; } } ui_redraw_needed = false; #undef GET_BLOCK_FROM_THIS }
void draw_map(min_block_type *map, int vx, int vy) { update_sky(); SDL_FillRect(surface, NULL, 0xFFFFFFFF); for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { draw_block(map[i * w + j], j, i, vx + j, vy + i); } } for(int i = 0; i < FLASHBACK_MAX; i++) { if(flashbacks[i].frames_left > 0) { draw_block(flashbacks[i].inf, flashbacks[i].x, flashbacks[i].y, vx + flashbacks[i].x, vy + flashbacks[i].y); flashbacks[i].frames_left--; } } ui_redraw_needed = false; }