{"id":298,"date":"2025-03-31T00:00:19","date_gmt":"2025-03-30T16:00:19","guid":{"rendered":"https:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/"},"modified":"2025-03-31T00:00:19","modified_gmt":"2025-03-30T16:00:19","slug":"%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2","status":"publish","type":"post","link":"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/","title":{"rendered":"\u7528python\u505a\u5c0f\u6e38\u620f\u2014\u2014\u4ee5\u5c04\u51fb\u6e38\u620f\u4e3a\u4f8b"},"content":{"rendered":"<div class=\"article_content clearfix\" id=\"article_content\">\n <link href=\"https:\/\/csdnimg.cn\/release\/blogv2\/dist\/mdeditor\/css\/editerView\/kdoc_html_views-1a98987dfd.css\" rel=\"stylesheet\"\/>\n <link href=\"https:\/\/csdnimg.cn\/release\/blogv2\/dist\/mdeditor\/css\/editerView\/ck_htmledit_views-704d5b9767.css\" rel=\"stylesheet\"\/>\n<div class=\"htmledit_views\" id=\"content_views\">\n<p>\n   \u672c\u535a\u5ba2\u4f7f\u7528\u4e86<br \/>\n   <a href=\"https:\/\/so.csdn.net\/so\/search?q=Pygame&amp;spm=1001.2101.3001.7020\" title=\"Pygame\"><br \/>\n    Pygame<br \/>\n   <\/a><br \/>\n   \u5e93\u6765\u521b\u5efa\u6e38\u620f\u7a97\u53e3\u548c\u5904\u7406\u6e38\u620f\u903b\u8f91\u3002\n  <\/p>\n<p id=\"main-toc\">\n   <strong><br \/>\n    \u76ee\u5f55<br \/>\n   <\/strong>\n  <\/p>\n<p id=\"%E4%B8%80%E3%80%81%E4%BB%A3%E7%A0%81%E7%9A%84%E8%AF%A6%E7%BB%86%E8%A7%A3%E9%87%8A%EF%BC%9A-toc\" style=\"margin-left:80px;\">\n   <a href=\"#%E4%B8%80%E3%80%81%E4%BB%A3%E7%A0%81%E7%9A%84%E8%AF%A6%E7%BB%86%E8%A7%A3%E9%87%8A%EF%BC%9A\" rel=\"nofollow\"><br \/>\n    \u4e00\u3001\u4ee3\u7801\u7684\u8be6\u7ec6\u89e3\u91ca\uff1a<br \/>\n   <\/a>\n  <\/p>\n<p id=\"%E5%88%9B%E5%BB%BA%E6%B8%B8%E6%88%8F%E7%AA%97%E5%8F%A3%EF%BC%9A-toc\" style=\"margin-left:200px;\">\n   <a href=\"#%E5%88%9B%E5%BB%BA%E6%B8%B8%E6%88%8F%E7%AA%97%E5%8F%A3%EF%BC%9A\" rel=\"nofollow\"><br \/>\n    \u521b\u5efa\u6e38\u620f\u7a97\u53e3\uff1a<br \/>\n   <\/a>\n  <\/p>\n<p id=\"%E8%9C%9C%E8%9C%82%E7%9A%84%E5%AE%9A%E4%B9%89%E4%B8%8E%E5%BE%AA%E7%8E%AF%E5%87%BA%E7%8E%B0%EF%BC%9A-toc\" style=\"margin-left:200px;\">\n   <a href=\"#%E8%9C%9C%E8%9C%82%E7%9A%84%E5%AE%9A%E4%B9%89%E4%B8%8E%E5%BE%AA%E7%8E%AF%E5%87%BA%E7%8E%B0%EF%BC%9A\" rel=\"nofollow\"><br \/>\n    \u871c\u8702\u7684\u5b9a\u4e49\u4e0e\u5faa\u73af\u51fa\u73b0\uff1a<br \/>\n   <\/a>\n  <\/p>\n<p id=\"%E6%98%BE%E7%A4%BA%E8%9C%9C%E8%9C%82%E5%92%8C%E5%A4%84%E7%90%86%E7%A2%B0%E6%92%9E%EF%BC%9A-toc\" style=\"margin-left:200px;\">\n   <a href=\"#%E6%98%BE%E7%A4%BA%E8%9C%9C%E8%9C%82%E5%92%8C%E5%A4%84%E7%90%86%E7%A2%B0%E6%92%9E%EF%BC%9A\" rel=\"nofollow\"><br \/>\n    \u663e\u793a\u871c\u8702\u548c\u5904\u7406\u78b0\u649e\uff1a<br \/>\n   <\/a>\n  <\/p>\n<p id=\"%E5%AE%9A%E4%B9%89%E5%B0%84%E5%87%BB%E5%99%A8%EF%BC%9A-toc\" style=\"margin-left:200px;\">\n   <a href=\"#%E5%AE%9A%E4%B9%89%E5%B0%84%E5%87%BB%E5%99%A8%EF%BC%9A\" rel=\"nofollow\"><br \/>\n    \u5b9a\u4e49\u5c04\u51fb\u5668\uff1a<br \/>\n   <\/a>\n  <\/p>\n<p id=\"%E5%AD%90%E5%BC%B9%E7%9A%84%E5%AE%9A%E4%B9%89%E4%B8%8E%E5%A4%84%E7%90%86%E7%A2%B0%E6%92%9E%EF%BC%9A-toc\" style=\"margin-left:200px;\">\n   <a href=\"#%E5%AD%90%E5%BC%B9%E7%9A%84%E5%AE%9A%E4%B9%89%E4%B8%8E%E5%A4%84%E7%90%86%E7%A2%B0%E6%92%9E%EF%BC%9A\" rel=\"nofollow\"><br \/>\n    \u5b50\u5f39\u7684\u5b9a\u4e49\u4e0e\u5904\u7406\u78b0\u649e\uff1a<br \/>\n   <\/a>\n  <\/p>\n<p id=\"%E8%AE%A1%E7%AE%97%E4%B8%A4%E7%82%B9%E9%97%B4%E8%B7%9D%E7%A6%BB%E7%9A%84%E5%87%BD%E6%95%B0%EF%BC%9A-toc\" style=\"margin-left:200px;\">\n   <a href=\"#%E8%AE%A1%E7%AE%97%E4%B8%A4%E7%82%B9%E9%97%B4%E8%B7%9D%E7%A6%BB%E7%9A%84%E5%87%BD%E6%95%B0%EF%BC%9A\" rel=\"nofollow\"><br \/>\n    \u8ba1\u7b97\u4e24\u70b9\u95f4\u8ddd\u79bb\u7684\u51fd\u6570\uff1a<br \/>\n   <\/a>\n  <\/p>\n<p id=\"%E6%92%AD%E6%94%BE%E8%83%8C%E6%99%AF%E9%9F%B3%E4%B9%90%EF%BC%9A-toc\" style=\"margin-left:200px;\">\n   <a href=\"#%E6%92%AD%E6%94%BE%E8%83%8C%E6%99%AF%E9%9F%B3%E4%B9%90%EF%BC%9A\" rel=\"nofollow\"><br \/>\n    \u64ad\u653e\u80cc\u666f\u97f3\u4e50\uff1a<br \/>\n   <\/a>\n  <\/p>\n<p id=\"%E4%B8%BB%E6%B8%B8%E6%88%8F%E5%BE%AA%E7%8E%AF%EF%BC%9A-toc\" style=\"margin-left:200px;\">\n   <a href=\"#%E4%B8%BB%E6%B8%B8%E6%88%8F%E5%BE%AA%E7%8E%AF%EF%BC%9A\" rel=\"nofollow\"><br \/>\n    \u4e3b\u6e38\u620f\u5faa\u73af\uff1a<br \/>\n   <\/a>\n  <\/p>\n<p id=\"%E4%BA%8C%E3%80%81%E5%AE%8C%E6%95%B4%E4%BB%A3%E7%A0%81%E5%B1%95%E7%A4%BA%EF%BC%9A-toc\" style=\"margin-left:80px;\">\n   <a href=\"#%E4%BA%8C%E3%80%81%E5%AE%8C%E6%95%B4%E4%BB%A3%E7%A0%81%E5%B1%95%E7%A4%BA%EF%BC%9A\" rel=\"nofollow\"><br \/>\n    \u4e8c\u3001\u5b8c\u6574\u4ee3\u7801\u5c55\u793a\uff1a<br \/>\n   <\/a>\n  <\/p>\n<p id=\"%E4%B8%89%E3%80%81%E8%A7%86%E9%A2%91%E6%BC%94%E7%A4%BA%EF%BC%9A-toc\" style=\"margin-left:80px;\">\n   <a href=\"#%E4%B8%89%E3%80%81%E8%A7%86%E9%A2%91%E6%BC%94%E7%A4%BA%EF%BC%9A\" rel=\"nofollow\"><br \/>\n    \u4e09\u3001\u89c6\u9891\u6f14\u793a\uff1a<br \/>\n   <\/a>\n  <\/p>\n<p id=\"%E5%9B%9B%E3%80%81Gitee%E4%BB%93%E5%BA%93%E5%9C%B0%E5%9D%80-toc\" style=\"margin-left:80px;\">\n   <a href=\"#%E5%9B%9B%E3%80%81Gitee%E4%BB%93%E5%BA%93%E5%9C%B0%E5%9D%80\" rel=\"nofollow\"><br \/>\n    \u56db\u3001Gitee\u4ed3\u5e93\u5730\u5740<br \/>\n   <\/a>\n  <\/p>\n<hr id=\"hr-toc\"\/>\n<h4 id=\"%E4%B8%80%E3%80%81%E4%BB%A3%E7%A0%81%E7%9A%84%E8%AF%A6%E7%BB%86%E8%A7%A3%E9%87%8A%EF%BC%9A\">\n   \u4e00\u3001\u4ee3\u7801\u7684\u8be6\u7ec6\u89e3\u91ca\uff1a<br \/>\n   <br \/>\n  <\/h4>\n<h6 id=\"%E5%88%9B%E5%BB%BA%E6%B8%B8%E6%88%8F%E7%AA%97%E5%8F%A3%EF%BC%9A\">\n   \u521b\u5efa\u6e38\u620f\u7a97\u53e3\uff1a<br \/>\n  <\/h6>\n<pre><code class=\"language-python\">screen = pygame.display.set_mode((WIDTH, HEIGHT))\npygame.display.set_caption(\"Bee\")\n<\/code><\/pre>\n<p>\n   \u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a&#8221;Bee&#8221;\u7684\u6e38\u620f\u7a97\u53e3\uff0c\u7a97\u53e3\u7684\u5927\u5c0f\u7531<br \/>\n   <code><br \/>\n    WIDTH<br \/>\n   <\/code><br \/>\n   \u548c<br \/>\n   <code><br \/>\n    HEIGHT<br \/>\n   <\/code><br \/>\n   \u53d8\u91cf\u51b3\u5b9a\u3002\n  <\/p>\n<h6 id=\"%E8%9C%9C%E8%9C%82%E7%9A%84%E5%AE%9A%E4%B9%89%E4%B8%8E%E5%BE%AA%E7%8E%AF%E5%87%BA%E7%8E%B0%EF%BC%9A\">\n   \u871c\u8702\u7684\u5b9a\u4e49\u4e0e\u5faa\u73af\u51fa\u73b0\uff1a<br \/>\n  <\/h6>\n<pre><code class=\"language-python\">class Enemy():\n    # \u6784\u9020\u51fd\u6570\n    def __init__(self):\n        self.img = pygame.image.load('bee.png')\n        self.x = random.randint(200, 600)\n        self.y = random.randint(50, 250)\n        self.step = random.randint(2, 6)\n\n    # \u91cd\u7f6e\u871c\u8702\u4f4d\u7f6e\n    def reset(self):\n        self.x = random.randint(200, 600)\n        self.y = random.randint(50, 200)\n\nenemies = []\nfor i in range(number_of_bee):\n    enemies.append(Enemy())\n<\/code><\/pre>\n<p>\n   \u5b9a\u4e49\u4e86\u4e00\u4e2a\u540d\u4e3a<br \/>\n   <code><br \/>\n    Enemy<br \/>\n   <\/code><br \/>\n   \u7684\u7c7b\uff0c\u6bcf\u4e2a\u871c\u8702\u5bf9\u8c61\u6709\u56fe\u50cf\u3001x\u5750\u6807\u3001y\u5750\u6807\u548c\u6b65\u957f\u3002\u871c\u8702\u7684\u5faa\u73af\u51fa\u73b0\u5728<br \/>\n   <code><br \/>\n    enemies<br \/>\n   <\/code><br \/>\n   \u5217\u8868\u4e2d\uff0c\u521d\u59cb\u4f4d\u7f6e\u968f\u673a\u3002\n  <\/p>\n<h6 id=\"%E6%98%BE%E7%A4%BA%E8%9C%9C%E8%9C%82%E5%92%8C%E5%A4%84%E7%90%86%E7%A2%B0%E6%92%9E%EF%BC%9A\">\n   \u663e\u793a\u871c\u8702\u548c\u5904\u7406\u78b0\u649e\uff1a<br \/>\n  <\/h6>\n<pre><code class=\"language-python\">def show_bee():\n    for e in enemies:\n        screen.blit(e.img, (e.x, e.y))\n        e.x += e.step\n        if e.x &gt; 736 or e.x &lt; 0:\n            e.step *= -1\n            e.y += 40\n            if e.y &gt;= 450:\n                over, over_rect = init_item('game over.jpg', 0, 0)\n                txt_restart, txt_restart_rect = show_text(\"Restart\", 300, 300, 32)\n                screen.blit(over, over_rect)  ##\u663e\u793agameover\u56fe\u7247\n                screen.blit(txt_restart, txt_restart_rect)\n                quit()\n<\/code><\/pre>\n<p>\n   \u8fd9\u4e2a\u51fd\u6570\u7528\u4e8e\u663e\u793a\u871c\u8702\uff0c\u5e76\u5728\u871c\u8702\u5230\u8fbe\u7a97\u53e3\u8fb9\u7f18\u65f6\uff0c\u8ba9\u5176\u6539\u53d8\u65b9\u5411\u5e76\u5411\u4e0b\u79fb\u52a8\u3002\u5982\u679c\u871c\u8702\u7684y\u5750\u6807\u8d85\u8fc7\u4e86450\uff0c\u5219\u6e38\u620f\u7ed3\u675f\uff0c\u663e\u793a&#8221;game over&#8221;\u56fe\u7247\u548c&#8221;Restart&#8221;\u6587\u5b57\uff0c\u7136\u540e\u9000\u51fa\u6e38\u620f\u3002\n  <\/p>\n<h6 id=\"%E5%AE%9A%E4%B9%89%E5%B0%84%E5%87%BB%E5%99%A8%EF%BC%9A\">\n   \u5b9a\u4e49\u5c04\u51fb\u5668\uff1a<br \/>\n  <\/h6>\n<pre><code class=\"language-python\">play_x = 400\nplay_y = 500\nshoot, shoot_rect = init_item('fighter.png', play_x, play_y)\nplayerstep = 0\n<\/code><\/pre>\n<p>\n   \u5b9a\u4e49\u4e86\u5c04\u51fb\u5668\u7684\u521d\u59cb\u4f4d\u7f6e\uff0c\u5e76\u52a0\u8f7d\u4e86\u5c04\u51fb\u5668\u7684\u56fe\u50cf\u3002\n  <\/p>\n<h6 id=\"%E5%AD%90%E5%BC%B9%E7%9A%84%E5%AE%9A%E4%B9%89%E4%B8%8E%E5%A4%84%E7%90%86%E7%A2%B0%E6%92%9E%EF%BC%9A\">\n   \u5b50\u5f39\u7684\u5b9a\u4e49\u4e0e\u5904\u7406\u78b0\u649e\uff1a<br \/>\n  <\/h6>\n<pre><code class=\"language-python\">class bullet():\n    def __init__(self):\n        self.img = pygame.image.load('bullet1.png')\n        self.x = play_x\n        self.y = play_y + 10\n        self.step = 10  # \u5b50\u5f39\u79fb\u52a8\u7684\u901f\u5ea6\n\n    def hit(self):\n        for e in enemies:\n            if distance(self.x, self.y, e.x, e.y) &lt; 30:\n                bullets.remove(self)\n                e.reset()\n\nbullets = []\n\ndef show_bullets():\n    for b in bullets:\n        screen.blit(b.img, (b.x, b.y))\n        b.hit()\n        b.y -= b.step\n        if b.y &lt; 0:\n            bullets.remove(b)\n<\/code><\/pre>\n<p>\n   \u8fd9\u6bb5\u4ee3\u7801\u5b9a\u4e49\u4e86<br \/>\n   <code><br \/>\n    bullet<br \/>\n   <\/code><br \/>\n   \u7c7b\uff0c\u6bcf\u4e2a\u5b50\u5f39\u5bf9\u8c61\u6709\u56fe\u50cf\u3001x\u5750\u6807\u3001y\u5750\u6807\u548c\u901f\u5ea6\u3002\u5728\u5b50\u5f39\u7684<br \/>\n   <code><br \/>\n    hit()<br \/>\n   <\/code><br \/>\n   \u65b9\u6cd5\u4e2d\uff0c\u68c0\u67e5\u5b50\u5f39\u4e0e\u871c\u8702\u662f\u5426\u78b0\u649e\uff0c\u82e5\u662f\uff0c\u5219\u79fb\u9664\u8be5\u5b50\u5f39\u5e76\u91cd\u65b0\u751f\u6210\u871c\u8702\u3002<br \/>\n   <code><br \/>\n    show_bullets()<br \/>\n   <\/code><br \/>\n   \u51fd\u6570\u7528\u4e8e\u663e\u793a\u5b50\u5f39\uff0c\u5e76\u5728\u5b50\u5f39\u8d85\u51fa\u7a97\u53e3\u65f6\u79fb\u9664\u5b83\u4eec\u3002\n  <\/p>\n<h6 id=\"%E8%AE%A1%E7%AE%97%E4%B8%A4%E7%82%B9%E9%97%B4%E8%B7%9D%E7%A6%BB%E7%9A%84%E5%87%BD%E6%95%B0%EF%BC%9A\">\n   \u8ba1\u7b97\u4e24\u70b9\u95f4\u8ddd\u79bb\u7684\u51fd\u6570\uff1a<br \/>\n  <\/h6>\n<pre><code class=\"language-python\">def distance(bx, by, ex, ey):\n    a = bx - ex\n    b = by - ey\n    return math.sqrt(a * a + b * b)\n<\/code><\/pre>\n<p>\n   \u8fd9\u4e2a\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u4e24\u70b9\u4e4b\u95f4\u7684\u8ddd\u79bb\uff0c\u5176\u4e2d<br \/>\n   <code><br \/>\n    bx<br \/>\n   <\/code><br \/>\n   \u548c<br \/>\n   <code><br \/>\n    by<br \/>\n   <\/code><br \/>\n   \u8868\u793a\u5b50\u5f39\u7684\u5750\u6807\uff0c<br \/>\n   <code><br \/>\n    ex<br \/>\n   <\/code><br \/>\n   \u548c<br \/>\n   <code><br \/>\n    ey<br \/>\n   <\/code><br \/>\n   \u8868\u793a\u871c\u8702\u7684\u5750\u6807\u3002\n  <\/p>\n<h6 id=\"%E6%92%AD%E6%94%BE%E8%83%8C%E6%99%AF%E9%9F%B3%E4%B9%90%EF%BC%9A\">\n   \u64ad\u653e\u80cc\u666f\u97f3\u4e50\uff1a<br \/>\n  <\/h6>\n<pre><code class=\"language-python\">pygame.mixer.music.load('\u80cc\u666f\u97f3\u4e50.mp3')  # \u5bfc\u5165\u97f3\u4e50\npygame.mixer.music.play(loops=-1)  # \u5faa\u73af\u64ad\u653e\n<\/code><\/pre>\n<p>\n   \u8fd9\u6bb5\u4ee3\u7801\u52a0\u8f7d\u540d\u4e3a&#8221;\u80cc\u666f\u97f3\u4e50.mp3&#8243;\u7684\u97f3\u4e50\uff0c\u5e76\u8bbe\u7f6e\u4e3a\u5faa\u73af\u64ad\u653e\u3002\n  <\/p>\n<h6 id=\"%E4%B8%BB%E6%B8%B8%E6%88%8F%E5%BE%AA%E7%8E%AF%EF%BC%9A\">\n   \u4e3b\u6e38\u620f\u5faa\u73af\uff1a<br \/>\n  <\/h6>\n<pre><code class=\"language-python\">clock = pygame.time.Clock()  ##\u7528\u6765\u8bbe\u5b9a\u7a97\u53e3\u7684\u5237\u65b0\u9891\u7387\nwhile True:\n    clock.tick(60)  ##\u6bcf\u79d2\u6267\u884c60\u6b21\n    screen.fill((0, 0, 0))\n\n    for event in pygame.event.get():\n        if event.type == pygame.QUIT:\n            exit()\n        if event.type == pygame.KEYDOWN:\n            if event.key == pygame.K_RIGHT:\n                playerstep = 5\n            elif event.key == pygame.K_LEFT:\n                playerstep = -5\n            elif event.key == pygame.K_SPACE:\n                bullets.append(bullet())\n\n        if event.type == pygame.KEYUP:\n            playerstep = 0\n    screen.blit(shoot, (play_x, play_y))\n    play_x += playerstep\n    if play_x &gt; 736:\n        play_x = 736\n    if play_x &lt; 0:\n        play_x = 0\n    show_bee()\n    show_bullets()\n    pygame.display.flip()\n<\/code><\/pre>\n<p>\n   \u8fd9\u662f\u6e38\u620f\u7684\u4e3b\u5faa\u73af\uff0c\u6e38\u620f\u4f1a\u5728\u6bcf\u6b21\u5faa\u73af\u4e2d\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a\n  <\/p>\n<\/p>\n<p>\n   \u6700\u540e\uff0c\u6e38\u620f\u4f1a\u5728\u4e3b\u5faa\u73af\u4e2d\u4e0d\u65ad\u91cd\u590d\u6267\u884c\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u5b9e\u73b0\u4e86\u871c\u8702\u7684\u5faa\u73af\u51fa\u73b0\u3001\u5c04\u51fb\u5668\u7684\u63a7\u5236\u4ee5\u53ca\u5b50\u5f39\u548c\u871c\u8702\u4e4b\u95f4\u7684\u78b0\u649e\u68c0\u6d4b\u3002\n  <\/p>\n<ul>\n<li>\n    \u8bbe\u7f6e\u7a97\u53e3\u5237\u65b0\u9891\u7387\u4e3a60\u5e27\u3002\n   <\/li>\n<li>\n    \u586b\u5145\u7a97\u53e3\u80cc\u666f\u4e3a\u9ed1\u8272\u3002\n   <\/li>\n<li>\n    \u5904\u7406\u4e8b\u4ef6\uff0c\u5305\u62ec\u6309\u952e\u4e8b\u4ef6\u548c\u9000\u51fa\u4e8b\u4ef6\u3002\n   <\/li>\n<li>\n    \u6839\u636e\u6309\u952e\u4e8b\u4ef6\u79fb\u52a8\u5c04\u51fb\u5668\u7684\u4f4d\u7f6e\uff0c\u5982\u679c\u6309\u4e0b\u7a7a\u683c\u952e\uff0c\u5219\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684\u5b50\u5f39\u5bf9\u8c61\u5230<br \/>\n    <code><br \/>\n     bullets<br \/>\n    <\/code><br \/>\n    \u5217\u8868\u3002\n   <\/li>\n<li>\n    \u663e\u793a\u5c04\u51fb\u5668\u7684\u56fe\u50cf\uff0c\u6839\u636e\u6309\u952e\u4e8b\u4ef6\u79fb\u52a8\u5c04\u51fb\u5668\u7684\u4f4d\u7f6e\uff0c\u4f7f\u5176\u5728\u7a97\u53e3\u5185\u5de6\u53f3\u79fb\u52a8\uff0c\u5e76\u9650\u5236\u5176\u4e0d\u8d85\u51fa\u7a97\u53e3\u8fb9\u754c\u3002\n   <\/li>\n<li>\n    \u8c03\u7528<br \/>\n    <code><br \/>\n     show_bee()<br \/>\n    <\/code><br \/>\n    \u51fd\u6570\uff0c\u663e\u793a\u871c\u8702\uff0c\u5e76\u5904\u7406\u871c\u8702\u4e0e\u7a97\u53e3\u8fb9\u754c\u7684\u78b0\u649e\uff0c\u4ee5\u53ca\u871c\u8702\u4e0e\u5b50\u5f39\u7684\u78b0\u649e\u3002\n   <\/li>\n<li>\n    \u8c03\u7528<br \/>\n    <code><br \/>\n     show_bullets()<br \/>\n    <\/code><br \/>\n    \u51fd\u6570\uff0c\u663e\u793a\u5b50\u5f39\uff0c\u5e76\u5904\u7406\u5b50\u5f39\u4e0e\u7a97\u53e3\u8fb9\u754c\u7684\u78b0\u649e\uff0c\u4ee5\u53ca\u5b50\u5f39\u4e0e\u871c\u8702\u7684\u78b0\u649e\u3002\n   <\/li>\n<li>\n    \u4f7f\u7528<br \/>\n    <code><br \/>\n     pygame.display.flip()<br \/>\n    <\/code><br \/>\n    \u65b9\u6cd5\u66f4\u65b0\u6574\u4e2a\u6e38\u620f\u7a97\u53e3\u3002<\/p>\n<hr\/>\n<h4 id=\"%E4%BA%8C%E3%80%81%E5%AE%8C%E6%95%B4%E4%BB%A3%E7%A0%81%E5%B1%95%E7%A4%BA%EF%BC%9A\">\n     \u4e8c\u3001\u5b8c\u6574\u4ee3\u7801\u5c55\u793a\uff1a<br \/>\n    <\/h4>\n<pre><code class=\"language-python\">import pygame\nimport sys\nimport random\nimport math\n\nWIDTH = 800\nHEIGHT = 600\n\n\ndef pygame_1():\n    global event, e\n    pygame.init()\n    screen = pygame.display.set_mode((WIDTH, HEIGHT))\n    pygame.display.set_caption(\"Bee\")\n    ##\u871c\u8702\uff1a\n    number_of_bee = 6\n    ##\u663e\u793a\u5206\u6570\n    txt_score, txt_score_rect = show_text(\"Score:0\", 40, 20, 20)\n    score = 0\n\n    ##\u871c\u8702\u7684\u5faa\u73af\u51fa\u73b0\n    class Enemy():\n        def __init__(self):\n            self.img = pygame.image.load('bee.png')\n            self.x = random.randint(200, 600)\n            self.y = random.randint(50, 250)\n            self.step = random.randint(2, 6)\n\n        def reset(self):\n            self.x = random.randint(200, 600)\n            self.y = random.randint(50, 200)\n\n    enemies = []\n    for i in range(number_of_bee):\n        enemies.append(Enemy())\n\n    def show_bee():\n        for e in enemies:\n            screen.blit(e.img, (e.x, e.y))\n            e.x += e.step\n            if e.x &gt; 736 or e.x &lt; 0:\n                e.step *= -1\n                e.y += 40\n                if e.y &gt;= 450:\n                    over, over_rect = init_item('game over.jpg', 0, 0)\n                    txt_restart, txt_restart_rect = show_text(\"Restart\", 300, 300, 32)\n                    screen.blit(over, over_rect)  ##\u663e\u793agameover\u56fe\u7247\n                    screen.blit(txt_restart, txt_restart_rect)\n                    quit()\n\n\n    ##\u5c04\u51fb\u5668\n    play_x = 400\n    play_y = 500\n    shoot, shoot_rect = init_item('fighter.png', play_x, play_y)\n    playerstep = 0\n\n    ##\u5b50\u5f39\n    class bullet():\n        def __init__(self):\n            self.img = pygame.image.load('bullet1.png')\n            self.x = play_x\n            self.y = play_y + 10\n            self.step = 10  # \u5b50\u5f39\u79fb\u52a8\u7684\u901f\u5ea6\n\n        def hit(self):\n            for e in enemies:\n                if distance(self.x, self.y, e.x, e.y) &lt; 30:\n                    bullets.remove(self)\n                    e.reset()\n\n\n    bullets = []\n\n    def show_bullets():\n        for b in bullets:\n            screen.blit(b.img, (b.x, b.y))\n            b.hit()\n            b.y -= b.step\n            if b.y &lt; 0:\n                bullets.remove(b)\n\n    def distance(bx, by, ex, ey):\n        a = bx - ex\n        b = by - ey\n        return math.sqrt(a * a + b * b)\n\n    pygame.mixer.music.load('\u80cc\u666f\u97f3\u4e50.mp3')  # \u5bfc\u5165\u97f3\u4e50\n    pygame.mixer.music.play(loops=-1)  # \u5faa\u73af\u64ad\u653e\n    clock = pygame.time.Clock()  ##\u7528\u6765\u8bbe\u5b9a\u7a97\u53e3\u7684\u5237\u65b0\u9891\u7387\n    while True:\n        clock.tick(60)  ##\u6bcf\u79d2\u6267\u884c60\u6b21\n        screen.fill((0, 0, 0))\n\n        for event in pygame.event.get():\n            if event.type == pygame.QUIT:\n                exit()\n            if event.type == pygame.KEYDOWN:\n                if event.key == pygame.K_RIGHT:\n                    playerstep = 5\n                elif event.key == pygame.K_LEFT:\n                    playerstep = -5\n                elif event.key == pygame.K_SPACE:\n                    bullets.append(bullet())\n\n            if event.type == pygame.KEYUP:\n                playerstep = 0\n        screen.blit(shoot, (play_x, play_y))\n        play_x += playerstep\n        if play_x &gt; 736:\n            play_x = 736\n        if play_x &lt; 0:\n            play_x = 0\n        show_bee()\n        show_bullets()\n        pygame.display.flip()\n\n\ndef init_item(img_path, pos_x, pos_y):\n    ##\u663e\u793a\u56fe\u7247\n    item = pygame.image.load(img_path)\n    item_rect = pygame.Rect((pos_x, pos_y, 0, 0))\n    item_rect.size = item.get_size()\n    return item, item_rect\n\n\ndef show_text(txt, pos_x, pos_y, fontsize=12):\n    ##\u8bbe\u5b9a\u663e\u793a\u6587\u672c\u4fe1\u606f\n    font = pygame.font.Font(None, fontsize)\n    text = font.render(txt, True, (255, 0, 0))\n    text_rect = text.get_rect()\n    text_rect.centerx = pos_x\n    text_rect.centery = pos_y\n    return text, text_rect\n\n\nif __name__ == \"__main__\":\n    pygame_1()\n<\/code><\/pre>\n<h4 id=\"%E4%B8%89%E3%80%81%E8%A7%86%E9%A2%91%E6%BC%94%E7%A4%BA%EF%BC%9A\">\n     \u4e09\u3001\u89c6\u9891\u6f14\u793a\uff1a<br \/>\n     <br \/>\n    <\/h4>\n<div class=\"csdn-video-box\" data-report-view='{\"spm\":\"3001.10261\",\"extra\":{\"id\":\"21ZGNVQR-1689903051509\"}}'>\n     <iframe allowfullscreen=\"true\" data-mediaembed=\"bilibili\" frameborder=\"0\" id=\"21ZGNVQR-1689903051509\" src=\"https:\/\/player.bilibili.com\/player.html?aid=231152578\"><br \/>\n     <\/iframe><\/p>\n<p>\n      \u7528python\u505a\u5c0f\u6e38\u620f\u2014\u2014\u4ee5\u5c04\u51fb\u6e38\u620f\u4e3a\u4f8b\u5b50\n     <\/p>\n<\/p><\/div>\n<h4 id=\"%E5%9B%9B%E3%80%81Gitee%E4%BB%93%E5%BA%93%E5%9C%B0%E5%9D%80\" style=\"background-color:transparent;\">\n     \u56db\u3001Gitee\u4ed3\u5e93\u5730\u5740<br \/>\n    <\/h4>\n<\/li>\n<li>\n    <a href=\"https:\/\/gitee.com\/fu-jiamei\/python-work\" rel=\"nofollow\" title=\"Jiamei Fu\/PythonWork - \u7801\u4e91 - \u5f00\u6e90\u4e2d\u56fd (gitee.com)\"><br \/>\n     Jiamei Fu\/PythonWork &#8211; \u7801\u4e91 &#8211; \u5f00\u6e90\u4e2d\u56fd (gitee.com)<br \/>\n    <\/a>\n   <\/li>\n<\/ul><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u535a\u5ba2\u4f7f\u7528\u4e86 Pygame \u5e93\u6765\u521b\u5efa\u6e38\u620f\u7a97\u53e3\u548c\u5904\u7406\u6e38\u620f\u903b\u8f91\u3002 \u76ee\u5f55 \u4e00\u3001\u4ee3\u7801\u7684\u8be6\u7ec6\u89e3\u91ca\uff1a \u521b\u5efa\u6e38\u620f\u7a97\u53e3\uff1a \u871c\u8702 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":215,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-298","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-23"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u7528python\u505a\u5c0f\u6e38\u620f\u2014\u2014\u4ee5\u5c04\u51fb\u6e38\u620f\u4e3a\u4f8b - \u7269\u5ae9\u8f6f\u4ef6\u8d44\u8baf\u7f51<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/\u7528python\u505a\u5c0f\u6e38\u620f-\u4ee5\u5c04\u51fb\u6e38\u620f\u4e3a\u4f8b-2\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u7528python\u505a\u5c0f\u6e38\u620f\u2014\u2014\u4ee5\u5c04\u51fb\u6e38\u620f\u4e3a\u4f8b - \u7269\u5ae9\u8f6f\u4ef6\u8d44\u8baf\u7f51\" \/>\n<meta property=\"og:description\" content=\"\u672c\u535a\u5ba2\u4f7f\u7528\u4e86 Pygame \u5e93\u6765\u521b\u5efa\u6e38\u620f\u7a97\u53e3\u548c\u5904\u7406\u6e38\u620f\u903b\u8f91\u3002 \u76ee\u5f55 \u4e00\u3001\u4ee3\u7801\u7684\u8be6\u7ec6\u89e3\u91ca\uff1a \u521b\u5efa\u6e38\u620f\u7a97\u53e3\uff1a \u871c\u8702 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/\u7528python\u505a\u5c0f\u6e38\u620f-\u4ee5\u5c04\u51fb\u6e38\u620f\u4e3a\u4f8b-2\/\" \/>\n<meta property=\"og:site_name\" content=\"\u7269\u5ae9\u8f6f\u4ef6\u8d44\u8baf\u7f51\" \/>\n<meta property=\"article:published_time\" content=\"2025-03-30T16:00:19+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.wunen.com\/wp-content\/uploads\/2025\/03\/\u8d44\u8baf.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"260\" \/>\n\t<meta property=\"og:image:height\" content=\"180\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin@wunen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin@wunen\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/#article\",\"isPartOf\":{\"@id\":\"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/\"},\"author\":{\"name\":\"admin@wunen\",\"@id\":\"https:\/\/www.wunen.com\/#\/schema\/person\/d5f7a6cf545656a9c90d507e64452db8\"},\"headline\":\"\u7528python\u505a\u5c0f\u6e38\u620f\u2014\u2014\u4ee5\u5c04\u51fb\u6e38\u620f\u4e3a\u4f8b\",\"datePublished\":\"2025-03-30T16:00:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/\"},\"wordCount\":22,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.wunen.com\/#organization\"},\"image\":{\"@id\":\"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/www.wunen.com\/wp-content\/uploads\/2025\/03\/\u8d44\u8baf.jpg\",\"articleSection\":[\"\u5c04\u51fb\u6e38\u620f\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/\",\"url\":\"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/\",\"name\":\"\u7528python\u505a\u5c0f\u6e38\u620f\u2014\u2014\u4ee5\u5c04\u51fb\u6e38\u620f\u4e3a\u4f8b - \u7269\u5ae9\u8f6f\u4ef6\u8d44\u8baf\u7f51\",\"isPartOf\":{\"@id\":\"https:\/\/www.wunen.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/#primaryimage\"},\"image\":{\"@id\":\"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/www.wunen.com\/wp-content\/uploads\/2025\/03\/\u8d44\u8baf.jpg\",\"datePublished\":\"2025-03-30T16:00:19+00:00\",\"breadcrumb\":{\"@id\":\"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/#primaryimage\",\"url\":\"http:\/\/www.wunen.com\/wp-content\/uploads\/2025\/03\/\u8d44\u8baf.jpg\",\"contentUrl\":\"http:\/\/www.wunen.com\/wp-content\/uploads\/2025\/03\/\u8d44\u8baf.jpg\",\"width\":260,\"height\":180},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wunen.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u7528python\u505a\u5c0f\u6e38\u620f\u2014\u2014\u4ee5\u5c04\u51fb\u6e38\u620f\u4e3a\u4f8b\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wunen.com\/#website\",\"url\":\"https:\/\/www.wunen.com\/\",\"name\":\"\u7269\u5ae9\u8f6f\u4ef6\u8d44\u8baf\u7f51\",\"description\":\"\u8f6f\u4ef6\u8d44\u8baf\u6765\u7269\u5ae9\",\"publisher\":{\"@id\":\"https:\/\/www.wunen.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wunen.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.wunen.com\/#organization\",\"name\":\"\u7269\u5ae9\u8f6f\u4ef6\u8d44\u8baf\u7f51\",\"url\":\"https:\/\/www.wunen.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wunen.com\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/www.wunen.com\/wp-content\/uploads\/2025\/03\/cropped-\u7269\u5ae9-1.png\",\"contentUrl\":\"http:\/\/www.wunen.com\/wp-content\/uploads\/2025\/03\/cropped-\u7269\u5ae9-1.png\",\"width\":1024,\"height\":1024,\"caption\":\"\u7269\u5ae9\u8f6f\u4ef6\u8d44\u8baf\u7f51\"},\"image\":{\"@id\":\"https:\/\/www.wunen.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wunen.com\/#\/schema\/person\/d5f7a6cf545656a9c90d507e64452db8\",\"name\":\"admin@wunen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wunen.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d90ec1e3faf77c4d4e66e40c29b85ff6401161e0502f401dae2f0e25b38ce25e?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d90ec1e3faf77c4d4e66e40c29b85ff6401161e0502f401dae2f0e25b38ce25e?s=96&d=mm&r=g\",\"caption\":\"admin@wunen\"},\"sameAs\":[\"http:\/\/www.wunen.com\"],\"url\":\"http:\/\/www.wunen.com\/index.php\/author\/adminwunen\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u7528python\u505a\u5c0f\u6e38\u620f\u2014\u2014\u4ee5\u5c04\u51fb\u6e38\u620f\u4e3a\u4f8b - \u7269\u5ae9\u8f6f\u4ef6\u8d44\u8baf\u7f51","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/\u7528python\u505a\u5c0f\u6e38\u620f-\u4ee5\u5c04\u51fb\u6e38\u620f\u4e3a\u4f8b-2\/","og_locale":"zh_CN","og_type":"article","og_title":"\u7528python\u505a\u5c0f\u6e38\u620f\u2014\u2014\u4ee5\u5c04\u51fb\u6e38\u620f\u4e3a\u4f8b - \u7269\u5ae9\u8f6f\u4ef6\u8d44\u8baf\u7f51","og_description":"\u672c\u535a\u5ba2\u4f7f\u7528\u4e86 Pygame \u5e93\u6765\u521b\u5efa\u6e38\u620f\u7a97\u53e3\u548c\u5904\u7406\u6e38\u620f\u903b\u8f91\u3002 \u76ee\u5f55 \u4e00\u3001\u4ee3\u7801\u7684\u8be6\u7ec6\u89e3\u91ca\uff1a \u521b\u5efa\u6e38\u620f\u7a97\u53e3\uff1a \u871c\u8702 [&hellip;]","og_url":"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/\u7528python\u505a\u5c0f\u6e38\u620f-\u4ee5\u5c04\u51fb\u6e38\u620f\u4e3a\u4f8b-2\/","og_site_name":"\u7269\u5ae9\u8f6f\u4ef6\u8d44\u8baf\u7f51","article_published_time":"2025-03-30T16:00:19+00:00","og_image":[{"width":260,"height":180,"url":"http:\/\/www.wunen.com\/wp-content\/uploads\/2025\/03\/\u8d44\u8baf.jpg","type":"image\/jpeg"}],"author":"admin@wunen","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin@wunen","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/#article","isPartOf":{"@id":"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/"},"author":{"name":"admin@wunen","@id":"https:\/\/www.wunen.com\/#\/schema\/person\/d5f7a6cf545656a9c90d507e64452db8"},"headline":"\u7528python\u505a\u5c0f\u6e38\u620f\u2014\u2014\u4ee5\u5c04\u51fb\u6e38\u620f\u4e3a\u4f8b","datePublished":"2025-03-30T16:00:19+00:00","mainEntityOfPage":{"@id":"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/"},"wordCount":22,"commentCount":0,"publisher":{"@id":"https:\/\/www.wunen.com\/#organization"},"image":{"@id":"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/#primaryimage"},"thumbnailUrl":"http:\/\/www.wunen.com\/wp-content\/uploads\/2025\/03\/\u8d44\u8baf.jpg","articleSection":["\u5c04\u51fb\u6e38\u620f"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/#respond"]}]},{"@type":"WebPage","@id":"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/","url":"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/","name":"\u7528python\u505a\u5c0f\u6e38\u620f\u2014\u2014\u4ee5\u5c04\u51fb\u6e38\u620f\u4e3a\u4f8b - \u7269\u5ae9\u8f6f\u4ef6\u8d44\u8baf\u7f51","isPartOf":{"@id":"https:\/\/www.wunen.com\/#website"},"primaryImageOfPage":{"@id":"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/#primaryimage"},"image":{"@id":"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/#primaryimage"},"thumbnailUrl":"http:\/\/www.wunen.com\/wp-content\/uploads\/2025\/03\/\u8d44\u8baf.jpg","datePublished":"2025-03-30T16:00:19+00:00","breadcrumb":{"@id":"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/"]}]},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/#primaryimage","url":"http:\/\/www.wunen.com\/wp-content\/uploads\/2025\/03\/\u8d44\u8baf.jpg","contentUrl":"http:\/\/www.wunen.com\/wp-content\/uploads\/2025\/03\/\u8d44\u8baf.jpg","width":260,"height":180},{"@type":"BreadcrumbList","@id":"http:\/\/www.wunen.com\/index.php\/2025\/03\/31\/%e7%94%a8python%e5%81%9a%e5%b0%8f%e6%b8%b8%e6%88%8f-%e4%bb%a5%e5%b0%84%e5%87%bb%e6%b8%b8%e6%88%8f%e4%b8%ba%e4%be%8b-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wunen.com\/"},{"@type":"ListItem","position":2,"name":"\u7528python\u505a\u5c0f\u6e38\u620f\u2014\u2014\u4ee5\u5c04\u51fb\u6e38\u620f\u4e3a\u4f8b"}]},{"@type":"WebSite","@id":"https:\/\/www.wunen.com\/#website","url":"https:\/\/www.wunen.com\/","name":"\u7269\u5ae9\u8f6f\u4ef6\u8d44\u8baf\u7f51","description":"\u8f6f\u4ef6\u8d44\u8baf\u6765\u7269\u5ae9","publisher":{"@id":"https:\/\/www.wunen.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wunen.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":"Organization","@id":"https:\/\/www.wunen.com\/#organization","name":"\u7269\u5ae9\u8f6f\u4ef6\u8d44\u8baf\u7f51","url":"https:\/\/www.wunen.com\/","logo":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wunen.com\/#\/schema\/logo\/image\/","url":"http:\/\/www.wunen.com\/wp-content\/uploads\/2025\/03\/cropped-\u7269\u5ae9-1.png","contentUrl":"http:\/\/www.wunen.com\/wp-content\/uploads\/2025\/03\/cropped-\u7269\u5ae9-1.png","width":1024,"height":1024,"caption":"\u7269\u5ae9\u8f6f\u4ef6\u8d44\u8baf\u7f51"},"image":{"@id":"https:\/\/www.wunen.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.wunen.com\/#\/schema\/person\/d5f7a6cf545656a9c90d507e64452db8","name":"admin@wunen","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wunen.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d90ec1e3faf77c4d4e66e40c29b85ff6401161e0502f401dae2f0e25b38ce25e?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d90ec1e3faf77c4d4e66e40c29b85ff6401161e0502f401dae2f0e25b38ce25e?s=96&d=mm&r=g","caption":"admin@wunen"},"sameAs":["http:\/\/www.wunen.com"],"url":"http:\/\/www.wunen.com\/index.php\/author\/adminwunen\/"}]}},"_links":{"self":[{"href":"http:\/\/www.wunen.com\/index.php\/wp-json\/wp\/v2\/posts\/298","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.wunen.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.wunen.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.wunen.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.wunen.com\/index.php\/wp-json\/wp\/v2\/comments?post=298"}],"version-history":[{"count":0,"href":"http:\/\/www.wunen.com\/index.php\/wp-json\/wp\/v2\/posts\/298\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.wunen.com\/index.php\/wp-json\/wp\/v2\/media\/215"}],"wp:attachment":[{"href":"http:\/\/www.wunen.com\/index.php\/wp-json\/wp\/v2\/media?parent=298"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wunen.com\/index.php\/wp-json\/wp\/v2\/categories?post=298"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wunen.com\/index.php\/wp-json\/wp\/v2\/tags?post=298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}