예제 #1
0
def draw_truba(y, delta):
    x_cor = 510
    # truba1=play.new_image(image='truba.png', x=x_cor, y=y, size=20)
    # truba3=play.new_image(image='truba.png', x=x_cor, y=y+460+delta, angle= 180, size=20)
    
    truba = play.new_box (height = 462, width = 65, x = x_cor, y = y, transparency = 50)
    truba2=play.new_box (height = 462, width = 65, x = x_cor, y = y + 460 + delta, angle = 180, transparency = 50)
    return truba, truba2
예제 #2
0
def trubi_img(y_niz, rast):
    delta = 515
    #truba_niz = play.new_image(image = 'truba_niz.png',size=210,y=y_niz,x=200)
    truba_niz = play.new_box(color='black',
                             y=y_niz,
                             x=500,
                             transparency=50,
                             width=45,
                             height=500)
    truba_niz.status = 1
    #truba_verh = play.new_image(image = 'truba_verh.png',size=290,y=delta + y_niz + rast,x=200)
    truba_verh = play.new_box(color='black',
                              y=delta + y_niz + rast,
                              x=500,
                              transparency=50,
                              width=45,
                              height=530)
    return truba_niz, truba_verh
예제 #3
0
def sdelat_truby(y, delta):
    truba = play.new_box(color='yellow',
                         transparency=50,
                         x=475,
                         y=y,
                         width=75,
                         height=460)
    # truba_image = play.new_image('truba.png', x = truba.x, y = truba.y, size = 25)
    truba_2 = play.new_box(color='yellow',
                           transparency=50,
                           x=475,
                           y=y + 575 + delta,
                           angle=180,
                           width=75,
                           height=460)
    # truba_2_image = play.new_image('truba.png', x = truba_2.x, y = truba_2.y, size = 25)
    # truba = play.new_image('My space pipe_1.png',  x = 475, y = y, size = 250)
    # truba_2 = play.new_image('My space pipe_2.png', x = 475, y = y + 575 + delta, angle = 180,  size = 250)
    return truba, truba_2
예제 #4
0
def add_to_body():
    """Добавляем в список новый кусочек тела"""
    global body

    if len(body) > 0:
        x, y = body[-1].x, body[-1].y
    else:
        x, y = had.x, had.y
    body.append(
        play.new_box(color='light green', x=x, y=y, width=19, height=19,
                     border_color="light blue", border_width=1)
    )
def draw_platforms():
    global finish
    platform1 = play.new_box(
        color = 'brown', border_width= 1, border_color= 'black', width = 150, height = 30, x = play.screen.left + 70, y = play.screen.top-170
    )
    platforms.append(platform1)

    platform2 = play.new_box(
        color = 'brown', border_width= 1, border_color= 'black', width = 250, height = 30, x = play.screen.left + 330, y = play.screen.top-150
    )
    platforms.append(platform2)

    platform3 = play.new_box(
        color = 'brown', border_width= 1, border_color= 'black', width = 100, height = 30, x = play.screen.left + 550, y = play.screen.top-150
    )
    platforms.append(platform3)
    
    platform4 = play.new_box(
        color = 'brown', border_width= 1, border_color= 'black', width = 130, height = 30, x = play.screen.left + 670, y = play.screen.top-170
    )
    platforms.append(platform4)

    platform5 = play.new_box(
        color = 'brown', border_width= 1, border_color= 'black', width = 150, height = 30, x = play.screen.left + 80, y = play.screen.top-300
    )
    platforms.append(platform5)

    platform6 = play.new_box(
        color = 'brown', border_width= 1, border_color= 'black', width = 250, height = 30, x = play.screen.left + 340, y = play.screen.top-280
    )
    platforms.append(platform6)

    platform7 = play.new_box(
        color = 'brown', border_width= 1, border_color= 'black', width = 100, height = 30, x = play.screen.left + 560, y = play.screen.top-300
    )
    platforms.append(platform7)
    
    platform8 = play.new_box(
        color = 'brown', border_width= 1, border_color= 'black', width = 130, height = 30, x = play.screen.left + 700, y = play.screen.top-260
    )
    platforms.append(platform8)

    finish  = play.new_circle(color = 'red', x = platform5.x, y = platform5.y + 45,radius = 20, border_color= 'black', border_width=2)

    for platform in platforms:
        platform.start_physics(can_move=False, stable=True, obeys_gravity=True, mass = 10)
