摘要: 本节讲解游戏界面中字体的处理,以在界面中实时显示当前时间、小球位置为例进行实验,具体见代码。一、代码# -*- coding:utf-8 -*- import os import sys import time import pygame from pygame.locals import * from pygame.font import * def load_image(pic_name): ''' Function:图片加载函数 Input:pic_name 图片名称 Output: NONE author: socrates b... 阅读全文
posted @ 2012-04-15 20:31 Socrates 阅读(1007) 评论(0) 推荐(0) 编辑
摘要: 上一节实现了小球自由移动,本节在上节基础上增加通过方向键控制小球运动,并为游戏增加了背景图片。一、实现:# -*- coding:utf-8 -*- import os import sys import pygame from pygame.locals import * def load_image(pic_name): ''' Function:图片加载函数 Input:NONE Output: NONE author: socrates blog:http://blog.csdn.net/dyx1024 date:201... 阅读全文
posted @ 2012-04-15 19:33 Socrates 阅读(775) 评论(1) 推荐(1) 编辑
摘要: 本节实现一个在窗口中自由运动的小球程序,做了详细注释,不多做解释了。代码:# -*- coding:utf-8 -*- import sys import pygame from pygame.locals import * def play_ball(): pygame.init() #窗口大小 window_size = (width, height) =(700, 500) #小球运行偏移量[水平,垂直],值越大,移动越快 speed = [1, 1] #窗口背景色RGB值 color... 阅读全文
posted @ 2012-04-15 17:09 Socrates 阅读(789) 评论(0) 推荐(0) 编辑
摘要: 按照上周计划,今天开始学习pygame,学习资料为http://www.pygame.org/docs/,学习的程序实例为pygame模块自带程序,会在程序中根据自己的理解加入详细注释,并对关键概念做说明。 一、pygame版本的hello world程序。代码:#!/usr/bin/python # -*- coding:utf-8 -*- import sys #导入pygame模块,第8行的作用是简化你的输入,如不用在event前再加上pygame模块名 import pygame from pygame.locals import * def hello_world(): ... 阅读全文
posted @ 2012-04-15 11:52 Socrates 阅读(503) 评论(0) 推荐(0) 编辑