def build(self): # display a button with the text : Hello QPython #return btn1 # return Button(text='Hello QPython') layout = GridLayout(rows=2) flayout = GridLayout(cols=3, row_force_default=False, size_hint_y =0.8) global buttons buttons = [] for x in range(1,13): btn = Plant(text='Plot %s' % x, background_color=[0,1,0,1]) btn.bind(on_press=callback) flayout.add_widget(btn, ) buttons.append(btn) layout.add_widget(flayout) s_button = Button(text="sow", border = [16,16,16,16]) s_button.bind(on_press=sow) w_button = Button(text="water") w_button.bind(on_press=water) clayout = GridLayout(cols=3,size_hint_y=0.2) clayout.add_widget(s_button) clayout.add_widget(w_button) layout.add_widget(clayout) Clock.schedule_interval(self.mytime, 1.0/1.0) return layout
def get_filtered_plants(self, species, dec_or_evg): print("species is", len(species)) print("doe is", len(dec_or_evg)) if len(species) == 0 and len(dec_or_evg) == 0: print("not filtering") return self.get_all_plants() cursor = self._connection.cursor() print("filtering") stmtStr, vals = self.create_filter_stmt(species, dec_or_evg) cursor.execute(stmtStr, vals) plants = [] row = cursor.fetchone() while row is not None: plant = Plant(str(row[0]), str(row[1]), str(row[2]), str(row[3]), str(row[4])) plant = Plant.getDict(plant) plants.append(plant) row = cursor.fetchone() cursor.close() return plants
def crossbreed(self, gamete): parent1 = self.origin parent2 = gamete.origin new_aut_TE = merge(self.aut_TE_list, gamete.aut_TE_list) new_nonaut_TE = merge(self.nonaut_TE_list, gamete.nonaut_TE_list) new_transposase_activity = 0.5 * (parent1.transposase_activity + parent2.transposase_activity) if param.location_mode : p = Plant.new(parent1.location, len(new_aut_TE), new_transposase_activity) else : p = Plant.new((0,0), len(new_aut_TE), new_transposase_activity) p.inactive_transposons = 0 #self.inactive_transposons p.phenotype = parent1.phenotype.generate_phenotype(parent2.phenotype) p.ord_counter = parent1.ord_counter #nie wiem co tu ma byc p.aut_transposons_list = new_aut_TE p.aut_transposons = len(new_aut_TE) p.nonaut_transposons_list = new_nonaut_TE p.nonaut_transposons = len(new_nonaut_TE) return p
def __init__(self): #-----location part if parameters.location_mode: self.mesh_size = 1./parameters.LD0range/2 f = lambda size: [[{} for x in xrange(int(size)+1)] for y in xrange(int(size)+1)] self.mesh = f(self.mesh_size) map_path = parameters.map_phenotype_image(parameters.maps) self.load_terrain(map_path+".info.tmp", map_path+".tmp") #------------------ from plant import Plant from phenotype import Phenotype self.plants = {} self.allplantslist = [] self.generation = 0 self.__class__.default = self self.__class__.environments += 1 debug.g("niche %d" % parameters.niche_size) for i in xrange(parameters.niche_size): if parameters.location_mode: Plant.new(parameters.get_start_point(parameters.maps)) else: Plant.new((0,0)) debug.g("*** %d" % len(self.plants)) self.optimal_global_phenotype = Phenotype() self.base_phenotype = Phenotype() self.survivors = parameters.niche_size self.randomkiller = selectors.KillerRandom() (self.killer, self.reproducer) = selectors.getSelectors() self.phenotype_link = Phenotype self.history = History(self) self.history.update()
def main(): #TODO: analyza dalsich logu log.filename = 'table_creator.log' plants = [] mj_list = [] a = '../../incoming/' if not os.path.isdir(a): a = './incoming' #endif for d in os.listdir(a): if os.path.isdir('%s/%s' % (a,d)) and d.startswith('mj') and not(d.endswith('d')): try: mj_list.append(int(d[2:])) except: pass #endif #endfor mj_list.sort() mj_list.reverse() for i in mj_list: x = Plant('mj%02i' % i) x.process() plants.append(x) #endfor create_table(plants) for i in plants: i = [i] create_table(i)
def important_fields_in_mesh(location): f = lambda (x,y): [(x,y),(x-r,y-r),(x,y-r),(x+r,y-r),(x-r,y),(x+r,y),(x-r,y+r),(x,y+r),(x+r,y+r)] g = lambda x: -1<x and x<self.mesh_size h = lambda (x,y): (Plant.scale(x),Plant.scale(y)) i = lambda (x,y): g(x) and g(y) #debug.g(location) #debug.g(r) fields = set() for x in filter(i, map(h, f(location))): fields.add(x) return fields
def get_plant_by_id(self, id_num): cursor = self._connection.cursor() stmt = "SELECT * FROM plant_indiv WHERE primary_id = %s;" cursor.execute(stmt, [id_num]) row = cursor.fetchone() if row is not None: plant = Plant(str(row[0]), str(row[1]), str(row[2]), str(row[3]), str(row[4])) plant = Plant.getDict(plant) cursor.close() return plant
def __init__(self, *args): super().__init__(*args) plants = [Plant("Plant 1", 0xa0), Plant("Plant 2", 0xb0)] available_ports = list([port.device for port in comports()]) self.portSelector = PortSelector(available_ports) self.portSelector.show() self.portSelector.portSelected.connect(self.set_port) self.portSelector.canceled.connect(self.quit) self.main_win = MainWindow()
def initplants(plants): # init three groups of plants with different sizes for i in range(3): loc = PVector(random(170, 220), height) tall = int(random(80, 130)) plants.append(Plant(loc, tall)) for j in range(3): loc = PVector(random(120, 150), height) tall = int(random(40, 80)) plants.append(Plant(loc, tall)) for k in range(2): loc = PVector(random(220, 240), height) tall = int(random(40, 60)) plants.append(Plant(loc, tall)) return plants
def get_all_plants(self): cursor = self._connection.cursor() stmt = "SELECT * FROM plant_indiv;" cursor.execute(stmt) plants = [] row = cursor.fetchone() while row is not None: plant = Plant(str(row[0]), str(row[1]), str(row[2]), str(row[3]), str(row[4])) plant = Plant.getDict(plant) plants.append(plant) row = cursor.fetchone() cursor.close() return plants
def search_in_range(self, south, north, east, west): cursor = self._connection.cursor() stmt, values = self.create_range_stmt(south, north, east, west) cursor.execute(stmt, values) plants = [] row = cursor.fetchone() while row is not None: plant = Plant(str(row[0]), str(row[1]), str(row[2]), str(row[3]), str(row[4])) plant = Plant.getDict(plant) plants.append(plant) row = cursor.fetchone() cursor.close() return plants
def getAllPlants(self): records = self.sheet.getAllRecords() plants = [ Plant(int(record[self.columnNames[0]]), record[self.columnNames[1]], datetime.datetime.strptime(record[self.columnNames[2]], '%Y-%m-%d').date(), int(record[self.columnNames[3]])) for record in records ] return plants
def evaluate(self): """runs the plant sim and returns (score, run_data)""" plant = Plant(lead_relevancy=self.lead_relevancy, speed=self.speed, distance_lead=self.distance_lead) last_live100 = None event_queue = sorted(self.cruise_button_presses, key=lambda a: a[1])[::-1] plot = ManeuverPlot(self.title) buttons_sorted = sorted(self.cruise_button_presses, key=lambda a: a[1]) current_button = 0 while plant.current_time() < self.duration: while buttons_sorted and plant.current_time( ) >= buttons_sorted[0][1]: current_button = buttons_sorted[0][0] buttons_sorted = buttons_sorted[1:] print "current button changed to", current_button grade = np.interp(plant.current_time(), self.grade_breakpoints, self.grade_values) speed_lead = np.interp(plant.current_time(), self.speed_lead_breakpoints, self.speed_lead_values) distance, speed, acceleration, distance_lead, brake, gas, steer_torque, fcw, live100 = plant.step( speed_lead, current_button, grade) if live100: last_live100 = live100[-1] d_rel = distance_lead - distance if self.lead_relevancy else 200. v_rel = speed_lead - speed if self.lead_relevancy else 0. if last_live100: # print last_live100 #develop plots plot.add_data(time=plant.current_time(), gas=gas, brake=brake, steer_torque=steer_torque, distance=distance, speed=speed, acceleration=acceleration, up_accel_cmd=last_live100.upAccelCmd, ui_accel_cmd=last_live100.uiAccelCmd, uf_accel_cmd=last_live100.ufAccelCmd, d_rel=d_rel, v_rel=v_rel, v_lead=speed_lead, v_target_lead=last_live100.vTargetLead, pid_speed=last_live100.vPid, cruise_speed=last_live100.vCruise, jerk_factor=last_live100.jerkFactor, a_target=last_live100.aTarget, fcw=fcw) print "maneuver end" return (None, plot)
def place_plant(self, row, col): if col < self.width-1 and self.board[row][col].isEmpty(): if self.cash >= Plant.cost: self.board[row][col].enqueue(Plant()) self.cash -= Plant.cost else: print("Bruh. You ain't got da dough for a plant") else: print("Nani deska? You can't place a plant there!")
def place_plant(self, row, col): if not self._board[row][col].is_empty() or col >= self.width: print("cannot place plant there") return if not self.cash >= Plant.cost: print("you don't have enough cash") return self.cash -= Plant.cost self._board[row][col].enqueue(Plant())
def loadPlantAndOrderList(args): plantName = args[0] orderListName = args[1] configName = args[2] plant = Plant.fromXmlFile(plantFileExists(plantName)) orderList = OrderList.fromXmlFile(orderListExists(orderListName), plant) return plant, orderList
def unserialize(cls, obj): e = cls(obj['name'], obj['light_on'], obj['light_off']) e.updated_at = obj['updated_at'] for p in obj['plants']: e.plants[p["name"]] = Plant.unserialize(p) return e
def _get_rows_of_plants(types): """ Types is array of (row, spacing, plant) tuples """ plants = [] for row, spacing, plant_type in types: for col in range(spacing // 2 + 2, NUM_X_STEPS - spacing // 2, spacing): plants.append(Plant.from_preset(plant_type, col, row)) return plants
def _get_random_plants_of_type(types): plants = [] for plant_type, num in types: x_locations = np.random.randint(3, NUM_X_STEPS - 3, (num, 1)) y_locations = np.random.randint(3, NUM_Y_STEPS - 3, (num, 1)) locations = np.hstack((x_locations, y_locations)) plants.extend([ Plant.from_preset(plant_type, row, col) for row, col in locations ]) return plants
def create_random_plants(self, num): death_age = random.randint(1, 100) proliferation = random.randint(5, 10) space_req = random.randint(2, 6) energy_supplied = random.randint(10, 20) ID = self.generate_new_id(Plant) for i in range(num): x = random.randint(1, self.width - 1) y = random.randint(1, self.height - 1) self.objects.append( Plant(death_age, proliferation, space_req, energy_supplied, x, y, ID, self))
def _get_grid_of_plants(types): count = 0 plants = [] for row in range(0, NUM_Y_STEPS - 1, 10): for col in range(0, NUM_X_STEPS - 1, 10): plants.append(Plant.from_preset(types[0][0], col, row)) count += 1 if count >= types[0][1]: types.pop(0) count = 0 return plants
def handle_event(self, e): if self.state != STATE_ON or sun.sun_score < self.score: return if e.type == SDL_MOUSEBUTTONDOWN and e.button == SDL_BUTTON_LEFT: pos = gobj.mouse_xy(e) if gobj.pt_in_rect(pos, self.get_bb()): # 식물 추가하기 m = Plant((e.x, get_canvas_height() - e.y), self.name) gfw.world.add(gfw.layer.plant, m) sun.sun_score -= self.score return True return False
def optimize(args): """ Runs the Scheduler with the OrderList from orderListName on the Plant with plantName. """ plantName = args[0] orderListName = args[1] plant = Plant.fromXmlFile(plantFileExists(plantName)) orderList = OrderList.fromXmlFile(orderListExists(orderListName)) optimizer = Optimizer(plant, orderList) optimizer.run()
def __init__(self, name, max_time_period, max_plant_size): """ This is a game constructor. It is called to create a new Game :param name: string containing the name of the game :param max_time_period: integer containing the number of "rounds" (time periods) in a game """ # name of the game attribute if name is not None: self.game_name = str(name) else: self.ame_name = 'Plant' # current time period of the game. This value will be incremented as # the game goes on self.time_period = 1 # game duration in terms maximum number of time periods if max_time_period > 0: self.max_time_period = max_time_period else: self.max_time_period = 20 # plant's size to achieve before the end of the game (in inches) if max_plant_size > 0: self.max_plant_size = max_plant_size else: self.max_plant_size = 10 # the plant object to grow in the game self.plant = Plant() # the available water for the plant to use at current time period self.available_water = 0 # the available light for the plant to use at current time period self.available_light = 0 # the available nutrients for the plant to use at current time period self.available_nutrients = 0
def new_game(cls, user): """Creates and returns a new game. Args: user: User Model that owns (parent of) the game. Returns: A new game Model.""" game = Game(user=user, plant=Plant.new_plant().key, game_over=False) game.put() logging.debug('new_game %s', game) return game
def _get_random_plants(plant_types, plants_per_color, seed=None): if seed is not None: np.random.seed(seed) plants = [] for name in plant_types: x_locations = np.random.randint(1, NUM_X_STEPS - 1, (plants_per_color, 1)) y_locations = np.random.randint(1, NUM_Y_STEPS - 1, (plants_per_color, 1)) locations = np.hstack((x_locations, y_locations)) plants.extend( [Plant.from_preset(name, row, col) for row, col in locations]) return plants
def schedule(args): """ Runs the Scheduler with the OrderList from orderListName on the Plant with plantName. """ plantName = args[0] orderListName = args[1] plant = Plant.fromXmlFile(plantFileExists(plantName)) orderList = OrderList.fromXmlFile(orderListExists(orderListName)) scheduler = Scheduler(plant, orderList) evaluator = Evaluator(plant) evaluator.evaluate(parseSolutions(scheduler.start(), orderList))
def read_from_disk(self, basepath): """ Loads all persisted entries from the filesystem and enqueues them to continue uploading :param basepath: The path where all persisted plant files are located :return: None """ for entry in os.listdir(basepath): if os.path.isfile(os.path.join(basepath, entry)) and fnmatch.fnmatch(entry, '*.json'): self._logger.info('Loading {} from disk for processing'.format(entry)) plant = Plant.load(os.path.join(basepath, entry)) self.add_plant(plant)
def vegetate(self): # grow a new plant if random.uniform(0, 100) < self.vegetation_rate: pos = (int(random.uniform(10, Simulation.window_width - 10)), int(random.uniform(10, Simulation.window_height - 10))) plant = Plant(pygame.Rect(pos[0], pos[1], 6, 6)) self.vegetation.append(plant) # check whether or not the plant was eaten and grow over time for plant in self.vegetation: eaten = self.eat(plant) if not eaten: if plant.bounds.width < 10 and random.uniform(0, 100) < 1: plant.bounds.width += 1 plant.bounds.height += 1
def loadPlantAndOrderList(plantName, orderListName): plant = Plant.fromXmlFile(plantFileExists(plantName)) orderList = OrderList.fromXmlFile(orderListExists(orderListName), plant) for i, m in enumerate(plant.machines): for o in orderList.orders: if o.recipe[m.name] == None: o.recipe.recipe.insert(i, [m.name, 0]) for o in orderList.orders: assert len(plant.machines) == len(o.recipe.recipe) normValue = normalizeValues(plant, orderList) return plant, orderList, normValue
def new_user(username, password, email): """ create a new user with a natural environment and a default plant """ u = User(username, password, email) u.add_environment(Environment('natural')) u.add_plant_to_environment(Plant.randomize_default(), 'natural') u.add_item(Item('water-tank', 10, False)) u.add_item(Item('water-reserve', 10, True)) u.add_item(Item('magic-bottle', 100, True)) return u
def _read_plants_from_csv(path): plants = [] with open(path) as csv_file: csv_reader = csv.reader(csv_file, delimiter=',') line_count = 0 for row in csv_reader: if line_count == 0: line_count += 1 else: coord = literal_eval(row[2]) x = round(coord[0] * NUM_X_STEPS / 1920) y = round(NUM_Y_STEPS - coord[1] * NUM_Y_STEPS / 1080) plants.append(Plant.from_preset(row[1], x, y)) line_count += 1 return plants
def load_from_proto(proto, db): logger = logging.getLogger() i2c = I2cController() pumps = { proto_pump.name: Pump(proto_pump, db, i2c) for proto_pump in proto.pumps } plants = {} for proto_plant in proto.plants: if proto_plant.pump_name not in pumps: logger.error("No pump found with name: " + proto_plant.pump_name) sys.exit(1) plants[proto_plant.name] = Plant(proto_plant, pumps[proto_plant.pump_name]) actions = [Action(action) for action in proto.actions] return Config(plants, pumps, actions, db, i2c)
def addMachine(args): """ Adds a Machine to a Plant with plantName. """ plantName = args[0] machineName = args[1] machineQuantity = args[2] machineDelay = args[3] machineCanUnhook = args[4] plantFilename = plantFileExists(plantName) plant = Plant.fromXmlFile(plantFilename) plant.addMachine( Machine(name=machineName, quantity=int(machineQuantity), minDelay=int(machineDelay), canUnhook=strToBool(machineCanUnhook))) plant.toXmlFile(plantFilename)
def click(self, keys): pos = pygame.mouse.get_pos() result = self.get_organism(pos) # print the contents of the location if result is not None: print(result) else: if keys[pygame.K_o]: new_organism = Organism(pos[0], pos[1]) new_organism.randomize() self.population.append(new_organism) elif keys[pygame.K_f]: new_plant = Plant(pygame.Rect(pos[0], pos[1], 6, 6)) self.vegetation.append(new_plant) elif keys[pygame.K_p]: new_predator = Predator(pos[0], pos[1]) new_predator.randomize() self.population.append(new_predator)
def place_plant(self, row, col): if row >= self.height or col >= self.width or row < 0 or col < 0: raise ValueError( str(row) + " " + str(col) + " aint no coordinates I ever heard of! do they speak english in " + str(row) + " " + str(col) + "?!") elif self.board[row][col] is self.board[row][-1]: raise ValueError( "you're out on the edge, yeah! and the HOA says no planting on the edge." ) elif self.is_plant(row, col) or self.is_nonplant(row, col): raise ValueError( "easy there xhibit, you've already got something in that spot." ) if self.cash <= Plant.cost: raise ValueError( "poor boy from a poor family, spare not their lives so you can afford me." ) self.cash -= Plant.cost self.board[row][col].enqueue(Plant())
def createMonsters(self): Green = (0, 255, 0) Pink = (255, 18, 248) level_rect = pygame.Rect(10, 10, 470, 310) level_rect2 = pygame.Rect(220, 85, 200, 100) levelFont = pygame.font.Font("fonts/BLOODY.ttf", 60) level_text = levelFont.render("Moving to Level ", False, Pink) level_text2 = levelFont.render(str(self.level), False, Pink) ### the transition surface between levels if self.trigger == False and self.level > 1: self.windowSurface.fill(Green) ## blit statement for the "changing levels self.windowSurface.blit(level_text, level_rect) self.windowSurface.blit(level_text2, level_rect2) pygame.display.update() #if self.elapsed_time > (3000): self.monster = True pygame.time.wait(3000) self.character.rect.center = (240, 160) self.direction = "stop" ## blits the super Monsters at the beginning of each level superMonster2 = Monster("crab") #superMonster2.image = pygame.image.load("img/superMonster_crab.png").convert_alpha() superMonster2.rect.center = (random.randint(400, 500), random.randint(-120, 20)) superMonster2.speed_trigger = 1 superMonster2.current_trigger = 0 self.superMonster2_group.empty() if self.level >= 6: self.superMonster2_group.add(superMonster2) superMonster = Monster("mummy") #superMonster.image = pygame.image.load("img/SuperMonster_mummy.png") #superMonster.image.convert_alpha() superMonster.rect.center = (random.randint(400, 500), random.randint(150, 340)) superMonster.speed_trigger = 1 superMonster.current_trigger = 0 self.superMonster_group.empty() if self.level >= 3: self.superMonster_group.add(superMonster) ### counter for the monsters speed zombie = Monster("zombie") zombie.speed_trigger = 2 zombie.current_trigger = 0 ##### instantiates the objects and addes them to the forest_group list if self.level == 2: tree = Plant() tree.rect.center = (15, 45) tree2 = Plant() tree2.rect.center = (460, 45) tree3 = Plant() tree3.rect.center = (15, 294) tree4 = Plant() tree4.rect.center = (460, 294) self.forest_group.add(tree, tree2, tree3, tree4) if self.level == 3: self.forest_group.empty() for x in range(10, 470, 32): y = 35 tree = Plant() tree.rect.center = (x, y) self.forest_group.add(tree) if self.level == 4: for x in range(10, 470, 32): y = 310 cactus = Plant() cactus.image = pygame.image.load("img/cactus.png") cactus.image.convert_alpha() cactus.rect.center = (x, y) self.forest_group.add(cactus) if self.level == 5: self.forest_group.empty() for x1 in range(40, 440, 30): y1 = 50 pillar = Plant() pillar.image = pygame.image.load("img/pillar.png") pillar.image.convert_alpha() pillar.rect.center = (x1, y1) for x2 in range(40, 440, 30): y2 = 100 pillar2 = Plant() pillar2.image = pygame.image.load("img/pillar.png") pillar.image.convert_alpha() pillar2.rect.center = (x2, y2) for x3 in range(40, 440, 30): y3 = 150 pillar3 = Plant() pillar3.image = pygame.image.load("img/pillar.png") pillar3.image.convert_alpha() pillar3.rect.center = (x3, y3) for x4 in range(40, 440, 30): y4 = 200 pillar4 = Plant() pillar4.image = pygame.image.load("img/pillar.png") pillar4.image.convert_alpha() pillar4.rect.center = (x4, y4) self.forest_group.add(pillar, pillar2, pillar3, pillar4) if self.level == 6: self.forest_group.empty() for y in range(40, 260, 70): for x in range(180, 330, 70): dragon = Plant() dragon.image = pygame.image.load("img/dragon.png") dragon.image.convert_alpha() dragon.rect.center = (x, y) self.forest_group.add(dragon) if self.level == 7: self.forest_group.empty() for x1 in range(30, 100, 30): y1 = 100 pillar1 = Plant() pillar1.image = pygame.image.load("img/pillar.png") pillar1.image.convert_alpha() pillar1.rect = pillar1.image.get_rect() pillar1.rect.center = (x1, y1) self.forest_group.add(pillar1) for x2 in range(15, 65, 30): y2 = 200 pillar2 = Plant() pillar2.image = pygame.image.load("img/pillar.png") pillar2.image.convert_alpha() pillar2.rect = pillar2.image.get_rect() pillar2.rect.center = (x2, y2) self.forest_group.add(pillar2) statue1 = Plant() statue1.image = pygame.image.load("img/statue.png") statue1.image.convert_alpha() statue1.rect = statue1.image.get_rect() statue1.rect.center = (240, 100) statue2 = Plant() statue2.image = pygame.image.load("img/statue.png") statue2.image.convert_alpha() statue2.rect = statue2.image.get_rect() statue2.rect.center = (240, 220) statue3 = Plant() statue3.image = pygame.image.load("img/statue.png") statue3.image.convert_alpha() statue3.rect = statue3.image.get_rect() statue3.rect.center = (180, 160) statue4 = Plant() statue4.image = pygame.image.load("img/statue.png") statue4.image.convert_alpha() statue4.rect = statue4.image.get_rect() statue4.rect.center = (300, 160) for x3 in range(380, 460, 30): y3 = 100 rubble = Plant() rubble.image = pygame.image.load("img/rubble.png") rubble.image.convert_alpha() rubble.rect = rubble.image.get_rect() rubble.rect.center = (x3, y3) self.forest_group.add(rubble) for x4 in range(380, 460, 30): y4 = 200 bones = Plant() bones.image = pygame.image.load("img/bones.png") bones.image.convert_alpha() bones.rect = bones.image.get_rect() bones.rect.center = (x4, y4) self.forest_group.add(bones) self.forest_group.add(statue1, statue2, statue3, statue4) if self.level == 8: self.forest_group.empty() lightThrone = Plant() lightThrone.image = pygame.image.load("img/lightThrone.png") lightThrone.image.convert_alpha() lightThrone.rect.center = (420, 120) darkThrone = Plant() darkThrone.image = pygame.image.load("img/darkThrone.png") darkThrone.image.convert_alpha() darkThrone.rect.center = (60, 120) coffin = Plant() coffin.image = pygame.image.load("img/coffin.png") coffin.image.convert_alpha() coffin.rect.center = (240, 160) for x in range(160, 320, 42): y = 300 knight = Plant() knight.image = pygame.image.load("img/knight.png") knight.image.convert_alpha() knight.rect.center = (x, y) self.forest_group.add(knight) for x2 in range(340, 420, 28): y2 = 50 crystal = Plant() crystal.image = pygame.image.load("img/crystal.png") crystal.image.convert_alpha() crystal.rect = crystal.image.get_rect() crystal.rect.center = (x2, y2) self.forest_group.add(crystal) for x3 in range(60, 140, 32): y3 = 50 bones = Plant() bones.image = pygame.image.load("img/bones.png") bones.image.convert_alpha() bones.rect = bones.image.get_rect() bones.rect.center = (x3, y3) self.forest_group.add(bones) self.forest_group.add(lightThrone, darkThrone, coffin) self.monster_num = 6 + (self.level * 3) print("The level is " + str(self.level)) print(str(self.monster_num) + " monsters created") print ("--------------------------------") for number in range(0, self.monster_num): monster = Monster("zombie") self.monster_group.add(monster) self.trigger = True
# To change this template, choose Tools | Templates # and open the template in the editor. __author__="francescopischedda" __date__ ="$20-mag-2011 12.12.17$" if __name__ == "__main__": from plant import Plant #from render import Render tree = Plant( 8, 80) tree.print_plant() #r = Render(800, 600, tree) #r.event_loop()