예제 #6
0
def start():
    # платформа не поддается гравитации и управляется только с клавиатуры
    platform.start_physics(stable=True,
                           obeys_gravity=False,
                           bounciness=1,
                           mass=1)
    # шарик не поддается гравитации, случайно перемещается по полю
    ball.start_physics(
        ball.start_physics(stable=False,
                           x_speed=35,
                           y_speed=35,
                           obeys_gravity=False,
                           bounciness=1,
                           mass=10))

    # генерация блоков
    block_x = play.screen.left + 75
    block_y = play.screen.top - 50

    for i in range(3):  # количество рядов
        while block_x <= play.screen.right - 30:
            # for i in range(8):
            block = play.new_box(color='grey',
                                 x=block_x,
                                 y=block_y,
                                 width=110,
                                 height=30,
                                 border_color='dark grey',
                                 border_width=1)
            blocks.append(block)
            block_x = block_x + block.width
        block_x = play.screen.left + 75
        block_y = block.y - block.height

    # for i in range(len(blocks)):
    # blocks[i].show()

    platform.show()
    lose.hide()
    win.hide()
예제 #7
0
    def __init__(self, image_name, position, game_map, size):
        self.image_name = image_name
        self.position = position
        self.game_map = game_map
        self.image = play.new_image(image=image_name, x=position[0], y=position[1], size=size)

        self.up = play.new_box(color="red", x=position[0], y=position[1] + self.image.height/2 + dist_const, width=self.image.width * close_length_const, height=1)
        self.right = play.new_box(color="red", x=position[0] + self.image.width/2 + dist_const, y=position[1], width=1, height=self.image.height * close_length_const)
        self.left = play.new_box(color="red", x=position[0] - self.image.width/2 - dist_const, y=position[1], width=1, height=self.image.height * close_length_const)
        self.down = play.new_box(color="red", x=position[0], y=position[1] - self.image.height/2 - dist_const, width=self.image.width * close_length_const, height=1)

        #self.up.hide()
        #self.right.hide()
        #self.left.hide()
        #self.down.hide()

        self.far_up = play.new_box(color="green", x=position[0], y=position[1] + self.image.height / 2 + far_dist_const,
                               width=self.image.width*far_length_const, height=1)
        self.far_right = play.new_box(color="green", x=position[0] + self.image.width / 2 + far_dist_const, y=position[1], width=1,
                                  height=self.image.height*far_length_const)
        self.far_left = play.new_box(color="green", x=position[0] - self.image.width / 2 - far_dist_const, y=position[1], width=1,
                                 height=self.image.height*far_length_const)
        self.far_down = play.new_box(color="green", x=position[0], y=position[1] - self.image.height / 2 - far_dist_const,
                                 width=self.image.width*far_length_const, height=1)
예제 #8
0
import play
from random import randint

play.set_backdrop((185, 119, 233))

status = 5

start_kub = play.new_box(color='red', height=40, width=100)
start_knopka = play.new_text('Start')

podzkazka_dlia_ne_ochen_umnih = play.new_text('Извольте нажать SPACE !',
                                              color='red',
                                              y=-250)
podzkazka_dlia_ne_ochen_umnih.hide()

restart_kub = play.new_box(color='red', height=40, width=130, y=-70)
restart_knopka = play.new_text('Restart', y=-70)
restart_knopka.hide()
restart_kub.hide()


@play.repeat_forever
def restart999():
    global status
    if status == 5:
        status = 3

        # bird_kub = play.new_box(color='black',transparency=0,width=32,height=25)
        # bird = play.new_image(image = 'bird_1.png',size=140,x=0)
        # bird_kub.start_physics(can_move=True,obeys_gravity=True,stable=True,y_speed = 0)
예제 #9
0
import pygame
import play

#вариант домашнего задания - дать список файлов с инструментами и попросить сделать другой набор

