# Bob - 对接小球

import pygame
import random
import time as t
def ball(screen,x,y,down,right,green):
if down:
y = y + 1
else:
y = y - 1

if right:
x += 1
else:
x -= 1

if y > 600 :
down = False
if x > 800:
right  = False
if 0 > y :
down = True
if x < 0:
right = True

pygame.draw.circle(screen, (green, 255, 20), (x, y), 50)
return  x,y,down,right

pygame.init()
screen = pygame.display.set_mode((800, 600))

x, y, down,right = random.randint(0,800),random.randint(0,600),True,True
ban_x,ban_y,ban_k,ban_g = 700,250,100,100
ban_x2,ban_y2,ban_k2,ban_g2 = 0,250,100,100
# 电脑每隔多少毫秒时间响应一次
# 1秒=1000毫秒
pygame.key.set_repeat(1, 1)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
# elif event.type == pygame.MOUSEMOTION:
#     ban_x, ban_y = event.pos    # pos---> position
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
ban_y -= 5
if ban_y < 0:
ban_y = 0
if event.key == pygame.K_DOWN:
ban_y += 5
if ban_y > 500:
ban_y = 600-100
if event.key == pygame.K_w:
ban_y2 -= 5
if ban_y2 < 0:
ban_y2 = 0
if event.key == pygame.K_s:
ban_y2 += 5
if ban_y2 > 500:
ban_y2 = 600-100

screen.fill((2, 2, 1))
x, y, down, right = ball(screen,x,y,down,right,0)
if x > 700 and y > ban_y and y < ban_y+100:
t.sleep(10)
if x < 100 and y > ban_y2 and y < ban_y2+100:
t.sleep(10)
# px,py,pdown,pright = ball(screen, px,py,pdown,pright,255)
pygame.draw.rect(screen,(220,0,0),(ban_x,ban_y,ban_k,ban_g))
pygame.draw.rect(screen,(220,100,0),(ban_x2,ban_y2,ban_k2,ban_g2 ))

pygame.display.update()

pygame.quit()


08-16 2334

08-16 1415

04-26 7012

06-01 1765

09-21 2397

12-04 1052

09-25 38

12-27 1128

08-06 2227

02-28 4131

03-19 1938

04-11 1116

08-01 1464

05-05 1213

12-18 4638

01-19 2565

07-18 1712

11-23 1317

07-18 1400

10-20 4180

03-19 82万+

04-14 60万+

02-28 9328

03-01 14万+

03-08 7万+

04-25 7万+

03-10 13万+

03-10 19万+

#### MySQL数据库面试题（2020最新版）

©️2019 CSDN 皮肤主题: 深蓝海洋 设计师: CSDN官方博客