"""
princess.py
本模块是作品《保卫公主行动》的公主类。公主实例化后会按路径移动。
路径是随机的,由另一个模块产生。
保卫公主行动的灵感来源于一位女大学生让我制作一个塔防游戏....
故事也是我自己编的。从前一位国王生了很多女儿。她们要穿越山洞去朝圣,在穿越过程中,有小鬼出没。
在游戏中,你需要单击鼠标把消灭这些小鬼。
这个只是其中的一个模块。供有需要的人士。
"""
import time
from turtle import *
class Princess(Turtle):
group = []
amounts = 0
success_counter = 0
def __init__(self,image,cors,sound=None):
"""image:造型,cors:路径上所有坐标点"""
if __name__ == "__main__":
screen = Screen()
screen.bgcolor("white")
screen.title("保卫公主行动之公主类")
cors = [(-133, 40), (-130, 42), (-127, 43), (-125, 44),
(-122, 45), (-119, 46), (-116, 47), (-114, 49),
(-111, 50), (-108, 51), (-105, 52), (-103, 53),
(-100, 54), (-97, 56), (-94, 57),(-92, 58),
(-89, 59), (-86, 59), (-83, 59), (-80, 60),
(-77, 60), (-74, 60), (-71, 60), (-68, 61),
(-65, 61), (-62, 61), (-59, 61), (-56, 62),
(-54, 61), (-52, 59), (-49, 57), (-47, 56),
(-45, 54), (-42, 52), (-40, 50), (-38, 48),
(-35, 46), (-33, 45), (-30, 43), (-28, 41),
(-26, 39), (-23, 37), (-21, 35), (-19, 33),
(-17, 32), (-14, 31), (-12, 30), (-9, 29),
(-6, 27), (-3, 26), (-1, 25),(1, 24), (4, 22),
(7, 21), (9, 20), (12, 18), (15, 17), (17, 16),
(21, 15), (24, 14), (27, 14), (30, 13), (33, 13),
(36, 13), (39, 12),(42, 12), (45, 12), (48, 11),
(51, 11), (54, 11), (57, 10), (60, 10),(63, 9),
(66, 9), (69, 9), (72, 8), (75, 8), (78, 7),
(81, 7), (84, 7),(87, 6), (90, 6), (93, 5),
(95, 5), (98, 4), (101, 4), (104, 4), (107, 3),
(110, 3), (113, 3), (116, 3), (119, 2), (122, 2),
(125, 2), (128, 2),(131, 2), (134, 2), (137, 1)]
image = "princess.gif"
screen.addshape(image)
def make_princess():
Princess(image,cors)
screen.ontimer(make_princess,400)
make_princess()
screen.mainloop()
如需要查看完整源代码,请
需要浏览更多吗?
成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)

