3个文件,不到400行代码打造经典吃豆人小游戏

C语言零基础项目:吃豆人小游戏!详细思路+源码分享 《吃豆游戏》是一款休闲小游戏,和贪吃蛇,球球大作战吃食物都是有差不多的游戏逻辑。 阅读详情

打造吃豆人小游戏,一共需要这几个文件:
Game.py
Levels.py
Sprites.py
以及一些配置文件与源文件。

废话不多说,直接上代码:

Game.py

"""
Function:
	吃豆豆小游戏
"""
import os
import sys
import pygame
import Levels

"""定义一些必要的参数"""
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
BLUE = (0, 0, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
YELLOW = (255, 255, 0)
PURPLE = (255, 0, 255)
SKYBLUE = (0, 191, 255)
BGMPATH = os.path.join(os.getcwd(), "resources/sounds/bg.mp3")
ICONPATH = os.path.join(os.getcwd(), "resources/images/icon.png")
FONTPATH = os.path.join(os.getcwd(), "resources/font/ALGER.TTF")
HEROPATH = os.path.join(os.getcwd(), "resources/images/pacman.png")
BlinkyPATH = os.path.join(os.getcwd(), "resources/images/Blinky.png")
ClydePATH = os.path.join(os.getcwd(), "resources/images/Clyde.png")
InkyPATH = os.path.join(os.getcwd(), "resources/images/Inky.png")
PinkyPATH = os.path.join(os.getcwd(), "resources/images/Pinky.png")

"""开始某一关游戏"""


def startLevelGame(level, screen, font):
    clock = pygame.time.Clock()
    SCORE = 0
    wall_sprites = level.setupWalls(SKYBLUE)
    gate_sprites = level.setupGate(WHITE)
    hero_sprites, ghost_sprites = level.setupPlayers(
        HEROPATH, [BlinkyPATH, ClydePATH, InkyPATH, PinkyPATH]
    )
    food_sprites = level.setupFood(YELLOW, WHITE)
    is_clearance = False
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit(-1)
                pygame.quit()
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_LEFT:
                    for hero in hero_sprites:
                        hero.changeSpeed([-1, 0])
                        hero.is_move = True
                elif event.key == pygame.K_RIGHT:
                    for hero in hero_sprites:
                        hero.changeSpeed([1, 0])
                        hero.is_move = True
                elif event.key == pygame.K_UP:
                    for hero in hero_sprites:
                        hero.changeSpeed([0, -1])
                        hero.is_move = True
                elif event.key == pygame.K_DOWN:
                    for hero in hero_sprites:
                        hero.changeSpeed([0, 1])
                        hero.is_move = True
            if event.type == pygame.KEYUP:
                if (
                        (event.key == pygame.K_LEFT)
                        or (event.key == pygame.K_RIGHT)
                        or (event.key == pygame.K_UP)
                        or (event.key == pygame.K_DOWN)
                ):
                    hero.is_move = False
        screen.fill(BLACK)
        for hero in hero_sprites:
            hero.update(wall_sprites, gate_sprites)
        hero_sprites.draw(screen)
        for hero in hero_sprites:
            food_eaten = pygame.sprite.spritecollide(hero, food_sprites, True)
        SCORE += len(food_eaten)
        wall_sprites.draw(screen)
        gate_sprites.draw(screen)
        food_sprites.draw(screen)
        for ghost in ghost_sprites:
            # 幽灵随机运动(效果不好且有BUG)
            """
            res = ghost.update(wall_sprites, None)
            while not res:
                ghost.changeSpeed(ghost.randomDirection())
                res = ghost.update(wall_sprites, None)
            """
            # 指定幽灵运动路径
            if ghost.tracks_loc[1] < ghost.tracks[ghost.tracks_loc[0]][2]:
                ghost.changeSpeed(ghost.tracks[ghost.tracks_loc[0]][0:2])
                ghost.tracks_loc[1] += 1
            else:
                if ghost.tracks_loc[0] < len(ghost.tracks) - 1:
                    ghost.tracks_loc[0] += 1
                elif ghost.role_name == "Clyde":
                    ghost.tracks_loc[0] = 2
                else:
                    ghost.tracks_loc[0] = 0
                ghost.changeSpeed(ghost.tracks[ghost.tracks_loc[0]][0:2])
                ghost.tracks_loc[1] = 0
            if ghost.tracks_loc[1] < ghost.tracks[ghost.tracks_loc[0]][2]:
                ghost.changeSpeed(ghost.tracks[ghost.tracks_loc[0]][0:2])
            else:
                if ghost.tracks_loc[0] < len(ghost.tracks) - 1:
                    loc0 = ghost.tracks_loc[0] + 1
                elif ghost.role_name == "Clyde":
                    loc0 = 2
                else:
                    loc0 = 0
                ghost.changeSpeed(ghost.tracks[loc0][0:2])
            ghost.update(wall_sprites, None)
        ghost_sprites.draw(screen)
        score_text = font.render("Score: %s" % SCORE, True, RED)
        screen.blit(score_text, [10, 10])
        if len(food_sprites) == 0:
            is_clearance = True
            break
        if pygame.sprite.groupcollide(hero_sprites, ghost_sprites, False, False):
            is_clearance = False
            break
        pygame.display.flip()
        clock.tick(10)
    return is_clearance


"""显示文字"""


def showText(screen, font, is_clearance, flag=False):
    clock = pygame.time.Clock()
    msg = "Game Over!" if not is_clearance else "Congratulations, you won!"
    positions = (
        [[235, 233], [65, 303], [170, 333]]
        if not is_clearance
        else [[145, 233], [65, 303], [170, 333]]
    )
    surface = pygame.Surface((400, 200))
    surface.set_alpha(10)
    surface.fill((128, 128, 128))
    screen.blit(surface, (100, 200))
    texts = [
        font.render(msg, True, WHITE),
        font.render("Press ENTER to continue or play again.", True, WHITE),
        font.render("Press ESCAPE to quit.", True, WHITE),
    ]
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()
                pygame.quit()
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_RETURN:
                    if is_clearance:
                        if not flag:
                            return
                        else:
                            main(initialize())
                    else:
                        main(initialize())
                elif event.key == pygame.K_ESCAPE:
                    sys.exit()
                    pygame.quit()
        for idx, (text, position) in enumerate(zip(texts, positions)):
            screen.blit(text, position)
        pygame.display.flip()
        clock.tick(10)


"""初始化"""


def initialize():
    pygame.init()
    icon_image = pygame.image.load(ICONPATH)
    pygame.display.set_icon(icon_image)
    screen = pygame.display.set_mode([606, 606])
    pygame.display.set_caption("吃豆人")
    return screen


"""主函数"""


def main(screen):
    pygame.mixer.init()
    pygame.mixer.music.load(BGMPATH)
    pygame.mixer.music.play(-1, 0.0)
    pygame.font.init()
    font_small = pygame.font.Font(FONTPATH, 18)
    font_big = pygame.font.Font(FONTPATH, 24)
    for num_level in range(1, Levels.NUMLEVELS + 1):
        if num_level == 1:
            level = Levels.Level1()
            is_clearance = startLevelGame(level, screen, font_small)
            if num_level == Levels.NUMLEVELS:
                showText(screen, font_big, is_clearance, True)
            else:
                showText(screen, font_big, is_clearance)


"""test"""
if __name__ == "__main__":
    main(initialize())

这里我们采用了pygame来进行游戏的主要设计。

Levels.py

'''
Function:
	定义关卡
'''
import pygame
from Sprites import *

NUMLEVELS = 1

'''关卡一'''


class Level1():
    def __init__(self):
        self.info = 'level1'

    '''创建墙'''

    def setupWalls(self, wall_color):
        self.wall_sprites = pygame.sprite.Group()
        wall_positions = [[0, 0, 6, 600],
                          [0, 0, 600, 6],
                          [0, 600, 606, 6],
                          [600, 0, 6, 606],
                          [300, 0, 6, 66],
                          [60, 60, 186, 6],
                          [360, 60, 186, 6],
                          [60, 120, 66, 6],
                          [60, 120, 6, 126],
                          [180, 120, 246, 6],
                          [300, 120, 6, 66],
                          [480, 120, 66, 6],
                          [540, 120, 6, 126],
                          [120, 180, 126, 6],
                          [120, 180, 6, 126],
                          [360, 180, 126, 6],
                          [480, 180, 6, 126],
                          [180, 240, 6, 126],
                          [180, 360, 246, 6],
                          [420, 240, 6, 126],
                          [240, 240, 42, 6],
                          [324, 240, 42, 6],
                          [240, 240, 6, 66],
                          [240, 300, 126, 6],
                          [360, 240, 6, 66],
                          [0, 300, 66, 6],
                          [540, 300, 66, 6],
                          [60, 360, 66, 6],
                          [60, 360, 6, 186],
                          [480, 360, 66, 6],
                          [540, 360, 6, 186],
                          [120, 420, 366, 6],
                          [120, 420, 6, 66],
                          [480, 420, 6, 66],
                          [180, 480, 246, 6],
                          [300, 480, 6, 66],
                          [120, 540, 126, 6],
                          [360, 540, 126, 6]]
        for wall_position in wall_positions:
            wall = Wall(*wall_position, wall_color)
            self.wall_sprites.add(wall)
        return self.wall_sprites

    '''创建门'''

    def setupGate(self, gate_color):
        self.gate_sprites = pygame.sprite.Group()
        self.gate_sprites.add(Wall(282, 242, 42, 2, gate_color))
        return self.gate_sprites

    '''创建角色'''

    def setupPlayers(self, hero_image_path, ghost_images_path):
        self.hero_sprites = pygame.sprite.Group()
        self.ghost_sprites = pygame.sprite.Group()
        self.hero_sprites.add(Player(287, 439, hero_image_path))
        for each in ghost_images_path:
            role_name = each.split('/')[-1].split('.')[0]
            if role_name == 'Blinky':
                player = Player(287, 199, each)
                player.is_move = True
                player.tracks = [[0, -0.5, 4], [0.5, 0, 9], [0, 0.5, 11], [0.5, 0, 3], [0, 0.5, 7], [-0.5, 0, 11],
                                 [0, 0.5, 3],
                                 [0.5, 0, 15], [0, -0.5, 15], [0.5, 0, 3], [0, -0.5, 11], [-0.5, 0, 3], [0, -0.5, 11],
                                 [-0.5, 0, 3],
                                 [0, -0.5, 3], [-0.5, 0, 7], [0, -0.5, 3], [0.5, 0, 15], [0, 0.5, 15], [-0.5, 0, 3],
                                 [0, 0.5, 3],
                                 [-0.5, 0, 3], [0, -0.5, 7], [-0.5, 0, 3], [0, 0.5, 7], [-0.5, 0, 11], [0, -0.5, 7],
                                 [0.5, 0, 5]]
                self.ghost_sprites.add(player)
            elif role_name == 'Clyde':
                player = Player(319, 259, each)
                player.is_move = True
                player.tracks = [[-1, 0, 2], [0, -0.5, 4], [0.5, 0, 5], [0, 0.5, 7], [-0.5, 0, 11], [0, -0.5, 7],
                                 [-0.5, 0, 3], [0, 0.5, 7], [-0.5, 0, 7], [0, 0.5, 15], [0.5, 0, 15], [0, -0.5, 3],
                                 [-0.5, 0, 11], [0, -0.5, 7], [0.5, 0, 3], [0, -0.5, 11], [0.5, 0, 9]]
                self.ghost_sprites.add(player)
            elif role_name == 'Inky':
                player = Player(255, 259, each)
                player.is_move = True
                player.tracks = [[1, 0, 2], [0, -0.5, 4], [0.5, 0, 10], [0, 0.5, 7], [0.5, 0, 3], [0, -0.5, 3],
                                 [0.5, 0, 3], [0, -0.5, 15], [-0.5, 0, 15], [0, 0.5, 3], [0.5, 0, 15], [0, 0.5, 11],
                                 [-0.5, 0, 3], [0, -0.5, 7], [-0.5, 0, 11], [0, 0.5, 3], [-0.5, 0, 11], [0, 0.5, 7],
                                 [-0.5, 0, 3], [0, -0.5, 3], [-0.5, 0, 3], [0, -0.5, 15], [0.5, 0, 15], [0, 0.5, 3],
                                 [-0.5, 0, 15], [0, 0.5, 11], [0.5, 0, 3], [0, -0.5, 11], [0.5, 0, 11], [0, 0.5, 3],
                                 [0.5, 0, 1]]
                self.ghost_sprites.add(player)
            elif role_name == 'Pinky':
                player = Player(287, 259, each)
                player.is_move = True
                player.tracks = [[0, -1, 4], [0.5, 0, 9], [0, 0.5, 11], [-0.5, 0, 23], [0, 0.5, 7], [0.5, 0, 3],
                                 [0, -0.5, 3], [0.5, 0, 19], [0, 0.5, 3], [0.5, 0, 3], [0, 0.5, 3], [0.5, 0, 3],
                                 [0, -0.5, 15], [-0.5, 0, 7], [0, 0.5, 3], [-0.5, 0, 19], [0, -0.5, 11], [0.5, 0, 9]]
                self.ghost_sprites.add(player)
        return self.hero_sprites, self.ghost_sprites

    '''创建食物'''

    def setupFood(self, food_color, bg_color):
        self.food_sprites = pygame.sprite.Group()
        for row in range(19):
            for col in range(19):
                if (row == 7 or row == 8) and (col == 8 or col == 9 or col == 10):
                    continue
                else:
                    food = Food(30 * col + 32, 30 * row + 32, 4, 4, food_color, bg_color)
                    is_collide = pygame.sprite.spritecollide(food, self.wall_sprites, False)
                    if is_collide:
                        continue
                    is_collide = pygame.sprite.spritecollide(food, self.hero_sprites, False)
                    if is_collide:
                        continue
                    self.food_sprites.add(food)
        return self.food_sprites

Levels的作用是定义关卡。

Sprites.py

'''
Function:
	定义一些精灵类
'''
import random
import pygame

'''墙类'''


class Wall(pygame.sprite.Sprite):
    def __init__(self, x, y, width, height, color, **kwargs):
        pygame.sprite.Sprite.__init__(self)
        self.image = pygame.Surface([width, height])
        self.image.fill(color)
        self.rect = self.image.get_rect()
        self.rect.left = x
        self.rect.top = y


'''食物类'''


class Food(pygame.sprite.Sprite):
    def __init__(self, x, y, width, height, color, bg_color, **kwargs):
        pygame.sprite.Sprite.__init__(self)
        self.image = pygame.Surface([width, height])
        self.image.fill(bg_color)
        self.image.set_colorkey(bg_color)
        pygame.draw.ellipse(self.image, color, [0, 0, width, height])
        self.rect = self.image.get_rect()
        self.rect.left = x
        self.rect.top = y


'''角色类'''


class Player(pygame.sprite.Sprite):
    def __init__(self, x, y, role_image_path):
        pygame.sprite.Sprite.__init__(self)
        self.role_name = role_image_path.split('/')[-1].split('.')[0]
        self.base_image = pygame.image.load(role_image_path).convert()
        self.image = self.base_image.copy()
        self.rect = self.image.get_rect()
        self.rect.left = x
        self.rect.top = y
        self.prev_x = x
        self.prev_y = y
        self.base_speed = [30, 30]
        self.speed = [0, 0]
        self.is_move = False
        self.tracks = []
        self.tracks_loc = [0, 0]

    '''改变速度方向'''

    def changeSpeed(self, direction):
        if direction[0] < 0:
            self.image = pygame.transform.flip(self.base_image, True, False)
        elif direction[0] > 0:
            self.image = self.base_image.copy()
        elif direction[1] < 0:
            self.image = pygame.transform.rotate(self.base_image, 90)
        elif direction[1] > 0:
            self.image = pygame.transform.rotate(self.base_image, -90)
        self.speed = [direction[0] * self.base_speed[0], direction[1] * self.base_speed[1]]
        return self.speed

    '''更新角色位置'''

    def update(self, wall_sprites, gate_sprites):
        if not self.is_move:
            return False
        x_prev = self.rect.left
        y_prev = self.rect.top
        self.rect.left += self.speed[0]
        self.rect.top += self.speed[1]
        is_collide = pygame.sprite.spritecollide(self, wall_sprites, False)
        if gate_sprites is not None:
            if not is_collide:
                is_collide = pygame.sprite.spritecollide(self, gate_sprites, False)
        if is_collide:
            self.rect.left = x_prev
            self.rect.top = y_prev
            return False
        return True

    '''生成随机的方向'''

    def randomDirection(self):
        return random.choice([[-0.5, 0], [0.5, 0], [0, 0.5], [0, -0.5]])

这是为了让怪物与吃豆人运动的一系列操作。

到这里我们的整个游戏设计就结束了,只要运行Game.py,就可以尽情地玩耍啦。让我们来看看效果如何:在这里插入图片描述

在这里插入图片描述
到这里我们的文章就结束了,想偷懒的小伙伴们请注意,这里有我已经做好的成品,放在百度网盘里,不拿白不拿哦!
链接:https://pan.baidu.com/s/1JiqwK4kWZkXLJ1G7ThT2ZA
提取码:0721


原创不易,求打赏 :)

