python-pygame激动时刻你我共享

    xiaoxiao2021-12-14  56

    这个小的游戏程序主要是参考的目光博客大神的一篇小文章,有兴趣的可以去看一下 程序需要的图片如下:

    let’s go just do it!

    background_image_filename = 'sushiplate.jpg' mouse_image_filename = 'fugu.png' import pygame from pygame.locals import * from sys import exit pygame.init() screen = pygame.display.set_mode((640, 480), 0, 32) pygame.display.set_caption("fish!") background = pygame.image.load(background_image_filename).convert() mouse_cursor = pygame.image.load(mouse_image_filename).convert_alpha() while True: for event in pygame.event.get(): if event.type == QUIT: exit() screen.blit(background, (0,0)) x, y = pygame.mouse.get_pos() x-= mouse_cursor.get_width() / 2 y-= mouse_cursor.get_height() / 2 screen.blit(mouse_cursor, (x, y)) pygame.display.update()

    运行的效果图如下:

    转载请注明原文地址: https://ju.6miu.com/read-968852.html

    最新回复(0)