# интерфейс - подсказки, кнопки управления:
play.set_backdrop('light blue')
introduce1 = play.new_text(words='Piano for fun!', x=0, y=200)
introduce2 = play.new_text(words='Create your melody by pressing the keys',
                           x=0,
                           y=150)

key_play_melody = play.new_box(color='light green',
                               border_color='black',
                               border_width=1,
                               x=-100,
                               y=-170,
                               width=160,
                               height=50)
kpm = play.new_text(words='play melody', x=-100, y=-170, font_size=20)

key_clear_melody = play.new_box(color='light yellow',
                                border_color='black',
                                border_width=1,
                                x=100,
                                y=-170,
                                width=160,
                                height=50)
kcm = play.new_text(words='clear melody', x=100, y=-170, font_size=20)

# клавиши и звуки для них:
예제 #10
0
    def is_ready(self):
        return self.ready


# интерфейс - подсказки, кнопки управления:
play.set_backdrop('light blue')
introduce1 = play.new_text(words='Piano for fun!', x=0, y=250)
introduce2 = play.new_text(words='Create your melody by pressing the keys',
                           x=0,
                           y=200)

key_play_melody = play.new_box(color='light green',
                               border_color='black',
                               border_width=1,
                               x=-140,
                               y=-80,
                               width=120,
                               height=50)
kpm = play.new_text(words='play melody', x=-140, y=-80, font_size=20)

key_repeat_melody = play.new_box(color='light yellow',
                                 border_color='black',
                                 border_width=1,
                                 x=-5,
                                 y=-80,
                                 width=120,
                                 height=50)
krm = play.new_text(words='repeat melody', x=-5, y=-80, font_size=20)

