def render(self, rc, render_list):
        img = self.get_current_image(rc)
        width, height = img.get_size()

        px = int(self.x) - width // 2
        py = int(self.y) - height

        # Image: I, sort value, image, x, y
        render_list.append(("I", self.y * 1000000 + self.x, img, px, py))

        # if self.playboard != None and self.playboard.selected == self:
        # 	# Rectangle: R, sort value,
        # 	render_list.append(('R', self.y * 1000000 + self.x - 1, px - 2, py - 2, img.get_width() + 4, img.get_height() + 4, (255, 255, 255)))

        if self.holding != None:
            if self.holding == "iv":
                img = IMAGES.get("treatments/iv_bag.png")
            elif self.holding == "cucumber":
                img = IMAGES.get("treatments/cucumber.png")
            elif self.holding == "tape":
                img = IMAGES.get("treatments/tape.png")
            elif self.holding == "jacket":
                img = IMAGES.get("treatments/jacket.png")
            else:
                raise Exception("Invalid item holding." + self.holding)

            render_list.append(
                ("I", self.y * 1000000 + self.x + 1, img, self.x - img.get_width() // 2, self.y - 64 - img.get_height())
            )
	def render(self, screen, rc):
		bg = IMAGES.get('menus/title.png')
		screen.blit(bg, (0, 0))
		
		mx, my = self.cursor
		
		y = GAME_HEIGHT // 2
		x = GAME_WIDTH // 5
		
		current = None
		for option in [
			('New Game', 'new_game'),
			('Tutorial', 'tutorial'),
			('Options', 'options'),
			('Exit', 'exit')
			]:
			
			label, id = option
			button = self.buttons[id]
			hover = mx > button[0] and mx < button[2] and my > button[1] and my < button[3]
			
			if hover:
				current = id
			
			coords = TEXT.render(screen, label, 'yellow' if hover else 'white', x, y)
			self.buttons[id] = (x, y, coords[0], coords[1])
			y += 30
		self.currently_over = current
	def get_ui_elements(self):
		if self.elements == None:
			elements = []

			col1 = 25
			col2 = 230
			col3 = 400
			
			row1 = 10
			row2 = 150
			row3 = row2 * 2 - row1
			
			
			lava_lamp_image = create_ui_image_list([
				IMAGES.get('furniture/lava_lamp0.png'),
				IMAGES.get('furniture/lava_lamp1.png'),
				IMAGES.get('furniture/lava_lamp2.png'),
				IMAGES.get('furniture/lava_lamp3.png')], col1 + 32, row1)
			elements.append(lava_lamp_image)
			elements.append(create_ui_button('$' + str(LAVA_PRICE), self.buy_lava, col1, row1 + 70, 100, 24, lambda:self.can_afford(LAVA_PRICE)))
			
			plush_image = create_ui_image(IMAGES.get('furniture/the_doll.png'), col2 + 12, row1)
			elements.append(plush_image)
			elements.append(create_ui_button('$' + str(PLUSH_PRICE), self.buy_plush, col2, row1 + 70, 100, 24, lambda:self.can_afford(PLUSH_PRICE)))
			
			plant_image = create_ui_image(IMAGES.get('furniture/potted_flower.png'), col3 + 32, row1)
			elements.append(plant_image)
			elements.append(create_ui_button('$' + str(PLANT_PRICE), self.buy_plant, col3, row1 + 70, 100, 24, lambda:self.can_afford(PLANT_PRICE)))
			
			bean_bag_image = create_ui_image(IMAGES.get('furniture/bean_bag.png'), col1 + 16, row2)
			elements.append(bean_bag_image)
			elements.append(create_ui_button('$' + str(BEAN_BAG_PRICE), self.buy_bean_bag, col1, row2 + 70, 100, 24, lambda:self.can_afford(BEAN_BAG_PRICE)))
			
			foosball_image = create_ui_image(IMAGES.get('furniture/foosball.png'), col2, row2)
			elements.append(foosball_image)
			elements.append(create_ui_button('$' + str(FOOSBALL_PRICE), self.buy_foosball, col2, row2 + 70, 100, 24, lambda:(self.can_buy_foosball() and self.can_afford(FOOSBALL_PRICE))))
			
			description = create_ui_text('Mouse over item for description.', 'white', col1, row3 - 32)
			elements.append(description)
			
			
			descriptions = [
				(lava_lamp_image, "Lava lamp:\n+2% productivity, small radius."),
				(plush_image, "Giant plush:\n-10% chance of sad/angry/crazy\ndevices."),
				(plant_image, "Famous flower:\n+10% productivity, small radius."),
				(bean_bag_image, "Bean Bag:\n+3% productivity everywhere."),
				(foosball_image, "Miniature Sportsball:\n-5% productivity, devices don't\nland near it. Limit 1"),
			]
			
			for t in descriptions:
				img, text = t
				elements.append(create_ui_hover_region(description, img.left, img.top, img.right, img.bottom, text))
			
			
			self.elements = elements
		return self.elements
	def __init__(self, starting_level):
		self.staff = [Staff(0)]
		self.max_staff_size = IMAGES.get('staff/composite.png').get_height() // 64
		self.furniture = []
		
		self.budget = 1000
		self.inventory_ivs = 15
		self.inventory_cucumbers = 5
		self.inventory_tapes = 5
		self.inventory_jackets = 5
		self.inventory_laptops = 3
		self.inventory_phones = 3
		self.inventory_tablets = 3
		
		self.session = Session(starting_level, self) # 0 for tutorial
    def get_current_image(self, rc):
        images = self.images
        if images == None:
            images = {}
            composite = IMAGES.get("staff/composite.png")
            y = self.id * 64
            x = 0
            for dir in "nsew":
                for action in ["stand", "walk"]:
                    suffixes = [""] if (action == "stand") else ("0", "1", "2", "3")
                    for suffix in suffixes:
                        img = pygame.Surface((32, 64)).convert()
                        img.fill((255, 0, 255))
                        img.blit(composite, (-x, -y))
                        img.set_colorkey((255, 0, 255))
                        key = action + "_" + dir + suffix
                        images[key] = img
                        x += 32
            self.images = images

        if self.moving:
            return images["walk_" + self.direction + str((rc // 3) & 3)]
        return images["stand_" + self.direction]
	def initialize(self):
		raw = IMAGES.get('text/composite.png')
		self.raw_letters_by_color = {}
		row = 0
		for color in COLORS:
			letters = {}
			self.raw_letters_by_color[color] = letters
			y = row * HEIGHT
			x = 0
			col = 0
			for letter in LETTERS:
				x = col * WIDTH
				col += 1
				img = pygame.Surface((WIDTH, HEIGHT)).convert()
				img.fill((255, 0, 255))
				img.blit(raw, (-x, -y))
				img.set_colorkey((255, 0, 255))
				letters[letter] = img
				if letter.lower() != letter.upper():
					letters[letter.lower()] = img
					letters[letter.upper()] = img
			
			row += 1
		self.space_size = letters['a'].get_width()
	def render(self, rc, render_list):
		sort_key = self.y * 1000000
		
		progress_bar = None
		
		if self.state == 'flying':
			mid = FLYING_FRAMES // 2
			zeroToOne = 1.0 - ((self.state_counter - mid) ** 2.0) / (mid ** 2.0)
			py_offset = int(zeroToOne * 80)
			self.draw_image(render_list, IMAGES.get('devices/' + self.device_type + '.png'), sort_key, self.x, self.y - py_offset)
		elif self.state == 'ailed':
			self.draw_image(render_list, IMAGES.get('devices/' + self.device_type + '.png'), sort_key, self.x, self.y)
			ailment = IMAGES.get('devices/' + self.ailment + '.png')
			py_offset = int(math.sin(3.14159 + self.state_counter * 2 * 3.14159 / 150) * 10 + 30)
			self.draw_image(render_list, ailment, sort_key + 1, self.x, self.y - py_offset)
			
			if self.ailment == 'unknown' and self.unknown_discovery_counter > 0:
				progress_bar = [
					(0, 128, 255),
					self.unknown_discovery_counter,
					UNKNOWN_TREAT_TIME
				]
		elif self.state == 'treated':
			if self.ailment == 'sick':
				treatment_time = SICK_TREAT_TIME
				self.draw_image(render_list, IMAGES.get('devices/' + self.device_type + '.png'), sort_key, self.x, self.y)
				self.draw_image(render_list, IMAGES.get('treatments/iv_rack.png'), sort_key - 1, self.x - 16, self.y,)
			elif self.ailment == 'sad':
				treatment_time = SAD_TREAT_TIME
				self.draw_image(render_list, IMAGES.get('devices/' + self.device_type + '_cucumber.png'), sort_key, self.x, self.y)
			elif self.ailment == 'angry':
				treatment_time = ANGRY_TREAT_TIME
				self.draw_image(render_list, IMAGES.get('devices/' + self.device_type + '_headphones.png'), sort_key, self.x, self.y)
			elif self.ailment == 'crazy':
				treatment_time = CRAZY_TREAT_TIME
				self.draw_image(render_list, IMAGES.get('devices/' + self.device_type + '_straightjacket.png'), sort_key, self.x, self.y)
			else:
				raise Exception("No rendering code for ailment treatment.")
			
			counter = int(self.treatment_ratio * self.state_counter)
			if counter > treatment_time: counter = treatment_time
			
			progress_bar = [
				(0, 255, 0),
				self.state_counter,
				treatment_time
			]
		else:
			self.draw_image(render_list, IMAGES.get('devices/' + self.device_type + '.png'), sort_key, self.x, self.y)

		if progress_bar != None:
			numerator = progress_bar[1]
			treatment_time = progress_bar[2]
			color = progress_bar[0]
			progress = 1.0 * numerator / treatment_time
			if progress > 1.0:
				progress = 1.0
			
			width = 50
			height = 8
			x = self.x - 12
			y = self.y + 8
			self.draw_rectangle(render_list, sort_key, x, y, width, height, (100, 100, 100))
			self.draw_rectangle(render_list, sort_key, x, y, int(width * progress), height, color)
		
		if self.state == 'ailed' or self.state == 'treated':
			progress = 1.0 * self.ttl / STARTING_TTL
			color = (0, 180, 0)
			if progress > .5:
				if progress > .75:
					color = (0, 100, 200)
				else:
					color = (0, 180, 0)
			elif progress > .25:
				color = (255, 255, 0)
			elif progress > .1:
				color = (255, 128, 0)
			else:
				color = (255, 0, 40)
			
			
			width = 50
			height = 8
			x = self.x - 12
			y = self.y
			self.draw_rectangle(render_list, sort_key, x, y, width, height, (100, 100, 100))
			self.draw_rectangle(render_list, sort_key, x, y, int(width * progress), height, color)
	def render(self, screen, rc, nullable_devices, nullable_staff, interesting_coords, nullable_supplies, mutable_animations, show_influence_radius, angry_employee_num):
		
		render_list = []
		
		if angry_employee_num == None:
			bg = IMAGES.get('the_room.png')
		else:
			bg = IMAGES.get('open_door_from_which_horribly_broken_devices_spew_forth.png')
		
		render_list.append(('I', -1, bg, 0, 0))
		
		if angry_employee_num != None:
			emp = IMAGES.get('angry_employee' + str(angry_employee_num) + '.png')
			render_list.append(('I', 0, emp, 440, 0))
		
		if nullable_staff != None:
			for member in nullable_staff:
				member.render(rc, render_list)
				if member.drag_path != None:
					for dot in member.drag_path.get_marker_list(rc):
						x, y = dot
						render_list.append(('R', y * 1000000, x - 1, y - 1, 2, 2, (255, 255, 0)))
		
		if nullable_devices != None:
			for device in nullable_devices:
				device.render(rc, render_list)
			
		for interesting in interesting_coords:
			key, x, y = interesting
			
			influence = None
			
			has_any = nullable_supplies == None or nullable_supplies.get(key, True) # default to true for placement screen
			if key == 'i':
				file = 'treatments/ivs'
			elif key == 'c':
				file = 'treatments/cucumber_station'
				x += .3
			elif key == 't':
				file = 'treatments/tape_shelf'
			elif key == 'j':
				file = 'treatments/jacket_rack'
			elif key == '1':
				file = 'furniture/lava_lamp' + str((rc // 5) % 4)
				influence = (x * 32 + 16, y * 32 + 16, 3 * 32, (0, 100, 255))
			elif key == '2':
				file = 'furniture/the_doll'
			elif key == '3':
				file = 'furniture/potted_flower'
				influence = (x * 32 + 16, y * 32 + 16, 3 * 32, (0, 100, 255))
			elif key == '4':
				file = 'furniture/bean_bag'
			elif key == '5':
				file = 'furniture/foosball'
				influence = (x * 32 + 16 + 32, y * 32, 4 * 32, (255, 0, 0))
			
			if key in ('i', 'c', 't', 'j'):
				path = file + '_' + ('full' if has_any else 'empty') + '.png'
			else:
				path = file + '.png'
			img = IMAGES.get(path)
			render_list.append(('I', (y + 1) * 32 * 1000000, img, int(x * 32), (y + 1) * 32 - img.get_height()))
			
			if show_influence_radius and influence != None:
				pts = 50 
				for i in range(pts):
					cx, cy, r, color = influence
					ang = 2 * 3.14159265 * (i + rc * .1) / pts
					x = int(cx + math.cos(ang) * r)
					y = int(cy + math.sin(ang) * r)
					render_list.append(('R', y * 1000000 + x, x, y, 2, 2, color))

		if mutable_animations != None:
			i = 0
			while i < len(mutable_animations):
				animation = mutable_animations[i]
				images = []
				if animation['type'] == 'device':
					images.append(IMAGES.get('devices/' + animation['device'] + '.png'))
					images.append(IMAGES.get('devices/' + animation['overlay'] + '.png'))
				ttl = animation['ttl']
				ttl -= 1
				animation['ttl'] = ttl
				
				for img in images:
					render_list.append(('I', animation['mx'] + animation['my'] * 1000000, img, animation['x'] - img.get_width() // 2, animation['y'] - img.get_height()))
					
				animation['x'] += animation['vx']
				animation['y'] += animation['vy']
				
				if ttl > 0:
					i += 1
				else:
					mutable_animations.pop(i)

		self.draw_to_screen(screen, render_list)