Untitled
TEXT
views 88
,
size 2135 b
``````#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from tkinter import *
import random
import math

def gui():
# Окно и холст

WIDTH = 400
HEIGHT = 400

global WINDOW
WINDOW=Tk()

global c
c = Canvas(WINDOW, width=WIDTH, height=HEIGHT, bg="white")
c.pack()

# Оформление
c.create_rectangle(0,0,400,400,fill="#404040")
c.create_rectangle(5,5,395,395, fill="#777777")
# Дисплей
c.create_rectangle(305,10,390,55, fill="#404040")
c.create_rectangle(307,12,388,53, fill="#365834");

def init_game():
# Шарик
global ball
DEF_BALL_POS=[200,350]

fill="#547650", outline="black")

# Платформа
global platform
platform = c.create_rectangle(140,380,260,395, fill="#391D19")

def keyboard():

# Движение платформы влево при нажатии клвиши <left>
def move_left(event):

if ((c.coords(platform))[0]) >= 5:
c.move(platform,-30,0)

print("Current coords:\n", c.coords(platform))

# Движение платформы вправо при нажатии клавиши <right>
def move_right(event):

if ((c.coords(platform))[2]) <= 400:
c.move(platform,30,0)

print("Current coords:\n", c.coords(platform))

WINDOW.bind('<Left>',  move_left)
WINDOW.bind('<Right>', move_right)
#WINDOW.bind('<Escape>', restart_game)

def game():

DEGR=random.randint(0,135)

def move_ball():