关于我:11岁小学生,马上六年级了,喜欢个人研究一些python和c++的编程内容,希望以后能去大厂(最好是鹅厂)工作。

C++写吃豆人 printf("现在切换到地图编辑模式\n\nq/4 为开始放置模式(光标移动过的痕迹会留下障碍物)\n\ne/6 为取消放置障碍物模式\n\nj/0 为橡皮模式(再按一次退出橡皮模式)\n\n按 h/+ 继续游戏\n\n"); 阅读详情

相关推荐

Pygame经典小游戏--贪吃蛇(完整代码+部分代码讲解)

通过本次对贪吃蛇游戏的改进和优化,提升了游戏的可玩性和趣味性,为玩家带来更加丰富和多样的游戏体验。如果你也对这款游戏感兴趣,不妨自己动手尝试一下,相信你会在编程的过程中找到无尽的乐趣和成就感!

m0_62857127的博客 5615

Python实现经典吃豆豆游戏教程:重温童年经典,学习Python游戏开发,附带完整源码

创建一个“吃豆豆”小游戏是使用Python及其图形库Tkinter的一个很好的练习。以下是一个简单的“吃豆豆”游戏项目的示例代码。请注意,这个代码是一个非常基础的实现,没有分数、胜利条件或者复杂的游戏逻辑。你可以在此基础上添加更多的功能,比如增加食物点、计分系统、不同的敌人行为等,以制作一个更加完整的游戏。这个代码创建了一个窗口,玩家可以使用键盘方向键控制一个白色方块移动,同时有一些红色的小方块作为敌人随机移动。如果玩家和任何一个敌人碰撞,游戏将会结束。首先,确保你已经安装了。模块来处理游戏逻辑。

