示例#1
0
def draw_truba(y, delta):
    size = 100
    trub = play.new_image(image="./img/sprite_1.png", x=0, y=y, size=size)
    trub2 = play.new_image(image="./img/sprite_22.png",
                           x=0,
                           y=y + 700 + delta,
                           size=size)
    return trub, trub2
示例#2
0
    def y_coord_from_mouth_rect(mouth_rects, box):
        if len(mouth_rects) > 0:

            cam_height = left_img.shape[1]
            cam_width = left_img.shape[0]
            screen_height = play.screen.height
            screen_width = play.screen.width

            raw_x_coordinate = mouth_rects[0][0]
            raw_y_coordinate = mouth_rects[0][1] * 2

            xpos = (raw_x_coordinate / cam_width)
            negative = -1 if box.x < 0 else 1
            if not negative:
                xpos = 200 - xpos
            x_coordinate = negative * 350 + (xpos * 50)
            box.x = x_coordinate

            # ypos represents mouth position as a percentage.
            # in the opencv code we halve the image size;
            # account for that here by dividing cam height by 2
            ypos = (raw_y_coordinate / cam_height)

            # if len(left_smile) == 0 and negative == -1:
            #     ypos = 1 - ypos
            # elif len(right_smile) == 0 and not negative == 1:
            #     ypos = 1 - ypos

            # convert the percentage y position to an absolute
            # coordinate in the play coordinate system
            # (0 is middle, 0.5 * screen height is top of screen)
            y_coordinate = (0.5 - ypos) * screen_height
            box.y = y_coordinate

            global p1_box
            global p2_box

            if len(right_mouth_rects) > 0:
                old_p1_box = p1_box
                p1_box = play.new_image(image='right_mouth.jpg',
                                        x=old_p1_box.x,
                                        y=old_p1_box.y,
                                        size=200)
                old_p1_box.remove()
            if len(left_mouth_rects) > 0:
                old_p2_box = p2_box
                p2_box = play.new_image(image='left_mouth.jpg',
                                        x=old_p2_box.x,
                                        y=old_p2_box.y,
                                        size=200)
                old_p2_box.remove()
示例#3
0
 def __init__(self, image_name, walls, dots, fruit):
     self.score = 0
     self.fruit = fruit
     self.full_image = play.new_image(image=image_name, x=0, y=0, size=50)
     self.full_image.transparency = 0
     self.walls = walls
     self.dots = dots
     self.you_won_sprite = play.new_image(image='images/text/YouWon.png',
                                          x=0,
                                          y=0,
                                          size=100)
     self.you_won_sprite.hide()
     self.game_over_sprite = play.new_image(
         image='images/text/GameOver.png', x=0, y=0, size=100)
     self.game_over_sprite.hide()
示例#4
0
def draw_truba(y_truba,rast):
    x_truba = 500
    delta = 500
    truba = play.new_image(
    x = x_truba,
    y = y_truba + rast,
    image="/img/truba2.png",
    size=3000,
    transparency = 50)
    truba2 = play.new_image(
    x = x_truba,
    y = y_truba-delta,
    image="/img/truba1.png",
    size=3000,
    transparency = 50)
    return truba, truba2
示例#5
0
def drow_truba(y_cor, rast):
    delta = 475
    truba2 = play.new_image(
        image='./img/truba2.png',
        x=450,
        y=y_cor - delta,
        size=100,
    )

    truba = play.new_image(
        image='./img/truba.png',
        x=450,
        y=y_cor + rast,
        size=100,
    )
    truba.satus = 1
    score = play.new_image(image='./img/score.png', x=-300, y=200)

    return truba, truba2
示例#6
0
def back():
    rain = play.new_image(image=k_rain[randint(0, 2)],
                          size=50,
                          x=randint(play.screen.left, play.screen.right + 400),
                          y=play.screen.top)
    rain_list.append(rain)
    for i in rain_list:
        if i.y > play.screen.bottom and i.x > play.screen.left:
            i.x -= 5
            i.y -= 7
        else:
            i.hide()
            del (i)
