#include "background.h" #include #include #include "astronomy.h" #include "colors.h" #include "gfx/gfx.h" #define GROUND_LEVEL (LCD_HEIGHT * 5 / 6) #define WINDOW_SIZE 50 #define WINDOW_X (LCD_WIDTH - WINDOW_SIZE - 20) #define WINDOW_Y 20 #define NUM_STARS 19 uint8_t star_x[NUM_STARS]; uint8_t star_y[NUM_STARS]; void gen_stars(void) { for(uint8_t i = 0; i < NUM_STARS; i++) { star_x[i] = randInt(1, WINDOW_SIZE - 2); star_y[i] = randInt(1, WINDOW_SIZE - 2); } } void draw_background(time_t time, bool lamp_on) { gfx_SetColor(WALL_COLOR); gfx_FillRectangle_NoClip(0, 0, LCD_WIDTH, GROUND_LEVEL); gfx_SetColor(FLOOR_COLOR); gfx_FillRectangle_NoClip(0, GROUND_LEVEL, LCD_WIDTH, LCD_HEIGHT - GROUND_LEVEL); if(lamp_on) { gfx_SetColor(LAMP_COLOR); gfx_FillTriangle_NoClip(LCD_WIDTH / 2, LCD_HEIGHT / 3, LCD_WIDTH / 3, GROUND_LEVEL, LCD_WIDTH * 2/3, GROUND_LEVEL); // todo: maybe use a parallelogram here to show the light on the ground? } else { gfx_SetColor(BLACK); gfx_FillCircle_NoClip(LCD_WIDTH / 2, LCD_HEIGHT / 3, 3); } gfx_SetColor(BLACK); gfx_FillRectangle_NoClip(LCD_WIDTH / 2 - 10, LCD_HEIGHT / 3 - 4, 20, 4); gfx_VertLine(LCD_WIDTH / 2, 0, LCD_HEIGHT / 3 - 4); // Window gfx_palette[SKY_COLOR] = get_sky_color(time); gfx_SetColor(FLOOR_COLOR); gfx_FillRectangle_NoClip(WINDOW_X - 3, WINDOW_Y - 3, WINDOW_SIZE + 6, WINDOW_SIZE + 6); gfx_SetColor(SKY_COLOR); gfx_FillRectangle_NoClip(WINDOW_X, WINDOW_Y, WINDOW_SIZE, WINDOW_SIZE); gfx_SetColor(FLOOR_COLOR); gfx_HorizLine(WINDOW_X, WINDOW_Y + WINDOW_SIZE / 2, WINDOW_SIZE); gfx_VertLine(WINDOW_X + WINDOW_SIZE / 2, WINDOW_Y, WINDOW_SIZE); // Stars if(last_solar_time(NIGHT_END, time) < last_solar_time(NIGHT_START, time)) { gfx_SetColor(WHITE); for(uint8_t i = 0; i < NUM_STARS; i++) { gfx_SetPixel(WINDOW_X + star_x[i], WINDOW_Y + star_y[i]); } } gfx_TransparentSprite(chicken, 15, GROUND_LEVEL - chicken_height + 6); gfx_TransparentSprite(nest, 13, GROUND_LEVEL - 2); }