Match man

火柴人

关键字: Python, 小游戏, GIMP, python for kids

Classes
  • class Game(object):
  • class Coords(object):
  • class sprites(object):
  • class PlatFromSprites(sprites):
  • class StickSprites(sprites):
  • class DoorSprite(sprites):
Functions
  • Global
    • def within_x(coo1, coo2):
    • def within_y(coo1, coo2):
    • def crash_left(coo1, coo2):
    • def crash_right(coo1, coo2):
    • def crash_top(coo1, coo2):
    • def crash_bottom(delty, coo1, coo2):
  • Non-Global
    • class Game(object):
      • def init(self):
      • def mainloop(self):
    • class Coords(object):
      • def init(self, x1 = 0, y1 = 0, x2 = 0, y2 = 0):
    • class sprites(object):
      • def init(self, game):
      • def move(self):
      • def coords(self):
    • class PlatFromSprites(sprites):
      • def init(self, game, photo_image, x, y, width, height):
    • class StickSprites(sprites):
      • def init(self, game):
      • def turn_left(self, evt):
      • def turn_right(self, evt):
      • def jump(self, evt):
      • def animate(self):
      • def coords(self):
      • def move(self):
    • class DoorSprite(sprites):
      • def init(self, game, photo_image, x, y, width, height):
Main
if __name__ == '__main__': 
    g = Game()
    platform1 = PlatFromSprites(g, PhotoImage(file="E:\\game\\pic\\stair1.gif"), 0, 480, 100, 10)
    platform2 = PlatFromSprites(g, PhotoImage(file="E:\\game\\pic\\stair1.gif"), 150, 440, 100, 10)
    platform3 = PlatFromSprites(g, PhotoImage(file="E:\\game\\pic\\stair1.gif"), 300, 400, 100, 10)
    platform4 = PlatFromSprites(g, PhotoImage(file="E:\\game\\pic\\stair1.gif"), 300, 160, 100, 10)
    g.sprites.append(platform1)
    g.sprites.append(platform2)
    g.sprites.append(platform3)
    g.sprites.append(platform4)
    platform5 = PlatFromSprites(g, PhotoImage(file="E:\\game\\pic\\stair2.gif"), 175, 350, 66, 10)
    platform6 = PlatFromSprites(g, PhotoImage(file="E:\\game\\pic\\stair2.gif"), 50, 300, 66, 10)
    platform7 = PlatFromSprites(g, PhotoImage(file="E:\\game\\pic\\stair2.gif"), 170, 120, 66, 10)
    platform8 = PlatFromSprites(g, PhotoImage(file="E:\\game\\pic\\stair2.gif"), 45, 60, 66, 10)
    g.sprites.append(platform5)
    g.sprites.append(platform6)
    g.sprites.append(platform7)
    g.sprites.append(platform8)
    platform9 = PlatFromSprites(g, PhotoImage(file="E:\\game\\pic\\stair3.gif"), 170, 300, 32, 10)
    platform10 = PlatFromSprites(g, PhotoImage(file="E:\\game\\pic\\stair3.gif"), 230, 200, 32, 10)
    door = DoorSprite(g, PhotoImage(file = "E:\\game\\pic\\door2.gif"), 45, 30, 40, 35)
    g.sprites.append(door)

    st = StickSprites(g)
    g.sprites.append(st)
    g.mainloop()


main()
Results
  • Screenshot of this little game
    initiation
    when it begins
    running
    when it was running
Appendix
  • How to get these gifs within my program ?
    • Firstly, draw these gifs with the drawing tool of Windows OS and be sure get the right size. In this program the matchman should be 27 * 30 pixel.
    • Secondly, make the background of these gifs transparent with GIMP. The method of “transparent” are as follows:
      • 1 Open your gif with GIMP
      • 2 Select all (Ctrl A)
      • 3 Reverse (Ctrl I)
      • 4 Copy
      • 5 New File, note that choosing background as transparent while you build the new file.
      • 6 Paste
      • 7 Save
      • 8 Export as XXX.gif
      • You may down GIMP freely here Down GIMP 2
  • Does this program has any bugs?
    • Unfortunately, it is. The Matchman can’t go to the 6 board in this game.
  • Source code of this program
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值