示例#7
0
def draw_platform(x, y):
    for wall in wall_list:
        if wall.x < play.screen.left:

            if wall.y == play.screen.bottom + 30:
                new_wall = play.new_image(image=box_img,
                                          x=play.screen.right + 32,
                                          y=play.screen.bottom + 30)
                new_wall.start_physics(can_move=True,
                                       obeys_gravity=False,
                                       stable=True,
                                       friction=0)
                wall_list.append(new_wall)
            wall_list.remove(wall)
示例#8
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)
示例#9
0
import pygame
import play
from random import randint

# if a==b:
n = 0

fon = play.new_image(image='./img/fon.png')

you_lose = play.new_image(image="./img/You_lose.png")
you_lose.hide()
''' tilda-макет сайт, tilda- сделать кам сайт'''

bird = play.new_image(image='./img/bird1.png', x=-250, y=0, size=150)

status = 1


def drow_truba(y_cor, rast):
    delta = 475
    truba2 = play.new_image(
        image='./img/truba2.png',
        x=450,
        y=y_cor - delta,
        size=100,
    )

    truba = play.new_image(
        image='./img/truba.png',
        x=450,
        y=y_cor + rast,
示例#10
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,
示例#11
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'):
示例#12
0
import play
from pacman import Pacman
from game_map import Game_map
from item import Item
from ghost import Ghost

ghosts = []
dots = []
fruit = []

map_sprites = []
play.set_backdrop((0, 0, 0))
# complete_map = play.new_image(image="images/map/Map.png", x=0, y=0, size=50)
map_sprites.append(
    play.new_image(image="new_images/map1.jpg", x=-200, y=235, size=40))
map_sprites.append(
    play.new_image(image="new_images/map1.jpg", x=200, y=235, size=40))
map_sprites.append(
    play.new_image(image="new_images/map2.jpg", x=-90, y=236, size=40))
map_sprites.append(
    play.new_image(image="new_images/map2.jpg", x=90, y=236, size=40))
map_sprites.append(
    play.new_image(image="new_images/map3.jpg", x=0, y=250, size=40))
map_sprites.append(
    play.new_image(image="new_images/map4.jpg", x=0, y=295, size=40))
map_sprites.append(
    play.new_image(image="new_images/map6.jpg", x=222, y=77, size=40))
map_sprites.append(
    play.new_image(image="new_images/map5.jpg", x=267, y=206, size=40))
map_sprites.append(
示例#13
0
def draw_tryba(y,delta):
    tryba1=play.new_image (image=/img/'truba.png', size=200,angle=180,x=100,y=y+345+delta)
    tryba2=play.new_image (image=/img/'truba.png', size =300,x=100,y=y)
    return tryba1, tryba2
示例#14
0
import play #flappy bird
from random import randint

bird=play.new_image (image='ptitsa.png',size=200,x=-300,y=-150)
po=play.new_image (image='njxrf.jpg',x=0,y=0,size=30)
po.hide()
             
def draw_tryba(y,delta):
    tryba1=play.new_image (image=/img/'truba.png', size=200,angle=180,x=100,y=y+345+delta)
    tryba2=play.new_image (image=/img/'truba.png', size =300,x=100,y=y)
    return tryba1, tryba2

truby_typie = []


@play.repeat_forever
async def do ():   
    y = randint(-150, -40)
    delta = randint (100, 350)
    truby_typie.append (draw_tryba(y,delta))
    await  play.timer(seconds =1)

@play.repeat_forever
async def leftright():
    for tryba in truby_typie:
        tryba[0].x-=5
        tryba[1].x-=5
        if tryba[0].x<-450:
            tryba[0].remove()
            tryba[1].remove()
            truby_typie.remove(tryba)
示例#15
0
async def do():
    global frame_count
    frame_count += 1
    if frame_count % 5 != 1:
        return

    left_img, left_mouth_rects, right_mouth_rects, left_smile, right_smile = find_mouth_rects(
    )

    # update the background
    global background
    old_background = background
    background = play.new_image(image='background.jpg',
                                x=0,
                                y=0,
                                size=160,
                                transparency=15)
    old_background.remove()

    def y_coord_from_mouth_rect(mouth_rects, box):
        if len(mouth_rects) > 0:

            cam_height = left_img.shape[1]
            cam_width = left_img.shape[0]
            screen_height = play.screen.height
            screen_width = play.screen.width

            raw_x_coordinate = mouth_rects[0][0]
            raw_y_coordinate = mouth_rects[0][1] * 2

            xpos = (raw_x_coordinate / cam_width)
            negative = -1 if box.x < 0 else 1
            if not negative:
                xpos = 200 - xpos
            x_coordinate = negative * 350 + (xpos * 50)
            box.x = x_coordinate

            # ypos represents mouth position as a percentage.
            # in the opencv code we halve the image size;
            # account for that here by dividing cam height by 2
            ypos = (raw_y_coordinate / cam_height)

            # if len(left_smile) == 0 and negative == -1:
            #     ypos = 1 - ypos
            # elif len(right_smile) == 0 and not negative == 1:
            #     ypos = 1 - ypos

            # convert the percentage y position to an absolute
            # coordinate in the play coordinate system
            # (0 is middle, 0.5 * screen height is top of screen)
            y_coordinate = (0.5 - ypos) * screen_height
            box.y = y_coordinate

            global p1_box
            global p2_box

            if len(right_mouth_rects) > 0:
                old_p1_box = p1_box
                p1_box = play.new_image(image='right_mouth.jpg',
                                        x=old_p1_box.x,
                                        y=old_p1_box.y,
                                        size=200)
                old_p1_box.remove()
            if len(left_mouth_rects) > 0:
                old_p2_box = p2_box
                p2_box = play.new_image(image='left_mouth.jpg',
                                        x=old_p2_box.x,
                                        y=old_p2_box.y,
                                        size=200)
                old_p2_box.remove()

    y_coord_from_mouth_rect(right_mouth_rects, p1_box)
    y_coord_from_mouth_rect(left_mouth_rects, p2_box)

    # change the smiley statuses
    if len(left_smile) > 0:
        p2_smiley.show()
        p2_not_smiley.hide()
    else:
        p2_smiley.hide()
        p2_not_smiley.show()

    if len(right_smile) > 0:
        p1_smiley.show()
        p1_not_smiley.hide()
    else:
        p1_smiley.hide()
        p1_not_smiley.show()
示例#16
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
示例#17
0
 def __init__(self, image_name, position, cat):
     self.position = position
     self.cat = cat
     self.image = play.new_image(image=image_name, x=position[0], y=position[1], size=0.7)
示例#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)
示例#19
0
    './img/sprite/left/sprite_0.png', './img/sprite/left/sprite_1.png',
    './img/sprite/left/sprite_2.png', './img/sprite/left/sprite_3.png',
    './img/sprite/left/sprite_4.png', './img/sprite/left/sprite_5.png'
]

k_heli = [
    './img/heli/heli0.png', './img/heli/heli1.png', './img/heli/heli2.png',
    './img/heli/heli3.png', './img/heli/heli4.png', './img/heli/heli5.png'
]
k_lava = [
    './img/lava/lava1.png',
    './img/lava/lava1.png',
    './img/lava/lava2.png',
]

wall1 = play.new_image(image='./img/platform.png', x=-100, y=0, size=15)
wall2 = play.new_image(image='./img/platform.png', x=250, y=-200, size=15)
wall3 = play.new_image(image='./img/platform.png', x=400, y=130, size=15)
wall4 = play.new_image(image='./img/platform.png', x=350, y=-100, size=15)
wall5 = play.new_image(image='./img/platform.png', x=500, y=-100, size=15)
wall6 = play.new_image(image='./img/platform.png', x=650, y=-100, size=15)
wall7 = play.new_image(image='./img/platform.png', x=800, y=-100, size=15)
wall_list = [wall1, wall2, wall3, wall4, wall5, wall6, wall7]

i = 31
j = 32
while play.screen.height - i > 0:
    box = play.new_image(image=box_img,
                         x=play.screen.left + 32,
                         y=play.screen.bottom + i)
    wall_list.append(box)
示例#20
0
import play
from random import randint

play.screen.height = 600
play.screen.width = 1000

background = './img/menu/background.jpeg'

fon = play.new_image(image=background)

k_rain = [
    './img/rain/sprite_0.png',
    './img/rain/sprite_1.png',
    './img/rain/sprite_2.png',
]

one_of_rain_k = [
    './img/menu/one/sprite_0.png', './img/menu/one/sprite_1.png',
    './img/menu/one/sprite_2.png', './img/menu/one/sprite_3.png',
    './img/menu/one/sprite_4.png', './img/menu/one/sprite_5.png',
    './img/menu/one/sprite_6.png', './img/menu/one/sprite_7.png'
]
number_k_one = 5

rain_list = []

button_play_k = [
    './img/menu/button/sprite_0.png', './img/menu/button/sprite_1.png'
]

button_play = play.new_image(image=button_play_k[0], y=100)
示例#21
0
import play
from random import randint
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',
示例#22
0
import pygame
import play
from random import randint
from time import sleep

catolog = 0
play.set_backdrop((215, 196, 164))

bird = play.new_image(image='./img/sprite_23.png', x=-200, y=0, size=300)
bird.start_physics(can_move=True, stable=False, bounciness=0)


def draw_truba(y, delta):
    size = 100
    trub = play.new_image(image="./img/sprite_1.png", x=0, y=y, size=size)
    trub2 = play.new_image(image="./img/sprite_22.png",
                           x=0,
                           y=y + 700 + delta,
                           size=size)
    return trub, trub2


truba_list = []


@play.repeat_forever
async def do():
    truba_list.append(draw_truba(randint(-500, -100), 0))
    await play.timer(2)

示例#23
0
    x = x_truba,
    y = y_truba + rast,
    image="/img/truba2.png",
    size=3000,
    transparency = 50)
    truba2 = play.new_image(
    x = x_truba,
    y = y_truba-delta,
    image="/img/truba1.png",
    size=3000,
    transparency = 50)
    return truba, truba2