程序熊的博客 542

Vue 3 + Phaser 3 实战:手把手教你打造一个可交互的2D小游戏(附完整源码)

本文详细介绍了如何使用Vue 3和Phaser 3集成开发一个可交互的2D小游戏。从环境搭建、项目初始化到核心游戏机制实现,再到Vue与Phaser的状态同步,手把手教你完成一个太空射击游戏的开发。文章还分享了性能优化和调试技巧,并提供了完整源码,帮助开发者快速掌握游戏开发与前端框架的完美结合。

weixin_33701617的博客 263

游戏——吃豆人

暑假自己写了个c++的吃豆人

hehepig的博客 2万+

Python与Pygame打造经典俄罗斯方块:从零开始的游戏开发指南

本文是一份详细的Python与Pygame游戏开发指南,教你从零开始构建经典的俄罗斯方块小游戏。文章涵盖了环境搭建、核心游戏循环、方块与网格定义、碰撞检测、旋转逻辑、消行计分等完整开发流程,适合Python初学者通过实践项目掌握游戏开发基础。

weixin_29204121的博客 229

用EasyX在C++中打造你的第一个3D小游戏:从立方体到简易FPS

本文详细介绍了如何使用EasyX在C++中开发3D小游戏,从绘制立方体到构建简易FPS游戏框架。通过清晰的代码示例和分步指导,帮助开发者掌握3D图形基础、摄像机系统实现和游戏场景优化等核心技能,适合C++初学者快速入门3D游戏开发。

