예제 #1
0
def do():
    spaceship.physics.y_speed = 0
    spaceship.physics.x_speed = 0

    if play.key_is_pressed('w'):
        spaceship.physics.y_speed = 15
    if play.key_is_pressed('s'):
        spaceship.physics.y_speed = -15
    if play.key_is_pressed('a'):
        spaceship.physics.x_speed = -15
    if play.key_is_pressed('d'):
        spaceship.physics.x_speed = 15
    if spaceship.is_touching(finish):
        asteroid1.hide()
        asteroid2.hide()
        asteroid3.hide()
        spaceship.hide()
        finish.hide()
        win = play.new_text(words="WIN",
                            x=0,
                            y=0,
                            font_size=200,
                            color="green")
    if spaceship.is_touching(asteroid1) or spaceship.is_touching(
            asteroid2) or spaceship.is_touching(asteroid3):
        asteroid1.hide()
        asteroid2.hide()
        asteroid3.hide()
        spaceship.hide()
        finish.hide()
        lose = play.new_text(words="LOSE",
                             x=0,
                             y=0,
                             font_size=200,
                             color="red")
예제 #2
0
def do():
    ball.physics.y_speed = 0
    ball.physics.x_speed = 0

    if play.key_is_pressed('w'):
        ball.physics.y_speed = 10
    if play.key_is_pressed('s'):
        ball.physics.y_speed = -10
    if play.key_is_pressed('a'):
        ball.physics.x_speed = -10
    if play.key_is_pressed('d'):
        ball.physics.x_speed = 10
    if ball.is_touching(finish):
        wall1.hide()
        wall2.hide()
        wall3.hide()
        wall4.hide()
        wall5.hide()
        wall6.hide()
        wall7.hide()
        wall8.hide()
        wall9.hide()
        wall10.hide()
        wall11.hide()
        wall12.hide()
        finish.hide()
        ball.hide()
        play.new_text(words="YOU WIN",
                      x=0,
                      y=0,
                      font=None,
                      font_size=100,
                      color="red")
예제 #3
0
def lose () :
    global status
    for truba in truba_list :
        if bird.is_touching (truba[0]) or bird.is_touching (truba[1]) :
            status = 0
            all_hide (truba_list)
            bird.stop_physics()
            bird.hide () 
            lose = play.new_text (words = 'LOSER', x = 0, y = 100, font_size = 200)
            restart_button.show()
            exit_button.show()
예제 #4
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)

# клавиши и звуки для них:
예제 #5
0
import play  # this should always be the first line
import random
import cv2
from tracking_camera import find_mouth_rects

# p1_box = play.new_box(color='blue', x=350, y=0, width=30, height=120)
# p2_box = play.new_box(color='red', x=-350, y=0, width=30, height=120)

play.new_text("MOUTHBALL", x=0, y=250)
# debug_print = play.new_text("", x=0, y=0, font_size=20)

p1_box = play.new_image(image='mouth-vertical.png', x=350, y=0, size=200)
p2_box = play.new_image(image='mouth-vertical.png', x=-350, y=0, size=200)

p1_smiley = play.new_image(image='smiley.png', x=200, y=250, size=30)
p2_smiley = play.new_image(image='smiley.png', x=-200, y=250, size=30)
p1_not_smiley = play.new_image(image='not-smiling.png', x=200, y=250, size=30)
p2_not_smiley = play.new_image(image='not-smiling.png', x=-200, y=250, size=30)

p1_score = 0
p2_score = 0

p1_score_text = play.new_text(str(p1_score), x=250, y=250, font_size=40)
p2_score_text = play.new_text(str(p2_score), x=-250, y=250, font_size=40)

p1_not_smiley.hide()
p2_not_smiley.hide()

ball = play.new_image(image='heart.png', x=0, y=0, size=30)

BALL_DX = 10  # horizontal velocity is always same speed
예제 #6
0
    truba.satus = 1
    score = play.new_image(image='./img/score.png', x=-300, y=200)

    return truba, truba2


bird.start_physics(obeys_gravity=True, bounciness=False)

truba_list = []

restart_button = play.new_image(image="./img/restart_button.png",
                                x=200,
                                y=-150)
restart_button.hide()

score_numbere = play.new_text(words='0', x=-300, y=165, color='red')

exit_button = play.new_image(image="./img/exit_button.png", x=-200, y=-150)
exit_button.hide()


