• 大小: 13KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-08-12
  • 语言: 其他
  • 标签: Pygame  Tetris  

资源简介

Pygame游戏源代码:俄罗斯方块 包含代码、图片、声音等所有资源,可直接运行

资源截图

代码片段和文件信息

#!/usr/bin/env python

import pygame
from pygame.locals import *
from pygame.time import *
from sys import exit
from random import *
from shapebase import *
from shapes import *

“““init game“““
pygame.init()
screen = pygame.display.set_mode((800600)032)
pygame.display.set_caption(“Rusia Block“)
icon = pygame.image.load(“py.jpg“)
pygame.display.set_icon(icon)
screen.fill((160160160))

“““some value use in main loop“““
shapeslist = [[[0 for a in range(4)] for b in range(20)] for c in range(16)]##all droped block
cur_pos = [[0 for a in range(2)] for b in range(4)]#current droping block‘position4 block [xy]
rgb = [0 for a in range(3)]#current droping block‘s rgb
bottom = True
right_pos = ((0 for a in range(2)) for b in range(4))#current droping block‘rightshow position
j = 0
total_score = 0


“““the public functions“““
def newShape(cur_pos):
    “““create a new random shape“““
    i = randint(06)
    j = randint(03)
    rgb = [randint(0255)randint(0255)randint(0255)]
    if i == 0:#l2
        if j == 0:
            cur_pos = [[719][718][717][617]]
        elif j == 1:
            cur_pos = [[619][719][819][818]]
        elif j == 2:
            cur_pos = [[719][819][718][717]]
        elif j == 3:
            cur_pos = [[719][718][818][918]]
        ashape = shapeL2(cur_posshapeslistrgb)
    if i == 1:#t
        if j == 0:
            cur_pos = [[719][619][718][819]]
        elif j == 1:
            cur_pos = [[719][718][717][818]]
        elif j == 2:
            cur_pos = [[719][718][618][818]]
        elif j == 3:
            cur_pos = [[719][718][717][618]]
        ashape = shapeT(cur_posshapeslistrgb)
    if i == 2:#z
        if j % 2 == 0:
            cur_pos = [[719][718][619][818]]
        elif j % 2 == 1:
            cur_pos = [[719][718][618][617]]
        ashape = shapeZ(cur_posshapeslistrgb)
    if i == 3:#l
        if j == 0:
            cur_pos = [[719][718][717][817]]
        elif j == 1:
            cur_pos = [[719][718][618][518]]
        elif j == 2:
            cur_pos = [[719][619][718][717]]
        elif j == 3:
            cur_pos = [[719][718][819][919]]
        ashape = shapeL(cur_posshapeslistrgb)
    if i == 4:#z2
        if j % 2 == 0:
            cur_pos = [[719][718][618][819]]
        elif j % 2 == 1:
            cur_pos = [[719][718][818][817]]
        ashape = shapeZ2(cur_posshapeslistrgb)
    if i == 5:#o
        cur_pos = [[719][718][819][818]]
        ashape = shapeO(cur_posshapeslistrgb)
    if i == 6:#i
        if j % 2 == 0:
            cur_pos = [[719][718][717][716]]
        elif j % 2 == 1:
            cur_pos = [[719][619][819][919]]
        ashape = shapeI(cur_posshapeslistrgb)
    return ashape j

def showChanged(screenrgbcur_pos):
    “““flesh screen while k

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       7976  2008-09-10 20:20  main.py

     文件      14289  2008-09-06 11:15  py.jpg

     文件       2929  2008-09-10 20:20  shapebase.py

     文件       3522  2012-07-25 14:53  shapebase.pyc

     文件      10139  2008-09-10 12:31  shapes.py

     文件      16376  2012-07-25 14:53  shapes.pyc

----------- ---------  ---------- -----  ----

                55231                    6


评论

共有 条评论