• 大小:
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-01
  • 语言: Python
  • 标签: pygame  python3  

资源简介

python游戏编程入门(More Python Programming For The Absolute Beginner)配套源代码

资源截图

代码片段和文件信息

# OOP Bug Demo

class Bug(object):
    legs = 0
    distance = 0

    def __init__(self name=“Bug“ legs=6):
        self.name = name
        self.legs = legs

    def Walk(selfdistance=1):
        self.distance += distance

    def GetDistance(self):
       return distance

    def SetDistance(self value):
        distance = value

    def ToString(self):
        return self.name + “ has “ + str(self.legs) + “ legs“ + \
            “ and taken “ + str(self.distance) + “ steps.“
        

#default constructor
ant = Bug()
for n in range(05):
    ant.Walk()
print(ant.ToString())

#one constructor parameter
beetle = Bug(“Beetle“)
beetle.legs = 6
for n in range(010):
    beetle.Walk()
print(beetle.ToString())

#two constructor parameters
spider = Bug(“Spider“ 8)
for n in range(010):
    spider.Walk(2)
print(spider.ToString())


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-01-23 16:37  resources\
     目录           0  2018-01-23 16:37  resources\code\
     目录           0  2018-01-23 16:37  resources\code\chap01\
     文件         885  2011-06-08 19:47  resources\code\chap01\BugDemo.py
     文件         220  2011-06-08 18:01  resources\code\chap01\ErrorProne.py
     文件         156  2011-06-08 13:59  resources\code\chap01\FunctionDemo.py
     文件        1354  2011-06-08 20:48  resources\code\chap01\GeometryDemo.py
     文件          26  2018-01-23 16:37  resources\code\chap01\HelloPython.py
     文件       84480  2011-08-18 19:20  resources\code\chap01\Thumbs.db
     目录           0  2018-01-23 16:37  resources\code\chap02\
     文件         622  2011-06-09 20:12  resources\code\chap02\DrawArcs.py
     文件         542  2011-06-09 19:25  resources\code\chap02\DrawingCircles.py
     文件         499  2011-06-09 20:05  resources\code\chap02\DrawingLines.py
     文件         829  2011-06-09 20:04  resources\code\chap02\DrawingRectangles.py
     文件         508  2011-06-09 20:06  resources\code\chap02\FirstPygameExample.py
     文件        2900  2011-06-09 20:54  resources\code\chap02\PieGame.py
     文件       54784  2011-08-18 19:21  resources\code\chap02\Thumbs.db
     目录           0  2018-01-23 16:37  resources\code\chap03\
     文件        1032  2011-06-15 20:32  resources\code\chap03\FileCode.py
     文件         167  2011-06-14 17:58  resources\code\chap03\InputDemo.py
     文件        1158  2011-06-14 21:45  resources\code\chap03\MadLibGame.py
     文件         434  2011-06-14 17:08  resources\code\chap03\TestCode.py
     文件       52224  2011-08-18 19:21  resources\code\chap03\Thumbs.db
     文件        4426  2011-06-16 20:13  resources\code\chap03\TriviaGame.py
     文件        4000  2011-06-16 17:51  resources\code\chap03\binary.dat
     文件          37  2011-06-15 13:24  resources\code\chap03\data2.txt
     文件         544  2011-06-16 19:28  resources\code\chap03\trivia_data.txt
     文件         162  2011-06-13 20:09  resources\code\chap03\~$806-03.doc
     文件       72192  2011-06-15 11:06  resources\code\chap03\~WRL0186.tmp
     文件       58880  2011-06-14 17:55  resources\code\chap03\~WRL0276.tmp
     文件       80384  2011-06-15 14:27  resources\code\chap03\~WRL0353.tmp
............此处省略215个文件信息

评论

共有 条评论