鱼C论坛

 找回密码
 立即注册
查看: 570|回复: 1

这是怎么回事

[复制链接]
发表于 2018-8-31 06:54:28 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 lxx25141228 于 2018-8-31 07:03 编辑
  1. import pygame
  2. import sys
  3. import traceback
  4. import myplane
  5. from pygame.locals import *
  6. from random import *

  7. pygame.init()
  8. pygame.mixer.init()

  9. bg_size = width, height = 480,700
  10. screen = pygame.display.set_mode(bg_size)
  11. pygame.display.set_caption("飞机大战 -- FishC Demo")

  12. background = pygame.image.load("images/background.png").convert()

  13. # 载入游戏音乐
  14. pygame.mixer.music.load("sound/game_music.ogg")
  15. pygame.mixer.music.set_volume(0.2)
  16. bullet_sound = pygame.mixer.Sound("sound/bullet.wav")
  17. bullet_sound.set_volume(0.2)
  18. bomb_sound = pygame.mixer.Sound("sound/use_bomb.wav")
  19. bomb_sound.set_volume(0.2)
  20. supply_sound = pygame.mixer.Sound("sound/supply.wav")
  21. supply_sound.set_volume(0.2)
  22. get_bomb_sound = pygame.mixer.Sound("sound/get_bomb.wav")
  23. get_bomb_sound.set_volume(0.2)
  24. get_bullet_sound = pygame.mixer.Sound("sound/get_bullet.wav")
  25. get_bullet_sound.set_volume(0.2)
  26. upgrade_sound = pygame.mixer.Sound("sound/upgrade.wav")
  27. upgrade_sound.set_volume(0.2)
  28. enemy3_fly_sound = pygame.mixer.Sound("sound/enemy3_flying.wav")
  29. enemy3_fly_sound.set_volume(0.5)
  30. enemy1_down_sound = pygame.mixer.Sound("sound/enemy1_down.wav")
  31. enemy1_down_sound.set_volume(0.2)
  32. enemy2_down_sound = pygame.mixer.Sound("sound/enemy2_down.wav")
  33. enemy2_down_sound.set_volume(0.5)
  34. enemy3_down_sound = pygame.mixer.Sound("sound/enemy3_down.wav")
  35. enemy3_down_sound.set_volume(0.5)
  36. me_down_sound = pygame.mixer.Sound("sound/me_down.wav")
  37. me_down_sound.set_volume(0.2)

  38. def main():
  39.     pygame.mixer.music.play(-1)

  40.     # 生成我放飞机
  41.     me = myplane.MyPlane(bg_size)

  42.     running = True

  43.     while running:
  44.         for event in pygame.event.get():
  45.             if event.type == QUIT:
  46.                 pygame.quit()
  47.                 sys.exit()
  48.         # 检测用户的键盘操作
  49.         key_pressed = pygame.key.get_pressed()

  50.         if key_pressed[K_w] or key_pressed[K_UP]:
  51.             me.moveUp()
  52.         if key_pressed[K_s] or key_pressed[K_DOWN]:
  53.             me.moveDown()
  54.         if key_pressed[K_a] or key_pressed[K_LEFT]:
  55.             me.moveLeft()
  56.         if key_pressed[K_d] or key_pressed[K_RIGHT]:
  57.             me.moveRight()

  58.         screen.blit(background,(0,0))
  59.         # 绘制我方飞机
  60.         screen.blit(me.image, me.rect)

  61.         pygame.display.flip()

  62.         clock.tick(60)

  63. if __name__ == "__main__":
  64.     try:
  65.         main()
  66.     except SystemExit:
  67.         pass
  68.     except:
  69.         traceback.print_exc()
  70.         pygame.quit()
  71.         input()

复制代码



错误原因
Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\lzqdzfjw\main.py", line 4, in <module>
    import myplane
ModuleNotFoundError: No module named 'myplane'

自己已经解决了   自己打错字了.....
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2018-8-31 09:11:11 | 显示全部楼层
  1. ModuleNotFoundError: No module named 'myplane'
复制代码

这种情况一般就是包名没打对或者这个包没安装
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-1-1 21:12

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表