易截截图软件、单文件、免安装、纯绿色、仅160KB

python 俄罗斯方块

这个算是C++嵌入python吧,利用python实现显示和事件处理,C++实现逻辑
以后有时间也会反过来试试:) 
import pygame
import sys
import os
import ctypes
def cur_file_dir():
#获取脚本路径
path = sys.path[0]
#判断为脚本文件还是py2exe编译后的文件,如果是脚本文件,则返回的是脚本的目录,如果是py2exe编译后的文件,则返回的是编译后的文件路径
if os.path.isdir(path):
return path
elif os.path.isfile(path):
return os.path.dirname(path)

#call dll
path = cur_file_dir()
print path
rblogic = ctypes.CDLL(path+r'\rblogic.dll')
#pygame init
pygame.init()
screen = pygame.display.set_mode((640,500),0,32)
pygame.display.set_caption('RussiaBoxGame!_by warmtrue')
rblogic.InitGame()
moveflag = 0
font = pygame.font.Font(os.environ['SYSTEMROOT'] + u"\\Fonts\\simsun.ttc", 40)
fontsmall = pygame.font.Font(os.environ['SYSTEMROOT'] + u"\\Fonts\\simsun.ttc", 15)
fontless = pygame.font.Font(os.environ['SYSTEMROOT'] + u"\\Fonts\\simsun.ttc", 15)
#game main loop
while True:
screen.fill((0,0,0))
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
pygame.quit()
sys.exit()
elif event.type == pygame.KEYDOWN and event.key == pygame.K_UP:
moveflag = 4
elif event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT:
moveflag = 1
elif event.type == pygame.KEYDOWN and event.key == pygame.K_DOWN:
moveflag = 3
elif event.type == pygame.KEYDOWN and event.key == pygame.K_RIGHT:
moveflag = 2
elif event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:
moveflag = 6
moveflag = rblogic.GameLoop(moveflag)
for i in range(0,19):
for j in range(0,10):
t = rblogic.check(i,j)
if t > 0:
if t ==


相关文档:

Installing Python 安装Python


   
You are here: Home ‣ Dive Into Python 3 ‣
Difficulty level: ♦♢♢♢♢
Installing Python 安装Python
❝ Tempora mutantur nos et mutamur in illis. (Times change, and we change with them.) ❞
— ancient Roman proverb
 
D ......

python中文件和目录操作

1.获得当前路径
在Python中可以使用os.getcwd()函数获得当前的路径。其原型如下所示。
os.getcwd()
该函数不需要传递参数,它返回当前的目录。需要说明的是,当前目录并不是指脚本所在的目录,而是所运行脚本的目录。例如,在PythonWin中输入如下脚本。
>>> import os
>>> print 'current director ......

Python 线程池


import Queue, threading, sys
from threading import Thread
import time,urllib
# working thread
class Worker(Thread):
   worker_count = 0
   def __init__( self, workQueue, resultQueue, timeout = 0, **kwds):
       Thread.__init__( self, **kwds ) ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号