python pygame 实现小球弹跳

python pygame 实现小球弹跳

首页休闲益智小球跳跃更新时间:2024-06-05

import sys

import os

import random

curPath = os.path.abspath(os.path.dirname(__file__))

rootPath = os.path.split(curPath)[0]

sys.path.append(rootPath)

WIDTH,HEIGHT=800,600

x=WIDTH/2

y=HEIGHT/2

r=30

s_y=5

s_x=3

c=['red','black','pink','orange','blue','green','yellow']

i=0

def draw():

screen.fill('white')

screen.draw.filled_circle((x,y),r,c[i])

def update():

global y,s_y,i,x,s_x

y=y s_y

x=x s_x

if x>=WIDTH-r or x<=r:

s_x=-s_x

if y>=HEIGHT-r or y<=r:

s_y=-s_y

i=i 1

if i==6:

i=0

#python #

#pygame#

查看全文
大家还看了
也许喜欢
更多游戏

Copyright © 2024 妖气游戏网 www.17u1u.com All Rights Reserved