@play.repeat_forever
async def do():
    global status, n
    if status == 1:
        a = drow_truba(randint(-200, 200), randint(200, 230))
        n = n + 1
        score_numbere.words = str(n)
        truba_list.append(a)
        await play.timer(3)
    else:
예제 #7
0
    def get_instrument(self):
        return self.instrument

    def start(self):
        self.ready = True

    def paused(self):  #объекту дается конкретное указание "игра на паузе"
        self.ready = False

    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',
예제 #8
0
import play
play.set_backdrop("darkblue")

#-------------------------------------
spaceship = play.new_image(image="spaceship.png", size=15, x=0, y=-200)
asteroid1 = play.new_image(image="asteroid.png", size=3, x=-300, y=-100)
asteroid2 = play.new_image(image="asteroid.png", size=3, x=300, y=0)
asteroid3 = play.new_image(image="asteroid.png", size=3, x=-300, y=100)
finish = play.new_text(words="FINISH",
                       x=0,
                       y=250,
                       font_size=100,
                       color="yellow")
#-------------------------------------


@play.when_program_starts
def start():
    spaceship.start_physics(stable=True,
                            obeys_gravity=False,
                            bounciness=1,
                            mass=10)
    asteroid1.start_physics(stable=False,
                            x_speed=5,
                            y_speed=0,
                            obeys_gravity=False,
                            bounciness=1,
                            mass=1)
    asteroid2.start_physics(stable=False,
                            x_speed=5,
                            y_speed=0,
예제 #9
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))
import play
import pygame

play.set_backdrop('light green')
coin_sound = pygame.mixer.Sound('coin.wav')
sea_sound = pygame.mixer.Sound('sea.ogg')
pygame.display.set_caption('Platformer: The Stupidest Game Ever!')

gameover_text = play.new_text(words = 'GAME OVER', x = 0, y = play.screen.top - 100, font_size=50)
retry_button = play.new_text(words="RETRY", x = 0, y = play.screen.bottom + 200, font_size=50)

gameover_text.hide()
retry_button.hide()

sprite = play.new_circle(
    color= 'black', x = play.screen.left + 20, y = play.screen.top - 20, border_width=3, radius = 15
)
finish = 0
coins = []
platforms = []

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
    )
예제 #11
0
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():
    ball.start_physics(bounciness=1.5)
    wall1.start_physics(can_move=False)
    wall2.start_physics(can_move=False)
    wall3.start_physics(can_move=False)
    wall4.start_physics(can_move=False)
    wall5.start_physics(can_move=False)
    wall6.start_physics(can_move=False)
    wall7.start_physics(can_move=False)
예제 #12
0
    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,
                              font_size=50,
                              color='blue',
                              x=-350,
                              y=240,
                              angle=0,
                              size=100,
                              transparency=100)
timer = 2 * 60  # 2 минуты по 60 секунд (120 секунд)
예제 #13
0
import pygame

background = ['The_space_of_JSG_1.png', 'The_space_of_JSG_2.png']
fon = play.new_image(image=background[0])
# @play.repeat_forever
# async def fon():
#     for i in background:
#         fon.image =i
#         await play.timer(2/3)
status = 1

play.screen.width = 800
play.screen.height = 640
n = 0
count = play.new_text(words='SCORE: {}'.format(n),
                      color='yellow',
                      x=play.screen.left + 100,
                      y=play.screen.top - 50)

u_lose = play.new_image("u_lose.png", size=750)

exit_demon = play.new_image('Exit_button_vadsl.png',
                            x=play.screen.right - 100,
                            y=play.screen.top - 50)
exit_demon.hide()


def sdelat_truby(y, delta):
    truba = play.new_box(color='yellow',
                         transparency=50,
                         x=475,
                         y=y,
                      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,
                      y=0,
                      font=None,
                      font_size=40,
                      color='green')
result = play.new_text(words='Вы выиграли!',
                       x=0,
                       y=0,
                       font=None,
                       font_size=40,
                       color='green')
button = play.new_box(color='yellow', x=0, y=0, width=150, height=50)
button_text = play.new_text(words='Вперед!', x=0, y=0, font=None, font_size=50)