weixin_30733003的博客 217

Levels - 在UE4中快速搭建场景(一)

利用素材快速搭建的UE4场景氛围,以及一些性能预览,文档有两篇,此为第一篇;UE4场景,虚幻引擎4相关,3D场景制作相关; 视频链接:https://zhuanlan.zhihu.com/p/58399943 ...

GT的虚幻引擎文档 8293

C#程序设计实践:打造2048小游戏

C#语言在2000年被推出,最初是为了适应快速发展的网络和电子商务应用。随着.NET框架的发展,C#逐渐成为企业级应用开发的首选语言之一。它融合了C++的性能和Visual Basic的易用性,成为了一个功能强大、类型安全的编程语言。2048是一个数字拼图游戏,玩家通过上下左右滑动屏幕上的数字方块,以实现它们的合并和移动。目标是在4x4的游戏板上,通过合并相同数字的方块,最终生成一个“2048”方块。每当玩家合并两个方块,都会得到一个新的方块,其数值为原来两个方块数值之和。

weixin_34885746的博客 652

用HTML5 Canvas和JavaScript代码实现打砖块小游戏

打砖块是一款经典的休闲游戏,玩家操控底部的挡板反弹小球,小球撞击并消除上方的砖块,直到所有砖块被清除。上述代码创建了一个600x400像素的Canvas画布,用于绘制游戏内容,还引入了外部JavaScript文件,后续将在其中编写游戏逻辑。1. 定义游戏元素和初始状态:在JavaScript文件中,定义小球、挡板、砖块等游戏元素,并设置它们的初始属性。3. 小球和挡板的运动与交互:实现小球的运动逻辑,包括碰撞检测和反弹,以及挡板的移动控制。// 重置游戏状态的逻辑。// 重置游戏状态的逻辑。

