from math import * from random import * from random import randint as RAND from kandinsky import * from kandinsky import fill_rect as FILL from kandinsky import draw_string as STR from ion import * from time import sleep RED = (255, 0, 0) GREEN = (0, 255, 0) BLUE = (0, 0, 255) BLACK = (0, 0, 0) WHITE = (255,) * 3 CYAN = (0, 255, 255) YELLOW = (255, 255, 0) S_WIDTH = 320 S_HEIGHT = 222 rect_w = 20 rect_h = 20 rect_c = RED center_x = S_WIDTH // 2 center_y = S_HEIGHT // 2 radius = 50 angle = 0 angular_speed = 0.02 gx = 0 gy = 170 gw = S_WIDTH gh = 6 gc = WHITE lavax = 0 lavay = RAND(200, 218) lavaw = 322 lavah = 30 lavac = RED px = 40 pw = 12 ph = 22 py = gy - ph + 1 pc = BLUE pskin = WHITE pe = 45 game = True bg = (RAND(0, 80), RAND(0, 80), RAND(0, 80)) FILL(0, 0, S_WIDTH, S_HEIGHT, bg) FILL(gx, gy, gw, gh, gc) while game: FILL(15, 5, int(pe), 8, (255, 0, 0)) x = center_x + int(radius * cos(angle)) y = center_y + int(radius * sin(angle)) FILL(px, py, pw, ph, pc) FILL(px, py, 1, ph, pskin) FILL(px + pw - 1, py, 1, ph, pskin) FILL(px, py, pw, 1, pskin) FILL(px, py + ph - 1, pw, 1, pskin) FILL(x - rect_w // 2, y - rect_h // 2, rect_w, rect_h, rect_c) FILL((x - rect_w // 2) + 3, (y - rect_h // 2) + 3, rect_w - 6, rect_h - 6, (RAND(50, 255), 0, 0)) if px < x + rect_w // 2 and px + pw > x - rect_w // 2 and py < y + rect_h // 2 and py + ph > y - rect_h // 2: pe -= 10 px = 40 angle += angular_speed sleep(0.01) FILL(x - (rect_w // 2) - 1, y - (rect_h // 2) - 1, rect_w + 2, rect_h + 2, bg) if keydown(KEY_LEFT): FILL(px + pw + 1, py, 1, ph, bg) px -= 1 if keydown(KEY_TOOLBOX): FILL(px + pw, py, 2, ph, bg) FILL(15 + int(pe), 5, 1, 8, bg) px -= 2 pe -= 0.8 if keydown(KEY_RIGHT): FILL(px - 1, py, 1, ph, bg) px += 1 if keydown(KEY_TOOLBOX): FILL(px - 2, py, 3, ph, bg) FILL(15 + int(pe), 5, 1, 8, bg) px += 2 pe -= 0.8 if px + pw < 0: px = S_WIDTH if px > S_WIDTH: px = -pw if keydown(KEY_UP) or keydown(KEY_OK) and pe > 0: FILL(15 + int(pe), 5, 1, 8, bg) FILL(px, py + ph, pw, 1, bg) py -= 1 pe -= 0.4 else: py += 1 if not keydown(KEY_UP) and not keydown(KEY_OK): FILL(px, py - 1, pw, 1, bg) if py + ph - 1 > gy: py = gy - ph + 1 if keydown(KEY_DOWN) and py + ph >= gy: ph = 10 FILL(px, py, pw, ph, bg) sleep(0.01) py = gy - ph else: ph = 22 pe += 0.05 if pe > 55: pe = 55 if pe < 0: pe = 0 game = False FILL(lavax, lavay, lavaw, lavah, lavac) FILL(lavax + 2, lavay + 5, lavaw - 4, lavah, (RAND(150, 255), 0, 0)) STR("E", 2, 2, GREEN, bg) bg = BLACK FILL(0, 0, S_WIDTH, S_HEIGHT, bg) STR("GAME OVER", 100, 100, RED, BLACK)