Ejemplo n.º 1
0
def draw_player(p_pos):
    x = p_pos[0]
    y = p_pos[1]
    np = [x % 16, y % 8]
    nd = [(x + p_dir[0]) % 16, (y + p_dir[1]) % 8]
    kit.set_pixel(np[0], np[1], colors['player'])
    kit.set_pixel(nd[0], nd[1], colors['heading'])
Ejemplo n.º 2
0
def update():
    global gameOver
    if stage[shooterPosition][0] == 1:
        gameOver = True
    if (t % 240 - score) == 0:
        shift()
    kit.clear()
    renderStage()
    kit.set_pixel(0, shooterPosition, [8, 8, 8])
    kit.render()
Ejemplo n.º 3
0
def draw_treasure_map(p_pos, t_pos):
    kit.clear()
    p_quad = calc_w_pos(p_pos[0], p_pos[1])
    rect(p_quad[0] * 4, p_quad[1] * 2, 4, 2, colors['player'])
    for t in t_pos:
        t_quad = calc_w_pos(t[0], t[1])
        rect(t_quad[0] * 4, t_quad[1] * 2, 4, 2, colors['treasure'])
    for i in range(0, score):
        kit.set_pixel(i % 16, int(i / 16), colors['heading'])
    kit.render()
    sleep(1)
Ejemplo n.º 4
0
def draw_npcs(npcs, w_pos):
    x = w_pos[0]
    y = w_pos[1]
    for npc in npcs:
        npc_quadrant = calc_w_pos(npc[0], npc[1])
        if npc_quadrant[0] == w_pos[0] and npc_quadrant[1] == w_pos[1]:
            np = [npc[0] % 16, npc[1] % 8]
            nd = [(npc[0] + dirs[npc[2]][0]) % 16,
                  (npc[1] + dirs[npc[2]][1]) % 8]
            kit.set_pixel(np[0], np[1], colors['npc'])
            kit.set_pixel(nd[0], nd[1], colors['npc_heading'])
Ejemplo n.º 5
0
def renderStage():
    global stage
    global score
    sum = 0
    for i, row in enumerate(stage):
        for j, value in enumerate(row):
            sum = sum + value
            color = [10 * value] * 3
            kit.set_pixel(j, i, color)
    if sum == 0:
        score = score + 1
        restart()
Ejemplo n.º 6
0
def draw_world(w, x, y):
    for wx in range(0, 16):
        for wy in range(0, 8):
            nx = ((x * 16) + wx + width) % width
            ny = ((y * 8) + wy + height) % height
            d = str(w[nx][ny])
            if d in colors.keys():
                c = colors[d]
                for t in t_pos:
                    if nx == t[0] and ny == t[1]:
                        c = colors['treasure']
            else:
                c = colors['3']
            kit.set_pixel(wx, wy, c)
Ejemplo n.º 7
0
def rect(x, y, width, height, color):
    for h in range(y, y + height):
        for w in range(x, x + width):
            kit.set_pixel(w, h, color)
Ejemplo n.º 8
0
                    t_pos.append(place_treasure(world))
            elif score < 23:
                if len(t_pos) == 0:
                    for i in range(0, 3):
                        t_pos.append(place_treasure(world))
                    n_pos = place_treasure(world)
                    npcs.append([n_pos[0], n_pos[1], 1])
            elif score < 32:
                if len(t_pos) == 0:
                    for i in range(0, 4):
                        t_pos.append(place_treasure(world))
                    for i in range(0, 2):
                        n_pos = place_treasure(world)
                        npcs.append([n_pos[0], n_pos[1], 1])
            else:
                kit.clear()
                while True:
                    kit.set_pixel(random(0, 15), random(
                        0, 7), [random(0, 30),
                                random(0, 30),
                                random(0, 30)])
                    kit.render()
                    sleep(0.01)
            draw_treasure_map(p_pos, t_pos)
    kit.render()
    sleep(0.1)
kit.clear()
for i in range(0, score):
    kit.set_pixel(i % 16, int(i / 16), colors['heading'])
kit.render()
Ejemplo n.º 9
0
 def draw(self):
     kit.set_pixel(int(self.pos[0]), int(self.pos[1]), [20, 20, 20])
Ejemplo n.º 10
0
        else:
            self.radius = radius

    def update(self):
        self.pos[0] += self.vel[0]
        self.pos[1] += self.vel[1]
        if self.pos[0] <= 0 or self.pos[0] >= 15:
            self.vel[0] *= -1
        if self.pos[1] <= 0 or self.pos[1] >= 7:
            self.vel[1] *= -1

    def draw(self):
        kit.set_pixel(int(self.pos[0]), int(self.pos[1]), [20, 20, 20])


balls = [Ball(), Ball()]
for i in range(0, randint(1, 3)):
    balls.append(Ball())
kit.clear()
kit.render()
while playing:
    kit.check_controls()
    for x in range(0, 16):
        for y in range(0, 8):
            c = get_color((x, y))
            kit.set_pixel(x, y, c)
    for ball in balls:
        ball.update()
    kit.render()
    sleep(0.01)
Ejemplo n.º 11
0

hilbert(0.0, 0.0, 8, 0, 0, 8, 3)
kit.clear()
kit.render()


def get_color(i):
    return [
        int(hsv_to_rgb(i, 1, 1)[0] * 20),
        int(hsv_to_rgb(i, 1, 1)[1] * 20),
        int(hsv_to_rgb(i, 1, 1)[2] * 20)
    ]


counter = 0
interval = 0.05
while True:
    for p in h:
        counter += 0.95
        c = get_color((counter % len(h)) / len(h))
        kit.set_pixel(7 - p[0], 7 - p[1], c)
        kit.render()
        sleep(interval)
    for p in h:
        counter += 1
        c = get_color((counter % len(h)) / len(h))
        kit.set_pixel(8 + p[0], p[1], c)
        kit.render()
        sleep(interval)
Ejemplo n.º 12
0
def clearScreen():
    for i in range(0, 16):
        for j in range(0, 8):
            kit.set_pixel(15 - i, j, [10, 10, 10])
        kit.render()
        sleep(0.2)