key_clear_melody = play.new_box(color='light pink',
예제 #11
0
            dots.remove(dots[i])

fruit.append(
    Item("images/Fruit.png", [-257 + 0 * 28.542, -257 + 29 * 28.542], "fruit"))
fruit.append(
    Item("images/Fruit.png", [-257 + 29 * 28.542, -257 + 29 * 28.542],
         "fruit"))
fruit.append(
    Item("images/Fruit.png", [-257 + 29 * 28.542, -257 + 0 * 28.542], "fruit"))
fruit.append(
    Item("images/Fruit.png", [-257 + 0 * 28.542, -257 + 0 * 28.542], "fruit"))

ghost_sprites = [
    play.new_box(color="red",
                 width=7,
                 height=7,
                 x=-257,
                 y=-273,
                 transparency=1),
    play.new_box(color="pink",
                 width=7,
                 height=7,
                 x=-257,
                 y=273,
                 transparency=1),
    play.new_box(color="cyan",
                 width=7,
                 height=7,
                 x=252,
                 y=-273,
                 transparency=1),
    play.new_box(color="orange",
예제 #12
0
# fon = play.new_image(
#         image='labirint.jpeg',
#         x=0, y=0, angle=0, size=60,
#         transparency=100
#     )

# todo скорректировать координаты линий и длины - убрать хвосты
lines = [
    play.new_line(color='blue', **args, thickness=8, x1=None, y1=None)
    for args in param_lines
]

box = play.new_box(color='black',
                   x=-240,
                   y=240,
                   width=30,
                   height=30,
                   border_color="light blue",
                   border_width=1)

timer_title = play.new_text(words='TIME:',
                            font=None,
                            font_size=40,
                            color='blue',
                            x=-350,
                            y=280,
                            angle=0,
                            size=100,
                            transparency=100)
timer_display = play.new_text(words='00:00',
                              font=None,
예제 #13
0
# print(play.screen.width, play.screen.height)  # получаем размер экрана

# Переменные конфиг
speed = 0.5
run = True
y_top = 290
y_bottom = -290
x_right = 390
x_left = -390
score = 0
timer = 10
time_for_rock = 15


apple = play.new_box(color='red', x=play.random_number(-19, 19) * 20,
                     y=play.random_number(-14, 14) * 20, width=19, height=19,
                     border_color="yellow", border_width=1)

super_apple = play.new_box(color='yellow', x=-400, y=-300, width=19, height=19,
                           border_color="red", border_width=1)
super_apple.hide()

# Тело змейки
body = []

had = play.new_box(color='green', x=0, y=0, width=19, height=19,
                   border_color="light blue", border_width=1)

rock = play.new_box(color='grey', x=play.random_number(-19, 19) * 20,
                    y=play.random_number(-14, 14) * 20, width=19, height=19,
                    border_color="black", border_width=1)
예제 #14
0
import play

# ЭКРАН
frames = 45  # частота кадров
lose = play.new_text(words='YOU LOSE', font_size=100, color='red')
win = play.new_text(words='YOU WIN', font_size=100, color='yellow')
platform = play.new_box(color='brown', y=-250, width=150, height=15)

ball = play.new_circle(color='green', y=-160, radius=15)
blocks = []

# count = play.new_text(words = '0', x = 200, y = -150, font = None, font_size = 30)
# count_text = play.new_text(words='Количество неудачных попыток: ', x = 0, y = -150, font = None, font_size = 30)


@play.when_program_starts
def start():
    # платформа не поддается гравитации и управляется только с клавиатуры
    platform.start_physics(stable=True,
                           obeys_gravity=False,
                           bounciness=1,
                           mass=1)
    # шарик не поддается гравитации, случайно перемещается по полю
    ball.start_physics(
        ball.start_physics(stable=False,
                           x_speed=35,
                           y_speed=35,
                           obeys_gravity=False,
                           bounciness=1,
                           mass=10))
예제 #15
0
#         # self.line3 = play.new_line(x=self.x, y=self.y, length=100, angle=-45)
#         # self.lines = [self.line1, self.line2, self.line3]
#         self.position = Vector2(self.x, self.y)
#         self.line.start_physics(can_move=True, stable=True, obeys_gravity=False)
#         # for line in self.lines:
#         #     line.start_physics(stable=True, bounciness=0, friction=100, obeys_gravity=False)
#         #     print(line.x, line.y)
#
#     def update(self, position, angle):
#         self.line.x = position.x * 2
#         self.line.y = position.y
#         self.angle = angle + 45


platform = Car(color='brown', x=100, y=-250, width=150, height=55)
platform2 = play.new_box()


@play.when_program_starts
def start():
    platform.start_physics(
        can_move=True, stable=True, obeys_gravity=False
    )
    platform.show()
    # line1 = play.new_line(x=10, y=10, length=600, angle=45)
    platform2.start_physics(can_move=True, stable=True, obeys_gravity=False)
    platform2.show()


@play.repeat_forever
def game():
예제 #16
0
frames = 48

# задание спрайта
player = play.new_circle(color='green',
                         x=0,
                         y=-270,
                         radius=20,
                         border_color='light green')
q1 = play.new_text(words='YOU WIN!',
                   x=0,
                   y=0,
                   font=None,
                   font_size=100,
                   color='yellow')
# задание препятствий
wall1 = play.new_box(color='black', x=0, y=0, width=100, height=10)
wall2 = play.new_box(color='black', x=-50, y=10, width=10, height=100)
wall3 = play.new_box(color='black', x=50, y=-10, width=10, height=100)
wall4 = play.new_box(color='black', x=100, y=-110, width=10, height=100)
wall5 = play.new_box(color='black', x=145, y=-160, width=100, height=10)
wall6 = play.new_box(color='black', x=-145, y=-150, width=100, height=10)
wall7 = play.new_box(color='black', x=-175, y=-200, width=300, height=10)
wall8 = play.new_box(color='black', x=-195, y=-50, width=10, height=300)
wall9 = play.new_box(color='black', x=-300, y=10, width=200, height=10)
wall10 = play.new_box(color='black', x=-300, y=-40, width=10, height=100)
wall11 = play.new_box(color='black', x=-290, y=100, width=200, height=10)
wall12 = play.new_box(color='black', x=290, y=100, width=200, height=10)
wall13 = play.new_box(color='black', x=100, y=50, width=10, height=300)
wall14 = play.new_box(color='black', x=0, y=100, width=150, height=10)
wall15 = play.new_box(color='black', x=-130, y=100, width=10, height=300)
        color = 'yellow', x = play.screen.left + 340, y = play.screen.top - 230, radius = 10
    )
    coins.append(coin3)
    coin4 = play.new_circle(
        color = 'yellow', x = play.screen.left + 700, y = play.screen.top - 230, radius = 10
    )
    coins.append(coin4)

score_txt = play.new_text(words='Score:', x=play.screen.right-100, y=play.screen.top-30, size=70)
score_num = 0
score = play.new_text(words=str(score_num), x=play.screen.right-30, y=play.screen.top-30, size=70)

text = play.new_text(words='Tap SPACE to jump, a/d to move', x=0, y=play.screen.bottom+60, size=70)

sea = play.new_box(
        color='blue', width=play.screen.width, height=50, x=0, y=play.screen.bottom+20
    )

@play.when_program_starts
def start():
    pygame.mixer_music.load('soundtrack.mp3')
    pygame.mixer_music.play()

    sprite.start_physics(can_move= True, stable = False, obeys_gravity=True, mass =50, friction=1.0, bounciness=0.5)

    draw_platforms()
    draw_coins()

@play.repeat_forever
async def game():
    global score
예제 #18
0
def start_program():
    global status
    if status == 4:
        if play.key_is_pressed('space'):
            podzkazka_dlia_ne_ochen_umnih.hide()

            status = 2

            bird_kub = play.new_box(color='black',
                                    transparency=0,
                                    width=32,
                                    height=25)
            bird = play.new_image(image='bird_1.png', size=140, x=0)

            bird_kub.start_physics(can_move=True,
                                   obeys_gravity=True,
                                   stable=True,
                                   y_speed=0)

            bird_kub.y += 10
    if status == 2:

        global n
        n = 0

        status = 1

        chet = play.new_text(str(n), y=-30)
        chet.hide()

        # trubi_img(-200,100)

        trubi_list = []

        lose = play.new_text('YOU LOSE', color='red')
        lose.hide()

        @play.repeat_forever
        def keypads():
            if play.key_is_pressed('space'):
                bird_kub.y += 10

        @play.repeat_forever
        async def do():
            global status
            if status == 1:
                a = trubi_img(randint(-500, -200), 150)
                trubi_list.append(a)
                await play.timer(3)
            else:
                for tum in trubi_list:
                    tum[1].remove()
                    tum[0].remove()
                    trubi_list.remove(tum)

        @play.repeat_forever
        async def run():
            for i in trubi_list:
                i[0].x -= 5
                i[1].x -= 5
                if i[0].x < -500:
                    i[0].remove()
                    i[1].remove()
                    trubi_list.remove(i)

            await play.timer(1 / 40)

        @play.repeat_forever
        def touch():
            global status
            if status == 1:
                if bird_kub.y < -280:
                    bird_kub.stop_physics()
                    bird_kub.hide()
                    bird.remove()
                    lose.show()
                    chet.show()
                    restart_knopka.show()
                    restart_kub.show()
                    status = 0
                elif status == 1:
                    for truba in trubi_list:
                        if truba[0].is_touching(
                                bird_kub) or truba[1].is_touching(bird_kub):
                            bird_kub.stop_physics()
                            bird_kub.hide()
                            bird.remove()
                            lose.show()
                            chet.show()
                            restart_knopka.show()
                            restart_kub.show()
                            status = 0

            bird.y = bird_kub.y

        @play.repeat_forever
        def chets():
            global n
            global status
            if status == 1:
                for tr in trubi_list:
                    if bird_kub.x > tr[1].x and tr[0].status == 1:
                        tr[0].status = 0
                        n = n + 1

                        chet.words = str(n)

        @restart_kub.when_clicked
        def restart():
            global status
            restart_kub.hide()
            restart_knopka.hide()
            status = 5
            start_knopka.show()
            start_kub.show()
            lose.hide()
            chet.words.hide()
            for tumka in trubi_list:
                tumka[0].remove()
                tuka[1].remove()
                trubi_list.remove(tumka)
#начало игры
import play
from random import randint

w = play.screen.width
h = play.screen.height

#создание объектов для внешнего интерфейса
place1 = play.new_box(color='light green',
                      x=0,
                      y=0,
                      width=100,
                      height=200,
                      border_width=5,
                      border_color='green')
place2 = play.new_box(color='light green',
                      x=0,
                      y=0,
                      width=100,
                      height=200,
                      border_width=5,
                      border_color='green')
place3 = play.new_box(color='light green',
                      x=0,
                      y=0,
                      width=100,
                      height=200,
                      border_width=5,
                      border_color='green')
hello = play.new_text(words='Привет! Нажми на кнопку, чтобы испытать удачу!',
                      x=0,
예제 #20
0
                           friction=0)
        box4 = play.new_image(image=box_img,
                              x=play.screen.left + j,
                              y=play.screen.top - 8)
        box4.start_physics(can_move=True,
                           obeys_gravity=False,
                           stable=True,
                           friction=0)
        wall_list.append(box2)
        wall_list.append(box4)
        j += 40
    i += 40

sprite_box = play.new_box(color='black',
                          x=0,
                          y=53,
                          width=17,
                          height=40,
                          transparency=100)

sprite = play.new_image(image=k_sprite[number_k], x=1000, y=50, size=20)

heli = play.new_image(image=k_heli[number], x=1000, y=50, size=600)

lava = play.new_image(image=k_lava[number], x=600, y=-269, size=600)
# tree = play.new_image('./img/tree.png', size=300, x=200, y=-200)

wall1.start_physics(can_move=True,
                    obeys_gravity=False,
                    stable=True,
                    friction=0)
wall2.start_physics(can_move=True,
예제 #21
0
import play

play.set_backdrop("darkorange")

#circle
ball = play.new_circle(x=-300, y=-250, radius=20, color="green")
#walls
wall1 = play.new_box(x=-300, y=0, width=200, height=10, color="black")
wall2 = play.new_box(x=-100, y=0, width=200, height=10, color="black")
wall3 = play.new_box(x=-200, y=100, width=10, height=200, color="black")
wall4 = play.new_box(x=200, y=-100, width=10, height=200, color="black")
wall5 = play.new_box(x=300, y=-200, width=200, height=10, color="black")
wall6 = play.new_box(x=100, y=-200, width=200, height=10, color="black")
wall7 = play.new_box(x=300, y=200, width=200, height=10, color="black")
wall8 = play.new_box(x=100, y=200, width=200, height=10, color="black")
wall9 = play.new_box(x=-400, y=-200, width=150, height=10, color="black")
wall10 = play.new_box(x=-250, y=-200, width=150, height=10, color="black")
wall11 = play.new_box(x=0, y=20, width=10, height=50, color="black")
wall12 = play.new_box(x=0, y=40, width=10, height=50, color="black")
#text
finish = play.new_text(words="FINISH",
                       x=-300,
                       y=50,
                       font=None,
                       font_size=70,
                       color="green")
#-------------------------------


@play.when_program_starts
def start():
예제 #22
0
import play
from random import randint

frames = 48  # что делает эта переменная

RIGHT = play.screen.width / 2  # что делает эта переменная (как считается и назначение)
LEFT = -1 * RIGHT
TOP = play.screen.height / 2
BOTTOM = -1 * TOP
R_SIZE = 100
B_SIZE = 10

ball = play.new_circle(color='green', x=0, y=0, radius=B_SIZE)
l_racket = play.new_box(color='black',
                        x=LEFT + 10,
                        y=0,
                        width=20,
                        height=R_SIZE)
r_racket = play.new_box(color='red',
                        x=RIGHT - 10,
                        y=0,
                        width=20,
                        height=R_SIZE)


@play.when_program_starts  # "раздел программы"
def start():
    l_racket.start_physics(stable=True,
                           obeys_gravity=False,
                           bounciness=1,
                           mass=1)
예제 #23
0
import play

# интерфейс - подсказки, кнопки управления:
play.set_backdrop('light blue')
introduce1 = play.new_text(words='Piano for fun!', x=0, y=200)
introduce2 = play.new_text(words='Create your melody by pressing the keys',
                           x=0,
                           y=150)

# клавиши и звуки для них:
keys = []

for i in range(8):
    key_x = -180 + i * 50  # 40 - ширина клавиши, 10 - расстояние между ними
    key = play.new_box(color='white',
                       border_color='black',
                       border_width=3,
                       x=key_x,
                       y=0,
                       width=40,
                       height=100)
    keys.append(key)

play.start_program()