#создание случайных чисел
num1_text = play.new_text(words='', x=-200, y=0, font=None, font_size=100)
num2_text = play.new_text(words='', x=0, y=0, font=None, font_size=100)
num3_text = play.new_text(words='', x=200, y=0, font=None, font_size=100)
예제 #15
0
    True if two rectangular sprites intersect
    """
    return (self.x < (other.x + other.width) and
        (self.x + self.width) > other.x and
        self.y > (other.y + other.height) and
        (self.y + self.height) < other.y)
play.sprite.is_touching = is_touching

start = (-280, -10)
target = (150, 70)
player = play.new_sprite(image='player.png', x=-260, y=-150, angle=0, size=50)
ball = play.new_sprite(image='basketball.png', x=start[0], y=start[1], angle=0, size=50)
backboard = play.new_sprite(image='backboard.png', x=170, y=-10, angle=0, size=50)
circle = play.new_circle(x=target[0], y=target[1], radius=5, border_color="black", border_width=5)

score = play.new_text(words='0', x=-350, y=250, font_size=50)
score.score = 0

@play.when_program_starts
def green_flag():
    ball.go_to(*start)
    ball.power = 0
    ball.is_being_dragged = False
    ball.has_been_dragged = False
    ball.has_being_thrown = False

@play.when_key_released('r')
async def do(key):
   green_flag()

@ball.when_clicked
'''
pip install replit-play codelab_adapter_client
'''

import play
import time
from codelab_adapter_client import HANode

# cat = play.new_text('=^.^=', font_size=70)
cat = play.new_text('click to turn off the light!', font_size=70)


class Neverland(HANode):
    def __init__(self):
        super().__init__()


neverland = Neverland()

num = 1


@cat.when_clicked
def win_function():
    global num
    cat.show()

    if num % 2 == 0:
        neverland.call_service(service="turn_on")
        cat.words = 'click to turn off the light!'
    else:
예제 #17
0
# начало программы

import play

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)
예제 #18
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)
예제 #19
0
import play
import pygame
from random import randint
play.set_backdrop((51,186,34))

N=0
schet = play.new_text(words="Очки {}".format(str(N)),y=200,x=-100)
STATUS=1
def start():
    bird.start_physics(can_move=True,y_speed=5, bounciness=0.1, obeys_gravity=False)
gameovertext = play.new_text(
    words="gameover",
    x = 0,
    y = 0,
    font_size=90,
    color="red")

gameoverbutton = play.new_circle(color="red",x=0,y=-50,radius=30)
restartbutton = play.new_circle(color="green",x=0,y=-140,radius=30)
restartbutton.hide()
gameoverbutton.hide()
gameovertext.hide()
@restartbutton.when_clicked
def do2():
    global STATUS
    STATUS=1
    # bird.stop_physics()
    bird.show()
    # gameovertext.hide()
    # gameoverbutton.hide()
    # restartbutton.hide()
예제 #20
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)
예제 #21
0
import play
#wallpaper
play.set_backdrop("darkorange")
#images
photo = play.new_image(image="1.jpg",
                       x=0,
                       y=0,
                       size=20,
                       angle=0,
                       transparency=100)
#text
text = play.new_text(words="Happy",
                     x=0,
                     y=200,
                     font=None,
                     font_size=100,
                     color="yellow")


@play.when_program_starts
def start():
    pass


@play.repeat_forever
def do():
    if play.key_is_pressed('e'):
        photo.image = "1.jpg"
        text.words = "Happy"
        text.color = "Yellow"
    if play.key_is_pressed('w'):
예제 #22
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()
예제 #23
0
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)

display = play.new_text(words=('%.03d' % score), x=350, y=270, angle=0,
                        font=None, font_size=50, color='black', transparency=100)

display_timer = play.new_text(words=('%.02d' % 0), x=-350, y=270, angle=0,
                              font=None, font_size=50, color='red', transparency=100)
display_timer.hide()

borders = [
    play.new_line(color='green', x=x_left, y=y_top, length=780, angle=0,
                  thickness=3, x1=None, y1=None),
    play.new_line(color='green', x=x_left, y=y_bottom, length=780, angle=0,
                  thickness=3, x1=None, y1=None),
    play.new_line(color='green', x=x_left, y=y_bottom, length=580, angle=90,
                  thickness=3, x1=None, y1=None),
    play.new_line(color='green', x=x_right, y=y_bottom, length=580, angle=90,
                  thickness=3, x1=None, y1=None)
]