def close_level_overlay(self, reset = False): self.has_level_overlay = False if (reset): self.lunar = self.set_lunar(CONSTANTS.GAME_WIDTH, CONSTANTS.GAME_HEIGHT) self.level = level.Level(self.gameboard) self.lunar.set_lunar_to_start() else: current_handicap = self.level.handicap self.level = level.Level(self.gameboard, current_handicap + 1) self.lunar.set_lunar_to_start()
def __init__(self, width = CONSTANTS.GAME_WIDTH, height = CONSTANTS.GAME_HEIGHT): self.__gameboard = self.set_gameboard(super(), width, height) self.__level = level.Level(self.gameboard) self.__player = player.Player("") self.__lunar = self.set_lunar(width, height) self.__key_control = control.KeyControl() self.__has_level_overlay = False self.__started = False self.__vocab_map = vcm.VocabularyMap()
def calculate_rankings(team_manager, alg): # reset team points before calculations team_manager.reset() teams = team_manager.get_teams() # print progress bar line print("_"*54) # loop through teams for i, team in enumerate(teams): # create a level_manager for the current team level_manager = Level(team, alg) # get first level level = level_manager.get_next_level() # while levels still exist calculate points while len(level_manager.current_level) > 0: for team_info in level: points = 0 if alg == "win": # points = the sum of the wins (+1 for win -1 for loss) / games played points += sum(team_info["won"])/len(team_info["won"]) if points == 0: points += team_info["prev_streak"] elif alg == "score": # points = the sum of the points earned by the team points += sum(team_info["score"])/len(team_info["score"]) elif alg == "score_win": points = sum(team_info["score"])/len(team_info["score"]) if points != 0: points/= abs(points) team.points += points # add calculated points level = level_manager.get_next_level() # get next level if i % 4 == 0: print("█", end="") return team_manager.get_rankings() # return list of ranked teams
repeatMenu = False # quit the menu choice = 'maps/level1.txt' # define the level to load elif event.key == K_2: repeatMenu = False choice = 'maps/level2.txt' #we check that the player has made a level choice #to not load if he leaves if choice is not 0: #load the background image background = pim.load(c.bgPicture).convert() #define the door position door = (14, 14) #generate the level level = Level(choice) level.generate() #create the utilities objects #and append them to a table tabUtilities = [] tabUtilities.append(Utility('S', level)) tabUtilities.append(Utility('E', level)) tabUtilities.append(Utility('N', level)) #create the character bot = Bot(c.heroPicture, level) #print the labyrinth level.show(bot, windows) #game loop while repeatGame: #limit the clock speed
def main(width, height): # import modules import pygame import os import random import time from classes import PowerUp from classes import Level from classes import Character from classes import Cloud from classes import Obtainium # Death counter deaths = 0 clock = pygame.time.Clock() pygame.init() font = pygame.font.SysFont("OSP-DIN", 48) # create the screen dimensions = (width, height) screen = pygame.display.set_mode(dimensions) # helps with making the close button in the corner work running = 1 # The ground level = Level(screen, width, height, "resources/Level 1.png") # The character, who's sprite is a gingerbread man gingerman = Character(screen, width, height) coin_imgs = ["resources/Coin2.png", "resources/Coin.png"] # The clouds. We put them into a list so we can iterate through them clouds = [Cloud(), Cloud(), Cloud()] coins = [] powerups = [] rocks = Obtainium(screen, width, height, "resources/stone.png", width / 2, 50, True) for x in range(7): coins.append( Obtainium( screen, width, height, random.choice(coin_imgs), (random.randint(-400, 4000)) - (10 * x) + width, height - 150, ) ) powerups.append( PowerUp( screen, width, height, "resources/arrow.png", (random.randint(-400, 4000)) - (10 * x) + width, height - 150, ) ) # If the arrow keys are held down, we want the character to continously move. This helps with that. pygame.key.set_repeat(100, gingerman.speed) # Gameloop, executes all the actions while running: # Gets a list of what's happening events = pygame.event.get() # Reads the list of what's happening for event in events: # Exits program if red X cliked if event.type == pygame.QUIT: running = 0 # Moves the character if the keys are pressed if event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT: gingerman.move(level, "left", coins, powerups) if event.key == pygame.K_RIGHT: gingerman.move(level, "right", coins, powerups) if event.key == pygame.K_SPACE: gingerman.move(level, "up", coins, powerups) # makes the background blue screen.fill((135, 206, 235)) # Shows the level level.display() for coin in coins: coin.display(gingerman, level) for thing in powerups: thing.display(gingerman, level) deathtext = font.render("Score:" + str(gingerman.deaths), 1, (255, 255, 255)) rocktext = font.render("Rocks:" + str(gingerman.rocks), 1, (255, 255, 255)) rocks.display(gingerman, level) # Makes sure physics applies gingerman.move(level, "forward", coins) # Shows and moves the cloud for cloud in clouds: cloud.move() screen.blit(deathtext, (0, 0)) screen.blit(rocktext, (0, 48)) # Shows everything pygame.display.flip() clock.tick(120)
#Author : Simon Maciag import pygame from pygame.locals import * pygame.init() import classes.Player as p import classes.Level as l import classes.Mob as m import threading as t import multiprocessing as multi import random import time level1 = l.Level(1) level2 = l.Level(2) level3 = l.Level(3) level4 = l.Level(4) level5 = l.Level(5) menu = l.Menu() perso = p.Player([level1, level2, level3, level4, level5]) level1.player = perso level2.player = perso level3.player = perso level4.player = perso level5.player = perso boss1 = m.Officer(10, 16, level1, 1) boss2 = m.Officer(7, 1, level2, 2)
from classes import Level level_list = { 1: Level(level=1, exp=0), 2: Level(level=2, exp=83), 3: Level(level=3, exp=174), 4: Level(level=4, exp=276), 5: Level(level=5, exp=388), 6: Level(level=6, exp=512), 7: Level(level=7, exp=650), 8: Level(level=8, exp=801), 9: Level(level=9, exp=969), 10: Level(level=10, exp=1154), 11: Level(level=11, exp=1358), 12: Level(level=12, exp=1584), 13: Level(level=13, exp=1833), 14: Level(level=14, exp=2107), 15: Level(level=15, exp=2411), 16: Level(level=16, exp=2746), 17: Level(level=17, exp=3115), 18: Level(level=18, exp=3523), 19: Level(level=19, exp=3973), 20: Level(level=20, exp=4470), 21: Level(level=21, exp=5018), 22: Level(level=22, exp=5624), 23: Level(level=23, exp=6291), 24: Level(level=24, exp=7028), 25: Level(level=25, exp=7842), 26: Level(level=26, exp=8740), 27: Level(level=27, exp=9730), 28: Level(level=28, exp=10824),