xuanyan19920827的博客 1966

吃豆人 c++ 源程序

自己打的,希望喜欢, 有三只小怪物,运动方式不同, 不过大力丸是以自己控制的方式设置的, 按g开启大力丸模式, 请多指教! 使用dev-c++ 5.5.3 编译(一般vs等都能编译)

c++游戏——吃豆人(普通版)

c++游戏——吃豆人(普通版)

探索未来游戏开发:用AI打造属于你的Pygame小游戏

最新接入DeepSeek-V3模型,点击下载最新版本InsCode AI IDE 探索未来游戏开发:用AI打造属于你的Pygame小游戏 在当今科技飞速发展的时代,游戏开发不再是专业程序员的专属领域。随着智能化工具的崛起,即使是编程小白也能轻松上手,制作出属于自己的小游戏。今天,我们将以Pygame为例,探讨如何利用先进的AI技术快速开发一款趣味横生的小游戏,并向大家展示这种智能化工具的强大功能和...

SunstoneLion34的博客 835

飞塔防火墙之Link Monitor

Link Monitor类似于SLA,飞塔防火墙线路质量探测的一个功能。

weixin_41903258的博客 2408

用AI打造你的专属小游戏:从零开始构建Pygame应用

开发AI智能应用,就下载InsCode AI IDE,一键接入DeepSeek-R1满血版大模型! 标题:用AI打造你的专属小游戏:从零开始构建Pygame应用 在数字化时代的浪潮中,游戏开发已经成为越来越多人的兴趣所在。无论是为了娱乐、学习还是创业,开发一款属于自己的小游戏都是一件充满成就感的事情。然而,传统的小游戏开发往往需要深厚的编程基础和大量的时间投入,这让许多初学者望而却步。但现在,借助...

