前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >学习-用Python和Pygame写游戏-从入门到精通(6)

学习-用Python和Pygame写游戏-从入门到精通(6)

作者头像
十四君
发布2019-11-28 00:06:58
4920
发布2019-11-28 00:06:58
举报
文章被收录于专栏:UrlteamUrlteam

本文干货很多,so给一个传送门,咱们就不搬砖了。http://python.jobbole.com/83523/

代码记录在git上 6.xiangsu

下面的小脚本会随机的在屏幕上画点:

Python

import pygame from pygame.locals import * from sys import exit from random import randint pygame.init() screen = pygame.display.set_mode((1024,800),0,32) while True: for event in pygame.event.get(): if event.type == QUIT: exit() rand_col = (randint(0,255),randint(0,255),randint(0,255)) for _ in xrange(100): rand_pos = (randint(0,1024),randint(0,799)) screen.set_at(rand_pos,rand_col) pygame.display.update()

12345678910111213141516171819

import pygamefrom pygame.locals import *from sys import exitfrom random import randint pygame.init()screen = pygame.display.set_mode((1024,800),0,32) while True:    for event in pygame.event.get():        if event.type == QUIT:            exit()     rand_col = (randint(0,255),randint(0,255),randint(0,255))    for _ in xrange(100):        rand_pos = (randint(0,1024),randint(0,799))        screen.set_at(rand_pos,rand_col)     pygame.display.update()

15
15

效果如上图。。。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2015-12-24,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档