这是用Python的海龟画图turtle模块制作的一个角色,人物和背景取自合金弹头,角色可以跳,可以左右行走.
下面是部分代码预览:
"""
合金弹头Macro角色
"""
from turtle import *
class Sprite(Turtle):
"""继承自Turtle类的角色"""
def __init__(self,mr,ml):
"""
mr:右造型序列表
ml:左造型序列表
"""
Turtle.__init__(self)
self.penup()
self.mr = mr # 右造型序列
self.ml = ml # 左造型序列
self.images = [mr,ml]# 造型列表
self.shapes_index = 0# 默认为向右造型序列
self.costume_index = 0
self.set_costume() # 设置造型
self.screen.onkeypress(self.move_right,"Right")
self.screen.onkeypress(self.move_left,"Left")
self.screen.onkeypress(self.jump,"Up")
self.screen.listen()
self.dy = 0
self.gravity()
def main():
"""主要函数"""
width,height = 480,360
screen = Screen()
screen.title("海龟画图制作的合金弹头主角by lixingqiu")
screen.bgpic("bg/07.png")
screen.setup(width,height)
.......................
macro = Sprite(mr,ml)
screen.update()
if __name__ == "__main__":
main()
下载完整源代码与素材,请
需要浏览更多吗?
成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)