BlackironPanther23的博客 1311

Windows打印体系结构之Windows内置打印驱动程序

时间是一种很残酷的东西,它只会冲淡能够冲淡的,但也会洗尽铅华帮你留下该留下的。1.3.4、Windows内置打印驱动程序现在的Windows下的打印机驱动程序通常分为V4打印机驱动程序(V4 Printer Driver)、XPS打印机驱动程序(XPSDrv)、微软通用打印机驱动程序(Microsoft UniversalPrinter Driver)、微软PostScri...

weixin_34309435的博客 2254

PADS VX2.7学习记录05-PADS Layout设计文件Gerber等输出整理

在“PDF Document”栏中,依次选中除REF-TOP和REF-BOT之外的文件,单击图标,将其余PDF Document文件进行删除,如图所示。然后单击【生成PDF】按钮,即可创建一份PDF格式的位号图。

tianpu2320959696的博客 1025

用HTML5 Canvas打造经典贪吃蛇游戏(附完整代码)

本文详细介绍了如何使用HTML5 Canvas技术从零开始构建经典的贪吃蛇小游戏。通过清晰的步骤讲解和完整的代码示例,涵盖了画布初始化、游戏循环、键盘控制、碰撞检测等核心模块,帮助前端开发者掌握Canvas动画与游戏开发的基础技能,并提供了可运行的完整项目代码。

