TETROID_OFFSET_DICT = dict([('square', ((0, 0), (0, 1), (1, 0), (1, 1))), ('zig-zag 1', ((-1, 0), (0, 0), (0, 1), (1, 1))), ('zig-zag 2', ((-1, 1), (0, 0), (0, 1), (1, 0))), ('tee', ((-1, 0), (0, 0), (0, 1), (1, 0))), ('L1', ((-1, 1), (-1, 0), (0, 0), (1, 0))), ('L2', ((-1, -1), (-1, 0), (0, 0), (1, 0))), ('line', ((-1, 0), (0, 0), (1, 0), (2, 0)))]) TETROID_COLOR_DICT = dict([('square', 'FireBrick'), ('zig-zag 1', 'SteelBlue'), ('zig-zag 2', 'Plum'), ('tee', (60, 179, 71)), ('L1', 'Gold'), ('L2', (220, 94, 56)), ('line', 'SkyBlue')]) image_infos = dict([ ('dark_blue', simplegui.Image_Info(simplegui.get_image_path('block_dark_blue.png'), (BLOCK_H, BLOCK_H))), ('light_blue', simplegui.Image_Info(simplegui.get_image_path('block_light_blue.png'), (BLOCK_H, BLOCK_H))), ('red', simplegui.Image_Info(simplegui.get_image_path('block_red.png'), (BLOCK_H, BLOCK_H))), ('green', simplegui.Image_Info(simplegui.get_image_path('block_green.png'), (BLOCK_H, BLOCK_H))), ('yellow', simplegui.Image_Info(simplegui.get_image_path('block_yellow.png'), (BLOCK_H, BLOCK_H))), ('purple', simplegui.Image_Info(simplegui.get_image_path('block_purple.png'),
('zig-zag 1',((-1,0),(0,0),(0,1),(1,1))), ('zig-zag 2',((-1,1),(0,0),(0,1),(1,0))), ('tee', ((-1,0),(0,0),(0,1),(1,0))), ('L1', ((-1, 1),(-1,0),(0,0),(1,0))), ('L2', ((-1,-1),(-1,0),(0,0),(1,0))), ('line', ((-1,0),(0,0),(1,0),(2,0)))]) TETROID_COLOR_DICT = dict([('square','FireBrick'), ('zig-zag 1','SteelBlue'), ('zig-zag 2','Plum'), ('tee',(60,179,71)), ('L1','Gold'), ('L2',(220,94,56)), ('line','SkyBlue')]) image_infos = dict([('dark_blue',simplegui.Image_Info(simplegui.get_image_path('block_dark_blue.png'),(BLOCK_H,BLOCK_H))), ('light_blue',simplegui.Image_Info(simplegui.get_image_path('block_light_blue.png'),(BLOCK_H,BLOCK_H))), ('red',simplegui.Image_Info(simplegui.get_image_path('block_red.png'),(BLOCK_H,BLOCK_H))), ('green',simplegui.Image_Info(simplegui.get_image_path('block_green.png'),(BLOCK_H,BLOCK_H))), ('yellow',simplegui.Image_Info(simplegui.get_image_path('block_yellow.png'),(BLOCK_H,BLOCK_H))), ('purple',simplegui.Image_Info(simplegui.get_image_path('block_purple.png'),(BLOCK_H,BLOCK_H))), ('orange',simplegui.Image_Info(simplegui.get_image_path('block_orange.png'),(BLOCK_H,BLOCK_H)))]) images = dict([]) TETROID_IMAGE_COLOR_DICT = dict([('square','red'), ('zig-zag 1','dark_blue'), ('zig-zag 2','purple'), ('tee','green'), ('L1','yellow'), ('L2','orange'), ('line','light_blue')])
HEIGHT = 400 UNIT = 40 MOVE_COUNT = 30 BACKGROUND_COLOR = 'SteelBlue' FOOD_COLOR = 'White' IMAGES_ON = True game_over = False game_paused = False move_count = 0 snake = None food = None image_infos = dict([ ('head', simplegui.Image_Info(simplegui.get_image_path('snake_head.png'), (UNIT, UNIT))), ('neck', simplegui.Image_Info(simplegui.get_image_path('snake_neck.png'), (UNIT, UNIT))), ('straight', simplegui.Image_Info(simplegui.get_image_path('snake_body_straight.png'), (UNIT, UNIT))), ('left', simplegui.Image_Info(simplegui.get_image_path('snake_body_left.png'), (UNIT, UNIT))), ('right', simplegui.Image_Info(simplegui.get_image_path('snake_body_right.png'), (UNIT, UNIT))), ('tail', simplegui.Image_Info(simplegui.get_image_path('snake_tail.png'),
HISTORY_DIR = os.path.join(os.path.expanduser("~"),".python_games") if not os.path.exists(HISTORY_DIR): os.makedirs(HISTORY_DIR) HISTORY = os.path.join(HISTORY_DIR, "setgame") PAD_W = 10 PAD_H = 10 CARD_W = 120 CARD_H = 180 WIDTH = 9*CARD_W HEIGHT = 4*CARD_H CONTROL_W = int(1.2*CARD_W) BUTTON_W = 0.9*CONTROL_W BUTTON_FONT_H = 16 CARDS_IMAGE_INFO = simplegui.Image_Info(simplegui.get_image_path('set_shapes.png'), (6*(CARD_W + PAD_W), 6*(CARD_H + PAD_H))) DEFAULT_CARDS_ON_BOARD = 12 ABS_MAX_CARDS_ON_BOARD = 21 max_cards_on_board = 12 deck = [] board = dict([]) num_sets = 0 score = 0 hint_label_str = "" high_score = 0 if os.path.exists(HISTORY): try: with open(HISTORY, 'r') as f_in: high_score = int(f_in.next().strip())
WIDTH = 600 HEIGHT = 400 UNIT = 40 MOVE_COUNT = 30 BACKGROUND_COLOR = 'SteelBlue' FOOD_COLOR = 'White' IMAGES_ON = True game_over = False game_paused = False move_count = 0 snake = None food = None image_infos = dict([('head',simplegui.Image_Info(simplegui.get_image_path('snake_head.png'),(UNIT,UNIT))), ('neck',simplegui.Image_Info(simplegui.get_image_path('snake_neck.png'),(UNIT,UNIT))), ('straight',simplegui.Image_Info(simplegui.get_image_path('snake_body_straight.png'),(UNIT,UNIT))), ('left',simplegui.Image_Info(simplegui.get_image_path('snake_body_left.png'),(UNIT,UNIT))), ('right',simplegui.Image_Info(simplegui.get_image_path('snake_body_right.png'),(UNIT,UNIT))), ('tail',simplegui.Image_Info(simplegui.get_image_path('snake_tail.png'),(UNIT,UNIT))), ('food',simplegui.Image_Info(simplegui.get_image_path('snake_food.png'),(UNIT,UNIT)))]) images = dict([]) def draw_head(head, canvas): '''Draws the head and eyes''' head.draw(canvas,default=True) eye1_pos = head.rotate_offset([0.25*head.size[0], 0.25*head.size[1]]) eye2_pos = head.rotate_offset([0.25*head.size[0], -0.25*head.size[1]]) canvas.draw_circle(eye1_pos,2,1,'Black','Black')