├── .gitignore ├── README.md ├── constants.py ├── block.py ├── tetris.py └── LICENSE.md /.gitignore: -------------------------------------------------------------------------------- 1 | /env 2 | 3 | # Byte-compiled / optimized / DLL files 4 | __pycache__ 5 | *.py[cod] 6 | *$py.class 7 | .env -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python Tetris 2 | 3 | This is the repository with non-finished implementation of the tetris. Please, be patient because I am writing it in my free time :-). 4 | 5 | ### Prerequisites 6 | 7 | The game is based on the pygame library. You can install it using the pip tool. 8 | 9 | ``` 10 | pip3 install --user pygame 11 | ``` 12 | 13 | Provided code is written for Python3. After that, you can run the game with: 14 | 15 | ``` 16 | python3 tetris.py 17 | ``` 18 | 19 | 20 | ## Control 21 | 22 | The following list contains used control keys: 23 | 24 | * *Arrows* - used for the moving of a tetris block 25 | * *Space* - rotates the tetris block 26 | * *q* - quit the game 27 | * *p* - pause the game 28 | 29 | ## Authors 30 | 31 | * **Pavel Benáček** - *coding of the game* 32 | 33 | ## License 34 | 35 | This project is licensed under the GNU GPL License - see the [LICENSE.md](LICENSE.md) file for details 36 | -------------------------------------------------------------------------------- /constants.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # File: constants.py 4 | # Description: Basic program constants. 5 | # Author: Pavel Benáček 6 | 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program. If not, see . 19 | 20 | 21 | from pygame.locals import * 22 | 23 | # Configuration of building shape block 24 | # Width of the shape block 25 | BWIDTH = 20 26 | # Height of the shape block 27 | BHEIGHT = 20 28 | # Width of the line around the block 29 | MESH_WIDTH = 1 30 | 31 | # Configuration of the player board 32 | # Board line height 33 | BOARD_HEIGHT = 7 34 | # Margin of upper line (for score) 35 | BOARD_UP_MARGIN = 40 36 | # Margins around all lines 37 | BOARD_MARGIN = 2 38 | 39 | # Color declarations in the RGB notation 40 | WHITE = (255,255,255) 41 | RED = (255,0,0) 42 | GREEN = (0,255,0) 43 | BLUE = (0,0,255) 44 | ORANGE = (255,69,0) 45 | GOLD = (255,125,0) 46 | PURPLE = (128,0,128) 47 | CYAN = (0,255,255) 48 | BLACK = (0,0,0) 49 | 50 | # Timing constraints 51 | # Time for the generation of TIME_MOVE_EVENT (ms) 52 | MOVE_TICK = 1000 53 | # Allocated number for the move dowon event 54 | TIMER_MOVE_EVENT = USEREVENT+1 55 | # Speed up ratio of the game (integer values) 56 | GAME_SPEEDUP_RATIO = 1.5 57 | # Score LEVEL - first threshold of the score 58 | SCORE_LEVEL = 2000 59 | # Score level ratio 60 | SCORE_LEVEL_RATIO = 2 61 | 62 | # Configuration of score 63 | # Number of points for one building block 64 | POINT_VALUE = 100 65 | # Margin of the SCORE string 66 | POINT_MARGIN = 10 67 | 68 | # Font size for all strings (score, pause, game over) 69 | FONT_SIZE = 25 70 | -------------------------------------------------------------------------------- /block.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # File: block.py 4 | # Description: This file contains the declaration of basic tetris block class. 5 | # Author: Pavel Benáček 6 | 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program. If not, see . 19 | 20 | import pdb 21 | 22 | import constants 23 | import pygame 24 | import math 25 | import copy 26 | import sys 27 | 28 | class Block(object): 29 | """ 30 | Class for handling of tetris block 31 | """ 32 | 33 | def __init__(self,shape,x,y,screen,color,rotate_en): 34 | """ 35 | Initialize the tetris block class 36 | 37 | Parameters: 38 | - shape - list of block data. The list contains [X,Y] coordinates of 39 | building blocks. 40 | - x - X coordinate of first tetris shape block 41 | - y - Y coordinate of first tetris shape block 42 | - screen - screen to draw on 43 | - color - the color of each shape block in RGB notation 44 | - rotate_en - enable or disable the rotation 45 | """ 46 | # The initial shape (convert all to Rect objects) 47 | self.shape = [] 48 | for sh in shape: 49 | bx = sh[0]*constants.BWIDTH + x 50 | by = sh[1]*constants.BHEIGHT + y 51 | block = pygame.Rect(bx,by,constants.BWIDTH,constants.BHEIGHT) 52 | self.shape.append(block) 53 | # Setup the rotation attribute 54 | self.rotate_en = rotate_en 55 | # Setup the rest of variables 56 | self.x = x 57 | self.y = y 58 | # Movement in the X,Y coordinates 59 | self.diffx = 0 60 | self.diffy = 0 61 | # Screen to drawn on 62 | self.screen = screen 63 | self.color = color 64 | # Rotation of the screen 65 | self.diff_rotation = 0 66 | 67 | def draw(self): 68 | """ 69 | Draw the block from shape blocks. Each shape block 70 | is filled with a color and black border. 71 | """ 72 | for bl in self.shape: 73 | pygame.draw.rect(self.screen,self.color,bl) 74 | pygame.draw.rect(self.screen,constants.BLACK,bl,constants.MESH_WIDTH) 75 | 76 | def get_rotated(self,x,y): 77 | """ 78 | Compute the new coordinates based on the rotation angle. 79 | 80 | Parameters: 81 | - x - the X coordinate to transfer 82 | - y - the Y coordinate to transfer 83 | 84 | Returns the tuple with new (X,Y) coordinates. 85 | """ 86 | # Use the classic transformation matrix: 87 | # https://www.siggraph.org/education/materials/HyperGraph/modeling/mod_tran/2drota.htm 88 | rads = self.diff_rotation * (math.pi / 180.0) 89 | newx = x*math.cos(rads) - y*math.sin(rads) 90 | newy = y*math.cos(rads) + x*math.sin(rads) 91 | return (newx,newy) 92 | 93 | def move(self,x,y): 94 | """ 95 | Move all elements of the block using the given offset. 96 | 97 | Parameters: 98 | - x - movement in the X coordinate 99 | - y - movement in the Y coordinate 100 | """ 101 | # Accumulate X,Y coordinates and call the update function 102 | self.diffx += x 103 | self.diffy += y 104 | self._update() 105 | 106 | def remove_blocks(self,y): 107 | """ 108 | Remove blocks on the Y coordinate. All blocks 109 | above the Y are moved one step down. 110 | 111 | Parameters: 112 | - y - Y coordinate to work with. 113 | """ 114 | new_shape = [] 115 | for shape_i in range(len(self.shape)): 116 | tmp_shape = self.shape[shape_i] 117 | if tmp_shape.y < y: 118 | # Block is above the y, move down and add it to the list of active shape 119 | # blocks. 120 | new_shape.append(tmp_shape) 121 | tmp_shape.move_ip(0,constants.BHEIGHT) 122 | elif tmp_shape.y > y: 123 | # Block is below the y, add it to the list. The block doesn't need to be moved because 124 | # the removed line is above it. 125 | new_shape.append(tmp_shape) 126 | # Setup the new list of block shapes. 127 | self.shape = new_shape 128 | 129 | def has_blocks(self): 130 | """ 131 | Returns true if the block has some shape blocks in the shape list. 132 | """ 133 | return True if len(self.shape) > 0 else False 134 | 135 | def rotate(self): 136 | """ 137 | Setup the rotation value to 90 degrees. 138 | """ 139 | # Setup the rotation and update coordinates of all shape blocks. 140 | # The block is rotated iff the rotation is enabled 141 | if self.rotate_en: 142 | self.diff_rotation = 90 143 | self._update() 144 | 145 | def _update(self): 146 | """ 147 | Update the position of all shape boxes. 148 | """ 149 | for bl in self.shape: 150 | # Get old coordinates and compute new x,y coordinates. 151 | # All rotation calculates are done in the original coordinates. 152 | origX = (bl.x - self.x)/constants.BWIDTH 153 | origY = (bl.y - self.y)/constants.BHEIGHT 154 | rx,ry = self.get_rotated(origX,origY) 155 | newX = rx*constants.BWIDTH + self.x + self.diffx 156 | newY = ry*constants.BHEIGHT + self.y + self.diffy 157 | # Compute the relative move 158 | newPosX = newX - bl.x 159 | newPosY = newY - bl.y 160 | bl.move_ip(newPosX,newPosY) 161 | # Everyhting was moved. Setup new x,y, coordinates and reset all disable the move 162 | # variables. 163 | self.x += self.diffx 164 | self.y += self.diffy 165 | self.diffx = 0 166 | self.diffy = 0 167 | self.diff_rotation = 0 168 | 169 | def backup(self): 170 | """ 171 | Backup the current configuration of shape blocks. 172 | """ 173 | # Make the deep copy of the shape list. Also, remember 174 | # the current configuration. 175 | self.shape_copy = copy.deepcopy(self.shape) 176 | self.x_copy = self.x 177 | self.y_copy = self.y 178 | self.rotation_copy = self.diff_rotation 179 | 180 | def restore(self): 181 | """ 182 | Restore the previous configuraiton. 183 | """ 184 | self.shape = self.shape_copy 185 | self.x = self.x_copy 186 | self.y = self.y_copy 187 | self.diff_rotation = self.rotation_copy 188 | 189 | def check_collision(self,rect_list): 190 | """ 191 | The function checks if the block colides with any other block 192 | in the shape list. 193 | 194 | Parameters: 195 | - rect_list - the function accepts the list of Rect object which 196 | are used for the collistion detection. 197 | """ 198 | for blk in rect_list: 199 | collist = blk.collidelistall(self.shape) 200 | if len(collist): 201 | return True 202 | return False 203 | 204 | -------------------------------------------------------------------------------- /tetris.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # File: tetris.py 4 | # Description: Main file with tetris game. 5 | # Author: Pavel Benáček 6 | 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program. If not, see . 19 | 20 | import pygame 21 | import pdb 22 | 23 | import random 24 | import math 25 | import block 26 | import constants 27 | 28 | class Tetris(object): 29 | """ 30 | The class with implementation of tetris game logic. 31 | """ 32 | 33 | def __init__(self,bx,by): 34 | """ 35 | Initialize the tetris object. 36 | 37 | Parameters: 38 | - bx - number of blocks in x 39 | - by - number of blocks in y 40 | """ 41 | # Compute the resolution of the play board based on the required number of blocks. 42 | self.resx = bx*constants.BWIDTH+2*constants.BOARD_HEIGHT+constants.BOARD_MARGIN 43 | self.resy = by*constants.BHEIGHT+2*constants.BOARD_HEIGHT+constants.BOARD_MARGIN 44 | # Prepare the pygame board objects (white lines) 45 | self.board_up = pygame.Rect(0,constants.BOARD_UP_MARGIN,self.resx,constants.BOARD_HEIGHT) 46 | self.board_down = pygame.Rect(0,self.resy-constants.BOARD_HEIGHT,self.resx,constants.BOARD_HEIGHT) 47 | self.board_left = pygame.Rect(0,constants.BOARD_UP_MARGIN,constants.BOARD_HEIGHT,self.resy) 48 | self.board_right = pygame.Rect(self.resx-constants.BOARD_HEIGHT,constants.BOARD_UP_MARGIN,constants.BOARD_HEIGHT,self.resy) 49 | # List of used blocks 50 | self.blk_list = [] 51 | # Compute start indexes for tetris blocks 52 | self.start_x = math.ceil(self.resx/2.0) 53 | self.start_y = constants.BOARD_UP_MARGIN + constants.BOARD_HEIGHT + constants.BOARD_MARGIN 54 | # Blocka data (shapes and colors). The shape is encoded in the list of [X,Y] points. Each point 55 | # represents the relative position. The true/false value is used for the configuration of rotation where 56 | # False means no rotate and True allows the rotation. 57 | self.block_data = ( 58 | ([[0,0],[1,0],[2,0],[3,0]],constants.RED,True), # I block 59 | ([[0,0],[1,0],[0,1],[-1,1]],constants.GREEN,True), # S block 60 | ([[0,0],[1,0],[2,0],[2,1]],constants.BLUE,True), # J block 61 | ([[0,0],[0,1],[1,0],[1,1]],constants.ORANGE,False), # O block 62 | ([[-1,0],[0,0],[0,1],[1,1]],constants.GOLD,True), # Z block 63 | ([[0,0],[1,0],[2,0],[1,1]],constants.PURPLE,True), # T block 64 | ([[0,0],[1,0],[2,0],[0,1]],constants.CYAN,True), # J block 65 | ) 66 | # Compute the number of blocks. When the number of blocks is even, we can use it directly but 67 | # we have to decrese the number of blocks in line by one when the number is odd (because of the used margin). 68 | self.blocks_in_line = bx if bx%2 == 0 else bx-1 69 | self.blocks_in_pile = by 70 | # Score settings 71 | self.score = 0 72 | # Remember the current speed 73 | self.speed = 1 74 | # The score level threshold 75 | self.score_level = constants.SCORE_LEVEL 76 | 77 | def apply_action(self): 78 | """ 79 | Get the event from the event queue and run the appropriate 80 | action. 81 | """ 82 | # Take the event from the event queue. 83 | for ev in pygame.event.get(): 84 | # Check if the close button was fired. 85 | if ev.type == pygame.QUIT or (ev.type == pygame.KEYDOWN and ev.unicode == 'q'): 86 | self.done = True 87 | # Detect the key evevents for game control. 88 | if ev.type == pygame.KEYDOWN: 89 | if ev.key == pygame.K_DOWN: 90 | self.active_block.move(0,constants.BHEIGHT) 91 | if ev.key == pygame.K_LEFT: 92 | self.active_block.move(-constants.BWIDTH,0) 93 | if ev.key == pygame.K_RIGHT: 94 | self.active_block.move(constants.BWIDTH,0) 95 | if ev.key == pygame.K_SPACE: 96 | self.active_block.rotate() 97 | if ev.key == pygame.K_p: 98 | self.pause() 99 | 100 | # Detect if the movement event was fired by the timer. 101 | if ev.type == constants.TIMER_MOVE_EVENT: 102 | self.active_block.move(0,constants.BHEIGHT) 103 | 104 | def pause(self): 105 | """ 106 | Pause the game and draw the string. This function 107 | also calls the flip function which draws the string on the screen. 108 | """ 109 | # Draw the string to the center of the screen. 110 | self.print_center(["PAUSE","Press \"p\" to continue"]) 111 | pygame.display.flip() 112 | while True: 113 | for ev in pygame.event.get(): 114 | if ev.type == pygame.KEYDOWN and ev.key == pygame.K_p: 115 | return 116 | 117 | def set_move_timer(self): 118 | """ 119 | Setup the move timer to the 120 | """ 121 | # Setup the time to fire the move event. Minimal allowed value is 1 122 | speed = math.floor(constants.MOVE_TICK / self.speed) 123 | speed = max(1,speed) 124 | pygame.time.set_timer(constants.TIMER_MOVE_EVENT,speed) 125 | 126 | def run(self): 127 | # Initialize the game (pygame, fonts) 128 | pygame.init() 129 | pygame.font.init() 130 | self.myfont = pygame.font.SysFont(pygame.font.get_default_font(),constants.FONT_SIZE) 131 | self.screen = pygame.display.set_mode((self.resx,self.resy)) 132 | pygame.display.set_caption("Tetris") 133 | # Setup the time to fire the move event every given time 134 | self.set_move_timer() 135 | # Control variables for the game. The done signal is used 136 | # to control the main loop (it is set by the quit action), the game_over signal 137 | # is set by the game logic and it is also used for the detection of "game over" drawing. 138 | # Finally the new_block variable is used for the requesting of new tetris block. 139 | self.done = False 140 | self.game_over = False 141 | self.new_block = True 142 | # Print the initial score 143 | self.print_status_line() 144 | while not(self.done) and not(self.game_over): 145 | # Get the block and run the game logic 146 | self.get_block() 147 | self.game_logic() 148 | self.draw_game() 149 | # Display the game_over and wait for a keypress 150 | if self.game_over: 151 | self.print_game_over() 152 | # Disable the pygame stuff 153 | pygame.font.quit() 154 | pygame.display.quit() 155 | 156 | def print_status_line(self): 157 | """ 158 | Print the current state line 159 | """ 160 | string = ["SCORE: {0} SPEED: {1}x".format(self.score,self.speed)] 161 | self.print_text(string,constants.POINT_MARGIN,constants.POINT_MARGIN) 162 | 163 | def print_game_over(self): 164 | """ 165 | Print the game over string. 166 | """ 167 | # Print the game over text 168 | self.print_center(["Game Over","Press \"q\" to exit"]) 169 | # Draw the string 170 | pygame.display.flip() 171 | # Wait untill the space is pressed 172 | while True: 173 | for ev in pygame.event.get(): 174 | if ev.type == pygame.QUIT or (ev.type == pygame.KEYDOWN and ev.unicode == 'q'): 175 | return 176 | 177 | def print_text(self,str_lst,x,y): 178 | """ 179 | Print the text on the X,Y coordinates. 180 | 181 | Parameters: 182 | - str_lst - list of strings to print. Each string is printed on new line. 183 | - x - X coordinate of the first string 184 | - y - Y coordinate of the first string 185 | """ 186 | prev_y = 0 187 | for string in str_lst: 188 | size_x,size_y = self.myfont.size(string) 189 | txt_surf = self.myfont.render(string,False,(255,255,255)) 190 | self.screen.blit(txt_surf,(x,y+prev_y)) 191 | prev_y += size_y 192 | 193 | def print_center(self,str_list): 194 | """ 195 | Print the string in the center of the screen. 196 | 197 | Parameters: 198 | - str_lst - list of strings to print. Each string is printed on new line. 199 | """ 200 | max_xsize = max([tmp[0] for tmp in map(self.myfont.size,str_list)]) 201 | self.print_text(str_list,self.resx/2-max_xsize/2,self.resy/2) 202 | 203 | def block_colides(self): 204 | """ 205 | Check if the block colides with any other block. 206 | 207 | The function returns True if the collision is detected. 208 | """ 209 | for blk in self.blk_list: 210 | # Check if the block is not the same 211 | if blk == self.active_block: 212 | continue 213 | # Detect situations 214 | if(blk.check_collision(self.active_block.shape)): 215 | return True 216 | return False 217 | 218 | def game_logic(self): 219 | """ 220 | Implementation of the main game logic. This function detects colisions 221 | and insertion of new tetris blocks. 222 | """ 223 | # Remember the current configuration and try to 224 | # apply the action 225 | self.active_block.backup() 226 | self.apply_action() 227 | # Border logic, check if we colide with down border or any 228 | # other border. This check also includes the detection with other tetris blocks. 229 | down_board = self.active_block.check_collision([self.board_down]) 230 | any_border = self.active_block.check_collision([self.board_left,self.board_up,self.board_right]) 231 | block_any = self.block_colides() 232 | # Restore the configuration if any collision was detected 233 | if down_board or any_border or block_any: 234 | self.active_block.restore() 235 | # So far so good, sample the previous state and try to move down (to detect the colision with other block). 236 | # After that, detect the the insertion of new block. The block new block is inserted if we reached the boarder 237 | # or we cannot move down. 238 | self.active_block.backup() 239 | self.active_block.move(0,constants.BHEIGHT) 240 | can_move_down = not self.block_colides() 241 | self.active_block.restore() 242 | # We end the game if we are on the respawn and we cannot move --> bang! 243 | if not can_move_down and (self.start_x == self.active_block.x and self.start_y == self.active_block.y): 244 | self.game_over = True 245 | # The new block is inserted if we reached down board or we cannot move down. 246 | if down_board or not can_move_down: 247 | # Request new block 248 | self.new_block = True 249 | # Detect the filled line and possibly remove the line from the 250 | # screen. 251 | self.detect_line() 252 | 253 | def detect_line(self): 254 | """ 255 | Detect if the line is filled. If yes, remove the line and 256 | move with remaining bulding blocks to new positions. 257 | """ 258 | # Get each shape block of the non-moving tetris block and try 259 | # to detect the filled line. The number of bulding blocks is passed to the class 260 | # in the init function. 261 | for shape_block in self.active_block.shape: 262 | tmp_y = shape_block.y 263 | tmp_cnt = self.get_blocks_in_line(tmp_y) 264 | # Detect if the line contains the given number of blocks 265 | if tmp_cnt != self.blocks_in_line: 266 | continue 267 | # Ok, the full line is detected! 268 | self.remove_line(tmp_y) 269 | # Update the score. 270 | self.score += self.blocks_in_line * constants.POINT_VALUE 271 | # Check if we need to speed up the game. If yes, change control variables 272 | if self.score > self.score_level: 273 | self.score_level *= constants.SCORE_LEVEL_RATIO 274 | self.speed *= constants.GAME_SPEEDUP_RATIO 275 | # Change the game speed 276 | self.set_move_timer() 277 | 278 | def remove_line(self,y): 279 | """ 280 | Remove the line with given Y coordinates. Blocks below the filled 281 | line are untouched. The rest of blocks (yi > y) are moved one level done. 282 | 283 | Parameters: 284 | - y - Y coordinate to remove. 285 | """ 286 | # Iterate over all blocks in the list and remove blocks with the Y coordinate. 287 | for block in self.blk_list: 288 | block.remove_blocks(y) 289 | # Setup new block list (not needed blocks are removed) 290 | self.blk_list = [blk for blk in self.blk_list if blk.has_blocks()] 291 | 292 | def get_blocks_in_line(self,y): 293 | """ 294 | Get the number of shape blocks on the Y coordinate. 295 | 296 | Parameters: 297 | - y - Y coordinate to scan. 298 | """ 299 | # Iteraveovel all block's shape list and increment the counter 300 | # if the shape block equals to the Y coordinate. 301 | tmp_cnt = 0 302 | for block in self.blk_list: 303 | for shape_block in block.shape: 304 | tmp_cnt += (1 if y == shape_block.y else 0) 305 | return tmp_cnt 306 | 307 | def draw_board(self): 308 | """ 309 | Draw the white board. 310 | """ 311 | pygame.draw.rect(self.screen,constants.WHITE,self.board_up) 312 | pygame.draw.rect(self.screen,constants.WHITE,self.board_down) 313 | pygame.draw.rect(self.screen,constants.WHITE,self.board_left) 314 | pygame.draw.rect(self.screen,constants.WHITE,self.board_right) 315 | # Update the score 316 | self.print_status_line() 317 | 318 | def get_block(self): 319 | """ 320 | Generate new block into the game if is required. 321 | """ 322 | if self.new_block: 323 | # Get the block and add it into the block list(static for now) 324 | tmp = random.randint(0,len(self.block_data)-1) 325 | data = self.block_data[tmp] 326 | self.active_block = block.Block(data[0],self.start_x,self.start_y,self.screen,data[1],data[2]) 327 | self.blk_list.append(self.active_block) 328 | self.new_block = False 329 | 330 | def draw_game(self): 331 | """ 332 | Draw the game screen. 333 | """ 334 | # Clean the screen, draw the board and draw 335 | # all tetris blocks 336 | self.screen.fill(constants.BLACK) 337 | self.draw_board() 338 | for blk in self.blk_list: 339 | blk.draw() 340 | # Draw the screen buffer 341 | pygame.display.flip() 342 | 343 | if __name__ == "__main__": 344 | Tetris(16,30).run() 345 | 346 | #Special add to try pull requests -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # GNU GENERAL PUBLIC LICENSE 2 | 3 | Version 3, 29 June 2007 4 | 5 | Copyright © 2007 Free Software Foundation, Inc. 6 | [http://fsf.org/](http://fsf.org/) 7 | 8 | Everyone is permitted to copy and distribute verbatim copies of this 9 | license document, but changing it is not allowed. 10 | 11 | ## Preamble 12 | 13 | The GNU General Public License is a free, copyleft license for software 14 | and other kinds of works. 15 | 16 | The licenses for most software and other practical works are designed to 17 | take away your freedom to share and change the works. By contrast, the 18 | GNU General Public License is intended to guarantee your freedom to 19 | share and change all versions of a program--to make sure it remains free 20 | software for all its users. We, the Free Software Foundation, use the 21 | GNU General Public License for most of our software; it applies also to 22 | any other work released this way by its authors. You can apply it to 23 | your programs, too. 24 | 25 | When we speak of free software, we are referring to freedom, not price. 26 | Our General Public Licenses are designed to make sure that you have the 27 | freedom to distribute copies of free software (and charge for them if 28 | you wish), that you receive source code or can get it if you want it, 29 | that you can change the software or use pieces of it in new free 30 | programs, and that you know you can do these things. 31 | 32 | To protect your rights, we need to prevent others from denying you these 33 | rights or asking you to surrender the rights. Therefore, you have 34 | certain responsibilities if you distribute copies of the software, or if 35 | you modify it: responsibilities to respect the freedom of others. 36 | 37 | For example, if you distribute copies of such a program, whether gratis 38 | or for a fee, you must pass on to the recipients the same freedoms that 39 | you received. You must make sure that they, too, receive or can get the 40 | source code. And you must show them these terms so they know their 41 | rights. 42 | 43 | Developers that use the GNU GPL protect your rights with two steps: (1) 44 | assert copyright on the software, and (2) offer you this License giving 45 | you legal permission to copy, distribute and/or modify it. 46 | 47 | For the developers' and authors' protection, the GPL clearly explains 48 | that there is no warranty for this free software. For both users' and 49 | authors' sake, the GPL requires that modified versions be marked as 50 | changed, so that their problems will not be attributed erroneously to 51 | authors of previous versions. 52 | 53 | Some devices are designed to deny users access to install or run 54 | modified versions of the software inside them, although the manufacturer 55 | can do so. This is fundamentally incompatible with the aim of protecting 56 | users' freedom to change the software. The systematic pattern of such 57 | abuse occurs in the area of products for individuals to use, which is 58 | precisely where it is most unacceptable. Therefore, we have designed 59 | this version of the GPL to prohibit the practice for those products. If 60 | such problems arise substantially in other domains, we stand ready to 61 | extend this provision to those domains in future versions of the GPL, as 62 | needed to protect the freedom of users. 63 | 64 | Finally, every program is threatened constantly by software patents. 65 | States should not allow patents to restrict development and use of 66 | software on general-purpose computers, but in those that do, we wish to 67 | avoid the special danger that patents applied to a free program could 68 | make it effectively proprietary. To prevent this, the GPL assures that 69 | patents cannot be used to render the program non-free. 70 | 71 | The precise terms and conditions for copying, distribution and 72 | modification follow. 73 | 74 | ## TERMS AND CONDITIONS 75 | 76 | ### 0. Definitions. 77 | 78 | “This License” refers to version 3 of the GNU General Public License. 79 | 80 | “Copyright” also means copyright-like laws that apply to other kinds of 81 | works, such as semiconductor masks. 82 | 83 | “The Program” refers to any copyrightable work licensed under this 84 | License. Each licensee is addressed as “you”. “Licensees” and 85 | “recipients” may be individuals or organizations. 86 | 87 | To “modify” a work means to copy from or adapt all or part of the work 88 | in a fashion requiring copyright permission, other than the making of an 89 | exact copy. The resulting work is called a “modified version” of the 90 | earlier work or a work “based on” the earlier work. 91 | 92 | A “covered work” means either the unmodified Program or a work based on 93 | the Program. 94 | 95 | To “propagate” a work means to do anything with it that, without 96 | permission, would make you directly or secondarily liable for 97 | infringement under applicable copyright law, except executing it on a 98 | computer or modifying a private copy. Propagation includes copying, 99 | distribution (with or without modification), making available to the 100 | public, and in some countries other activities as well. 101 | 102 | To “convey” a work means any kind of propagation that enables other 103 | parties to make or receive copies. Mere interaction with a user through 104 | a computer network, with no transfer of a copy, is not conveying. 105 | 106 | An interactive user interface displays “Appropriate Legal Notices” to 107 | the extent that it includes a convenient and prominently visible feature 108 | that (1) displays an appropriate copyright notice, and (2) tells the 109 | user that there is no warranty for the work (except to the extent that 110 | warranties are provided), that licensees may convey the work under this 111 | License, and how to view a copy of this License. If the interface 112 | presents a list of user commands or options, such as a menu, a prominent 113 | item in the list meets this criterion. 114 | 115 | ### 1. Source Code. 116 | 117 | The “source code” for a work means the preferred form of the work for 118 | making modifications to it. “Object code” means any non-source form of a 119 | work. 120 | 121 | A “Standard Interface” means an interface that either is an official 122 | standard defined by a recognized standards body, or, in the case of 123 | interfaces specified for a particular programming language, one that is 124 | widely used among developers working in that language. 125 | 126 | The “System Libraries” of an executable work include anything, other 127 | than the work as a whole, that (a) is included in the normal form of 128 | packaging a Major Component, but which is not part of that Major 129 | Component, and (b) serves only to enable use of the work with that Major 130 | Component, or to implement a Standard Interface for which an 131 | implementation is available to the public in source code form. A “Major 132 | Component”, in this context, means a major essential component (kernel, 133 | window system, and so on) of the specific operating system (if any) on 134 | which the executable work runs, or a compiler used to produce the work, 135 | or an object code interpreter used to run it. 136 | 137 | The “Corresponding Source” for a work in object code form means all the 138 | source code needed to generate, install, and (for an executable work) 139 | run the object code and to modify the work, including scripts to control 140 | those activities. However, it does not include the work's System 141 | Libraries, or general-purpose tools or generally available free programs 142 | which are used unmodified in performing those activities but which are 143 | not part of the work. For example, Corresponding Source includes 144 | interface definition files associated with source files for the work, 145 | and the source code for shared libraries and dynamically linked 146 | subprograms that the work is specifically designed to require, such as 147 | by intimate data communication or control flow between those subprograms 148 | and other parts of the work. 149 | 150 | The Corresponding Source need not include anything that users can 151 | regenerate automatically from other parts of the Corresponding Source. 152 | 153 | The Corresponding Source for a work in source code form is that same 154 | work. 155 | 156 | ### 2. Basic Permissions. 157 | 158 | All rights granted under this License are granted for the term of 159 | copyright on the Program, and are irrevocable provided the stated 160 | conditions are met. This License explicitly affirms your unlimited 161 | permission to run the unmodified Program. The output from running a 162 | covered work is covered by this License only if the output, given its 163 | content, constitutes a covered work. This License acknowledges your 164 | rights of fair use or other equivalent, as provided by copyright law. 165 | 166 | You may make, run and propagate covered works that you do not convey, 167 | without conditions so long as your license otherwise remains in force. 168 | You may convey covered works to others for the sole purpose of having 169 | them make modifications exclusively for you, or provide you with 170 | facilities for running those works, provided that you comply with the 171 | terms of this License in conveying all material for which you do not 172 | control copyright. Those thus making or running the covered works for 173 | you must do so exclusively on your behalf, under your direction and 174 | control, on terms that prohibit them from making any copies of your 175 | copyrighted material outside their relationship with you. 176 | 177 | Conveying under any other circumstances is permitted solely under the 178 | conditions stated below. Sublicensing is not allowed; section 10 makes 179 | it unnecessary. 180 | 181 | ### 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 182 | 183 | No covered work shall be deemed part of an effective technological 184 | measure under any applicable law fulfilling obligations under article 11 185 | of the WIPO copyright treaty adopted on 20 December 1996, or similar 186 | laws prohibiting or restricting circumvention of such measures. 187 | 188 | When you convey a covered work, you waive any legal power to forbid 189 | circumvention of technological measures to the extent such circumvention 190 | is effected by exercising rights under this License with respect to the 191 | covered work, and you disclaim any intention to limit operation or 192 | modification of the work as a means of enforcing, against the work's 193 | users, your or third parties' legal rights to forbid circumvention of 194 | technological measures. 195 | 196 | ### 4. Conveying Verbatim Copies. 197 | 198 | You may convey verbatim copies of the Program's source code as you 199 | receive it, in any medium, provided that you conspicuously and 200 | appropriately publish on each copy an appropriate copyright notice; keep 201 | intact all notices stating that this License and any non-permissive 202 | terms added in accord with section 7 apply to the code; keep intact all 203 | notices of the absence of any warranty; and give all recipients a copy 204 | of this License along with the Program. 205 | 206 | You may charge any price or no price for each copy that you convey, and 207 | you may offer support or warranty protection for a fee. 208 | 209 | ### 5. Conveying Modified Source Versions. 210 | 211 | You may convey a work based on the Program, or the modifications to 212 | produce it from the Program, in the form of source code under the terms 213 | of section 4, provided that you also meet all of these conditions: 214 | 215 | - a) The work must carry prominent notices stating that you modified 216 | it, and giving a relevant date. 217 | - b) The work must carry prominent notices stating that it is released 218 | under this License and any conditions added under section 7. This 219 | requirement modifies the requirement in section 4 to “keep intact 220 | all notices”. 221 | - c) You must license the entire work, as a whole, under this License 222 | to anyone who comes into possession of a copy. This License will 223 | therefore apply, along with any applicable section 7 additional 224 | terms, to the whole of the work, and all its parts, regardless of 225 | how they are packaged. This License gives no permission to license 226 | the work in any other way, but it does not invalidate such 227 | permission if you have separately received it. 228 | - d) If the work has interactive user interfaces, each must display 229 | Appropriate Legal Notices; however, if the Program has interactive 230 | interfaces that do not display Appropriate Legal Notices, your work 231 | need not make them do so. 232 | 233 | A compilation of a covered work with other separate and independent 234 | works, which are not by their nature extensions of the covered work, and 235 | which are not combined with it such as to form a larger program, in or 236 | on a volume of a storage or distribution medium, is called an 237 | “aggregate” if the compilation and its resulting copyright are not used 238 | to limit the access or legal rights of the compilation's users beyond 239 | what the individual works permit. Inclusion of a covered work in an 240 | aggregate does not cause this License to apply to the other parts of the 241 | aggregate. 242 | 243 | ### 6. Conveying Non-Source Forms. 244 | 245 | You may convey a covered work in object code form under the terms of 246 | sections 4 and 5, provided that you also convey the machine-readable 247 | Corresponding Source under the terms of this License, in one of these 248 | ways: 249 | 250 | - a) Convey the object code in, or embodied in, a physical product 251 | (including a physical distribution medium), accompanied by the 252 | Corresponding Source fixed on a durable physical medium customarily 253 | used for software interchange. 254 | - b) Convey the object code in, or embodied in, a physical product 255 | (including a physical distribution medium), accompanied by a written 256 | offer, valid for at least three years and valid for as long as you 257 | offer spare parts or customer support for that product model, to 258 | give anyone who possesses the object code either (1) a copy of the 259 | Corresponding Source for all the software in the product that is 260 | covered by this License, on a durable physical medium customarily 261 | used for software interchange, for a price no more than your 262 | reasonable cost of physically performing this conveying of source, 263 | or (2) access to copy the Corresponding Source from a network server 264 | at no charge. 265 | - c) Convey individual copies of the object code with a copy of the 266 | written offer to provide the Corresponding Source. This alternative 267 | is allowed only occasionally and noncommercially, and only if you 268 | received the object code with such an offer, in accord with 269 | subsection 6b. 270 | - d) Convey the object code by offering access from a designated place 271 | (gratis or for a charge), and offer equivalent access to the 272 | Corresponding Source in the same way through the same place at no 273 | further charge. You need not require recipients to copy the 274 | Corresponding Source along with the object code. If the place to 275 | copy the object code is a network server, the Corresponding Source 276 | may be on a different server (operated by you or a third party) that 277 | supports equivalent copying facilities, provided you maintain clear 278 | directions next to the object code saying where to find the 279 | Corresponding Source. Regardless of what server hosts the 280 | Corresponding Source, you remain obligated to ensure that it is 281 | available for as long as needed to satisfy these requirements. 282 | - e) Convey the object code using peer-to-peer transmission, provided 283 | you inform other peers where the object code and Corresponding 284 | Source of the work are being offered to the general public at no 285 | charge under subsection 6d. 286 | 287 | A separable portion of the object code, whose source code is excluded 288 | from the Corresponding Source as a System Library, need not be included 289 | in conveying the object code work. 290 | 291 | A “User Product” is either (1) a “consumer product”, which means any 292 | tangible personal property which is normally used for personal, family, 293 | or household purposes, or (2) anything designed or sold for 294 | incorporation into a dwelling. In determining whether a product is a 295 | consumer product, doubtful cases shall be resolved in favor of coverage. 296 | For a particular product received by a particular user, “normally used” 297 | refers to a typical or common use of that class of product, regardless 298 | of the status of the particular user or of the way in which the 299 | particular user actually uses, or expects or is expected to use, the 300 | product. A product is a consumer product regardless of whether the 301 | product has substantial commercial, industrial or non-consumer uses, 302 | unless such uses represent the only significant mode of use of the 303 | product. 304 | 305 | “Installation Information” for a User Product means any methods, 306 | procedures, authorization keys, or other information required to install 307 | and execute modified versions of a covered work in that User Product 308 | from a modified version of its Corresponding Source. The information 309 | must suffice to ensure that the continued functioning of the modified 310 | object code is in no case prevented or interfered with solely because 311 | modification has been made. 312 | 313 | If you convey an object code work under this section in, or with, or 314 | specifically for use in, a User Product, and the conveying occurs as 315 | part of a transaction in which the right of possession and use of the 316 | User Product is transferred to the recipient in perpetuity or for a 317 | fixed term (regardless of how the transaction is characterized), the 318 | Corresponding Source conveyed under this section must be accompanied by 319 | the Installation Information. But this requirement does not apply if 320 | neither you nor any third party retains the ability to install modified 321 | object code on the User Product (for example, the work has been 322 | installed in ROM). 323 | 324 | The requirement to provide Installation Information does not include a 325 | requirement to continue to provide support service, warranty, or updates 326 | for a work that has been modified or installed by the recipient, or for 327 | the User Product in which it has been modified or installed. Access to a 328 | network may be denied when the modification itself materially and 329 | adversely affects the operation of the network or violates the rules and 330 | protocols for communication across the network. 331 | 332 | Corresponding Source conveyed, and Installation Information provided, in 333 | accord with this section must be in a format that is publicly documented 334 | (and with an implementation available to the public in source code 335 | form), and must require no special password or key for unpacking, 336 | reading or copying. 337 | 338 | ### 7. Additional Terms. 339 | 340 | “Additional permissions” are terms that supplement the terms of this 341 | License by making exceptions from one or more of its conditions. 342 | Additional permissions that are applicable to the entire Program shall 343 | be treated as though they were included in this License, to the extent 344 | that they are valid under applicable law. If additional permissions 345 | apply only to part of the Program, that part may be used separately 346 | under those permissions, but the entire Program remains governed by this 347 | License without regard to the additional permissions. 348 | 349 | When you convey a copy of a covered work, you may at your option remove 350 | any additional permissions from that copy, or from any part of it. 351 | (Additional permissions may be written to require their own removal in 352 | certain cases when you modify the work.) You may place additional 353 | permissions on material, added by you to a covered work, for which you 354 | have or can give appropriate copyright permission. 355 | 356 | Notwithstanding any other provision of this License, for material you 357 | add to a covered work, you may (if authorized by the copyright holders 358 | of that material) supplement the terms of this License with terms: 359 | 360 | - a) Disclaiming warranty or limiting liability differently from the 361 | terms of sections 15 and 16 of this License; or 362 | - b) Requiring preservation of specified reasonable legal notices or 363 | author attributions in that material or in the Appropriate Legal 364 | Notices displayed by works containing it; or 365 | - c) Prohibiting misrepresentation of the origin of that material, or 366 | requiring that modified versions of such material be marked in 367 | reasonable ways as different from the original version; or 368 | - d) Limiting the use for publicity purposes of names of licensors or 369 | authors of the material; or 370 | - e) Declining to grant rights under trademark law for use of some 371 | trade names, trademarks, or service marks; or 372 | - f) Requiring indemnification of licensors and authors of that 373 | material by anyone who conveys the material (or modified versions of 374 | it) with contractual assumptions of liability to the recipient, for 375 | any liability that these contractual assumptions directly impose on 376 | those licensors and authors. 377 | 378 | All other non-permissive additional terms are considered “further 379 | restrictions” within the meaning of section 10. If the Program as you 380 | received it, or any part of it, contains a notice stating that it is 381 | governed by this License along with a term that is a further 382 | restriction, you may remove that term. If a license document contains a 383 | further restriction but permits relicensing or conveying under this 384 | License, you may add to a covered work material governed by the terms of 385 | that license document, provided that the further restriction does not 386 | survive such relicensing or conveying. 387 | 388 | If you add terms to a covered work in accord with this section, you must 389 | place, in the relevant source files, a statement of the additional terms 390 | that apply to those files, or a notice indicating where to find the 391 | applicable terms. 392 | 393 | Additional terms, permissive or non-permissive, may be stated in the 394 | form of a separately written license, or stated as exceptions; the above 395 | requirements apply either way. 396 | 397 | ### 8. Termination. 398 | 399 | You may not propagate or modify a covered work except as expressly 400 | provided under this License. Any attempt otherwise to propagate or 401 | modify it is void, and will automatically terminate your rights under 402 | this License (including any patent licenses granted under the third 403 | paragraph of section 11). 404 | 405 | However, if you cease all violation of this License, then your license 406 | from a particular copyright holder is reinstated (a) provisionally, 407 | unless and until the copyright holder explicitly and finally terminates 408 | your license, and (b) permanently, if the copyright holder fails to 409 | notify you of the violation by some reasonable means prior to 60 days 410 | after the cessation. 411 | 412 | Moreover, your license from a particular copyright holder is reinstated 413 | permanently if the copyright holder notifies you of the violation by 414 | some reasonable means, this is the first time you have received notice 415 | of violation of this License (for any work) from that copyright holder, 416 | and you cure the violation prior to 30 days after your receipt of the 417 | notice. 418 | 419 | Termination of your rights under this section does not terminate the 420 | licenses of parties who have received copies or rights from you under 421 | this License. If your rights have been terminated and not permanently 422 | reinstated, you do not qualify to receive new licenses for the same 423 | material under section 10. 424 | 425 | ### 9. Acceptance Not Required for Having Copies. 426 | 427 | You are not required to accept this License in order to receive or run a 428 | copy of the Program. Ancillary propagation of a covered work occurring 429 | solely as a consequence of using peer-to-peer transmission to receive a 430 | copy likewise does not require acceptance. However, nothing other than 431 | this License grants you permission to propagate or modify any covered 432 | work. These actions infringe copyright if you do not accept this 433 | License. Therefore, by modifying or propagating a covered work, you 434 | indicate your acceptance of this License to do so. 435 | 436 | ### 10. Automatic Licensing of Downstream Recipients. 437 | 438 | Each time you convey a covered work, the recipient automatically 439 | receives a license from the original licensors, to run, modify and 440 | propagate that work, subject to this License. You are not responsible 441 | for enforcing compliance by third parties with this License. 442 | 443 | An “entity transaction” is a transaction transferring control of an 444 | organization, or substantially all assets of one, or subdividing an 445 | organization, or merging organizations. If propagation of a covered work 446 | results from an entity transaction, each party to that transaction who 447 | receives a copy of the work also receives whatever licenses to the work 448 | the party's predecessor in interest had or could give under the previous 449 | paragraph, plus a right to possession of the Corresponding Source of the 450 | work from the predecessor in interest, if the predecessor has it or can 451 | get it with reasonable efforts. 452 | 453 | You may not impose any further restrictions on the exercise of the 454 | rights granted or affirmed under this License. For example, you may not 455 | impose a license fee, royalty, or other charge for exercise of rights 456 | granted under this License, and you may not initiate litigation 457 | (including a cross-claim or counterclaim in a lawsuit) alleging that any 458 | patent claim is infringed by making, using, selling, offering for sale, 459 | or importing the Program or any portion of it. 460 | 461 | ### 11. Patents. 462 | 463 | A “contributor” is a copyright holder who authorizes use under this 464 | License of the Program or a work on which the Program is based. The work 465 | thus licensed is called the contributor's “contributor version”. 466 | 467 | A contributor's “essential patent claims” are all patent claims owned or 468 | controlled by the contributor, whether already acquired or hereafter 469 | acquired, that would be infringed by some manner, permitted by this 470 | License, of making, using, or selling its contributor version, but do 471 | not include claims that would be infringed only as a consequence of 472 | further modification of the contributor version. For purposes of this 473 | definition, “control” includes the right to grant patent sublicenses in 474 | a manner consistent with the requirements of this License. 475 | 476 | Each contributor grants you a non-exclusive, worldwide, royalty-free 477 | patent license under the contributor's essential patent claims, to make, 478 | use, sell, offer for sale, import and otherwise run, modify and 479 | propagate the contents of its contributor version. 480 | 481 | In the following three paragraphs, a “patent license” is any express 482 | agreement or commitment, however denominated, not to enforce a patent 483 | (such as an express permission to practice a patent or covenant not to 484 | sue for patent infringement). To “grant” such a patent license to a 485 | party means to make such an agreement or commitment not to enforce a 486 | patent against the party. 487 | 488 | If you convey a covered work, knowingly relying on a patent license, and 489 | the Corresponding Source of the work is not available for anyone to 490 | copy, free of charge and under the terms of this License, through a 491 | publicly available network server or other readily accessible means, 492 | then you must either (1) cause the Corresponding Source to be so 493 | available, or (2) arrange to deprive yourself of the benefit of the 494 | patent license for this particular work, or (3) arrange, in a manner 495 | consistent with the requirements of this License, to extend the patent 496 | license to downstream recipients. “Knowingly relying” means you have 497 | actual knowledge that, but for the patent license, your conveying the 498 | covered work in a country, or your recipient's use of the covered work 499 | in a country, would infringe one or more identifiable patents in that 500 | country that you have reason to believe are valid. 501 | 502 | If, pursuant to or in connection with a single transaction or 503 | arrangement, you convey, or propagate by procuring conveyance of, a 504 | covered work, and grant a patent license to some of the parties 505 | receiving the covered work authorizing them to use, propagate, modify or 506 | convey a specific copy of the covered work, then the patent license you 507 | grant is automatically extended to all recipients of the covered work 508 | and works based on it. 509 | 510 | A patent license is “discriminatory” if it does not include within the 511 | scope of its coverage, prohibits the exercise of, or is conditioned on 512 | the non-exercise of one or more of the rights that are specifically 513 | granted under this License. You may not convey a covered work if you are 514 | a party to an arrangement with a third party that is in the business of 515 | distributing software, under which you make payment to the third party 516 | based on the extent of your activity of conveying the work, and under 517 | which the third party grants, to any of the parties who would receive 518 | the covered work from you, a discriminatory patent license (a) in 519 | connection with copies of the covered work conveyed by you (or copies 520 | made from those copies), or (b) primarily for and in connection with 521 | specific products or compilations that contain the covered work, unless 522 | you entered into that arrangement, or that patent license was granted, 523 | prior to 28 March 2007. 524 | 525 | Nothing in this License shall be construed as excluding or limiting any 526 | implied license or other defenses to infringement that may otherwise be 527 | available to you under applicable patent law. 528 | 529 | ### 12. No Surrender of Others' Freedom. 530 | 531 | If conditions are imposed on you (whether by court order, agreement or 532 | otherwise) that contradict the conditions of this License, they do not 533 | excuse you from the conditions of this License. If you cannot convey a 534 | covered work so as to satisfy simultaneously your obligations under this 535 | License and any other pertinent obligations, then as a consequence you 536 | may not convey it at all. For example, if you agree to terms that 537 | obligate you to collect a royalty for further conveying from those to 538 | whom you convey the Program, the only way you could satisfy both those 539 | terms and this License would be to refrain entirely from conveying the 540 | Program. 541 | 542 | ### 13. Use with the GNU Affero General Public License. 543 | 544 | Notwithstanding any other provision of this License, you have permission 545 | to link or combine any covered work with a work licensed under version 3 546 | of the GNU Affero General Public License into a single combined work, 547 | and to convey the resulting work. The terms of this License will 548 | continue to apply to the part which is the covered work, but the special 549 | requirements of the GNU Affero General Public License, section 13, 550 | concerning interaction through a network will apply to the combination 551 | as such. 552 | 553 | ### 14. Revised Versions of this License. 554 | 555 | The Free Software Foundation may publish revised and/or new versions of 556 | the GNU General Public License from time to time. Such new versions will 557 | be similar in spirit to the present version, but may differ in detail to 558 | address new problems or concerns. 559 | 560 | Each version is given a distinguishing version number. If the Program 561 | specifies that a certain numbered version of the GNU General Public 562 | License “or any later version” applies to it, you have the option of 563 | following the terms and conditions either of that numbered version or of 564 | any later version published by the Free Software Foundation. If the 565 | Program does not specify a version number of the GNU General Public 566 | License, you may choose any version ever published by the Free Software 567 | Foundation. 568 | 569 | If the Program specifies that a proxy can decide which future versions 570 | of the GNU General Public License can be used, that proxy's public 571 | statement of acceptance of a version permanently authorizes you to 572 | choose that version for the Program. 573 | 574 | Later license versions may give you additional or different permissions. 575 | However, no additional obligations are imposed on any author or 576 | copyright holder as a result of your choosing to follow a later version. 577 | 578 | ### 15. Disclaimer of Warranty. 579 | 580 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 581 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 582 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT 583 | WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT 584 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 585 | PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF 586 | THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME 587 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 588 | 589 | ### 16. Limitation of Liability. 590 | 591 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 592 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR 593 | CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 594 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES 595 | ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT 596 | NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES 597 | SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE 598 | WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN 599 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 600 | 601 | ### 17. Interpretation of Sections 15 and 16. 602 | 603 | If the disclaimer of warranty and limitation of liability provided above 604 | cannot be given local legal effect according to their terms, reviewing 605 | courts shall apply local law that most closely approximates an absolute 606 | waiver of all civil liability in connection with the Program, unless a 607 | warranty or assumption of liability accompanies a copy of the Program in 608 | return for a fee. 609 | 610 | END OF TERMS AND CONDITIONS 611 | --------------------------------------------------------------------------------