python-pygame激动时刻你我共享
生活随笔
收集整理的這篇文章主要介紹了
python-pygame激动时刻你我共享
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
這個小的游戲程序主要是參考的目光博客大神的一篇小文章,有興趣的可以去看一下
程序需要的圖片如下:
let’s go just do it!
background_image_filename = 'sushiplate.jpg' mouse_image_filename = 'fugu.png'import pygamefrom pygame.locals import *from sys import exitpygame.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() / 2y-= mouse_cursor.get_height() / 2screen.blit(mouse_cursor, (x, y))pygame.display.update()運行的效果圖如下:
總結
以上是生活随笔為你收集整理的python-pygame激动时刻你我共享的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: STM32F103系列单片机学习笔记1方
- 下一篇: 作者:石勇(1956-),男,中国科学院