"""
伪3D拦彩球小游戏.py
本程序新建Ball类,球实例化后会在定时器的作用下不断地自我移动与进行碰撞检测。
board.py模块在下面。
"""
from glob import glob
from board import Board
from time import sleep
from turtle import Screen,Turtle
from random import randint,choice
class Ball(Turtle):
def __init__(self,image,board ):
"""image:已注册的gif图,board:拦板对象"""
Turtle.__init__(self,shape=image,visible=False)
self.penup()
self.board = board
self.xspeed = choice(speeds)
self.yspeed = choice(speeds)
self.sw = self.screen.window_width() # 屏幕宽度属性
self.sh = self.screen.window_height() # 屏幕高度属性
self.dead = False
self.goto(self.sw//2,self.sh//2)
self.showturtle()
self.move()
def move(self):
"""移动小球方法"""
def is_bumped_board(self):
"""是否碰到拦板检测"""
if __name__ == "__main__":
wood_image = "wood.gif"
width,height = 800,600
game_title= "接彩球游戏"
gif_images = glob("images/*.gif")
speeds = [x for x in range(-6,6) if x!=0] # 如果x不是0则加到列表中
screen = Screen()
下载完整源代码与素材,请
需要浏览更多吗?
成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)

