Python 3 / pygame / Создание игры Arkanoid
Нужна подсказка как сделать код отскакивания мячика
Вот код:
from tkinter import *
def roll():
global ball_y
global dy
global ball_x
global dx
global platform
ball_x = ball_x + dx
if ball_x > 700 or ball_x < 0:
dx = -dx
ball_y = ball_y + dy
if ball_y > 500 or ball_y < 0:
dy = -dy
canv.coords(ball, ball_x, ball_y, ball_x+100, ball_y+100,)
form.after(10,roll)
def pad_move(event):
global pad_x
pad_x = event.x
canv.coords(platform, pad_x-50, 500, pad_x+50, 530)
form = Tk()
form.title("Arkanoid TEST")
form.geometry("800x600")
canv = Canvas(form, width = 800, height = 600, bg="lightblue")
canv.pack()
ball_x=0
ball_y=0
dx = 5
dy = 5
ball = canv.create_oval(ball_x, ball_y, ball_x+100, ball_y+100, fill = "Black")
form.after(0,roll)
pad_x = 150
platform = canv.create_rectangle(pad_x, 500,pad_x+100, 530, fill = "Black")
form.bind("<Motion>", pad_move)
form.mainloop()