Сделайте так чтоб падл двигалась import tkinter as tk
from tkinter import *
import ctypes
import time
import random
tk = Tk()
tk.title('Greeting')
tk.resizable(0, 0)
tk.wm_attributes('-topmost', 1)
canvas = Canvas(tk, width=1920, height=1080, highlightthickness=0)
canvas.pack()
tk.update()
h = ('''
Hello
My name is kishimoto
I was waiting for you
''')
class Text:
def __init__(self, canvas, color):
self.Text = h
self.canvas = canvas
self.id = canvas.create_text(130, 42, text=self.Text, font=('Courier', 15), fill=color)
text = Text(canvas, 'Black')
t = ('''
In this game you must went to red balls and eat them.
You will went with 4 arrows.
Let's play!
''')
class Text:
def __init__(self, canvas, color):
self.Text = t
self.canvas = canvas
self.id = canvas.create_text(320, 95, text=self.Text, font=('Courier', 15), fill=color)
text = Text(canvas, 'Black')
tk.after(1000, lambda: tk.destroy())
tk.mainloop()
tk = Tk()
tk.title('Game')
tk.resizable(0, 0)
tk.wm_attributes('-topmost', 1)
canvas = Canvas(tk, width=1920, height=1080, highlightthickness=0)
canvas.pack()
tk.update()
class Paddle:
def __init__(self, canvas, color):
self.canvas = canvas
self.id = canvas.create_rectangle(0, 0, 20, 20, fill=color)
start_1 = [40, 60, 90, 120, 150, 180, 200, 230, 260, 300, 340 , 375, 421, 497, 511, 590, 647, 701, 787, 871, 891, 954, 1020, 1111, 1213, 1290, 1371, 1423, 1567, 1563, 1671, 1721, 1790, 1834, 1890, 1900]
random.shuffle(start_1)
self.starting_point_x = start_1[0]
self.canvas.move(self.id, self.starting_point_x, 300)
self.x = 0
self.canvas_width = self.canvas.winfo_width()
self.canvas.bind_all(' ', self.turn_right)
self.canvas.bind_all(' ', self.turn_left)
self.started = False
self.canvas.bind_all(' ', self.start_game)
def turn_right(self, event):
self.x = 2
def turn_left(self, event):
self.x = -2
def start_game(self, event):
self.started = True
def draw(self):
self.canvas.move(self.id, self.x, 0)
pos = self.canvas.coords(self.id)
if pos[0] <= 0:
self.x = 0
elif pos[2] >= self.canvas_width:
self.x = 0
paddle = Paddle(canvas, 'Red')
if paddle.started == True:
paddle.draw()
tk.update_idletasks()
tk.update()
time.sleep(0.01)