weixin_29016833的博客 537

Codex登录要手机验证码?Cockpit Tools跳过验证保姆级教程

摘要:OpenAI升级风控后,Codex登录需手机验证,增加批量账号使用成本。CockpitTools(GitHub 8.3k star)可绕过验证,支持多AI编程平台账号管理。操作步骤:1) 获取ChatGPT网页Session数据;2) 通过转换工具生成CPA格式JSON;3) 导入工具启动Codex。注意:仅适用于未绑定手机号的账号,Session会过期,且需防范数据泄露风险。商业账号通常直接提供认证文件。(150字)

5843

从零开始:用Pygame打造趣味小游戏,轻松掌握编程技巧

最新接入DeepSeek-V3模型,点击下载最新版本InsCode AI IDE 从零开始:用Pygame打造趣味小游戏,轻松掌握编程技巧 引言 在当今数字化时代,编程技能已经成为一项必备的工具。无论是开发复杂的商业应用,还是简单的个人项目,编程都为我们的生活带来了极大的便利和乐趣。对于初学者来说,选择一个合适的切入点至关重要。而制作小游戏,尤其是使用Pygame这样的框架,无疑是入门编程的最佳途...

inscode_060的博客 644

TortoiseGit提示No supported authentication methods available错误

一、问题 在使用TortoiseGit与远程仓库进行同步代码的时候提示如下错误,即:没有支持认证的方法可用。而GitBash却可以正常使用,不受影响。 通过调查,发现应该是TortoiseGit远程仓库的公匙无法和本地的密匙进行匹配认证造成的(主要是TortoiseGit缺少本地密匙)。由于TortoiseGit的默认网络SSH client是TortoiseGitPlink.exe,如下图所示。因此主要有两种方式来解决该问题: 不修改TortoiseGit的默认网络SSH client,此时需要为To

Jeffxu_lib的博客 2万+

Serial RapidIO Gen2 IP 说明(一)

概述 高速IO(RapidIO)互联架构,用来兼容当前最流行的集成通信处理器、主处理器、联网的数字信号处理器,是一种高性能、分组交换(报文交换)的互联技术。它解决了高性能嵌入式产业稳定性、高带宽以及系统内部更快的总线速率的需求。 高速IO(RapidIO)标准由三层定义:逻辑层、传输层、物理层。逻辑层定义了所有的协议内容和报文格式。这些是终端发起和完成一次传输所必需的信息。传输层提供了报文从一个端点传输到另外一个端点必要的路线信息。物理层则描述了设备级的端口声明,如报...

记录所学,分享知识,结识挚友 1497

C语言开发打气球小游戏

C语言开发打气球小游戏 首先我们写一下项目所需要的头文件 #include<stdio.h>//标准输入输出头文件 #include<math.h>//数学库头文件 #include<graphics.h>//EasyX图形库头文件 #include<mmsystem.h>//多媒体音乐库头文件 #pragma comment(lib,"winmm.lib")//导入winmm库 #pragma warning(disable : 4996)//4996警告杂

mmg5j64的博客 5896

基于点云数据的统计滤波算法改进

随着三维视觉和点云处理技术的发展,点云数据在机器人、自动驾驶、增强现实等领域得到了广泛应用。而点云数据中常常包含着各种噪声和异常点,这些噪声和异常点会影响后续的数据处理和分析任务。因此,对点云数据进行滤波处理是必不可少的一步。在点云滤波算法中,统计滤波(Statistical Filtering)是一种常见且有效的方法。它通过对点云数据进行统计分析,将噪声和异常点剔除或修复,从而得到更为准确和可靠的点云数据。本文将介绍一种改进的统计滤波算法,并提供相应的源代码实现。

QfcaLinux的博客 292

如何处理前端文件上传?

如何处理前端文件上传?

商务合作欢迎私信我 1万+

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

上一篇: python简易爬虫v1.0
下一篇: 一行代码玩童年小游戏
ternary_tree
博客等级 码龄6年 82粉丝 11原创
评论 4
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值