bird = play.new_image(
    image = "/img/birdanimation0.png",
    x = -300,
    y = 0,
    size=150)
bird.start_physics(can_move=True,y_speed=10, bounciness=0.1, obeys_gravity=False)
    
trubas = []

@play.repeat_forever
async def draw():
    global N
    if STATUS==1:
        N+=1
        schet.words="Очки {}".format(str(N)) 
        y_truba = randint(50,400)
        rast =  randint(50,100)
        trubas.append(draw_truba(y_truba,rast))
示例#24
0
import pygame
import play
from random import randint


play.screen.width = 994
play.screen.height = 492


fone = play.new_image (image = 'fone.png', size = 33)


truba_list = []


status = 1



bird = play.new_image(image = 'bird0.png', x = - 350, y = 200)
total_score = play.new_image(image = 'score.png', x = - 455, y = 235, size = 150)


sound_jump = pygame.mixer.Sound('qwerty.ogg')


restart_button = play.new_image(image = 'restart.png', x =- 250, y = -150)
exit_button = play.new_image(image = 'exit.png', x = 250, y = -150)
restart_button.hide()
exit_button.hide()
示例#25
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 секунд)

key = play.new_image(image='key.png',
                     x=0,
                     y=110,
                     angle=0,
                     size=2,
                     transparency=100)

gameover = play.new_image(image='gameover.jpeg',
                          x=0,
                          y=0,
                          angle=0,
                          size=85,
                          transparency=100)
gameover.hide()

winner = play.new_text(words='YOU WIN',
                       font=None,
                       font_size=200,
                       color='green',