예제 #1
0
    def __init__(self):
        super(Game, self).__init__()
        pyglet.resource.path = settings.RESOURCE_PATH
        pyglet.resource.reindex()
        self.window = pyglet.window.Window(
                width=settings.MAIN_WINDOW_WIDTH
                , height=settings.MAIN_WINDOW_HEIGHT, vsync=False)
        self.current_scene = menu.MainMenu(self)
        sounds.load()
        music.load()

        self.unfinished_levels = copy.copy(gamelevel.glevels)
        self.loaded_level = -1
        self.scores = defaultdict(int)
예제 #2
0
    def __init__(self, game):

        # create a window and grab fullscreen with exclusive mouse
        #super(MainMenu, self).__init__(width = 1024, height = 768)
        #self.set_exclusive_mouse()
        super(MainMenu, self).__init__()
        music.load()
        music.play('pink')

        self.game = game
        
        self.num_options = 4 #number of menu items to choose from
        self.main_batch = pyglet.graphics.Batch()

        self.game_label = pyglet.text.Label(batch = self.main_batch)
        self.game_label.text = "Python on Rails"

        self.start_label = pyglet.text.Label(batch = self.main_batch)
        self.start_label.text = "Start Game"
        self.instructions_label = pyglet.text.Label(batch = self.main_batch)
        self.instructions_label.text = "Instructions"
        self.highscores_label = pyglet.text.Label(batch = self.main_batch)
        self.highscores_label.text = "Highscores"
        self.quit_label = pyglet.text.Label(batch = self.main_batch)
        self.quit_label.text = "Quit"
        
        self.controls_label = pyglet.text.Label(batch = self.main_batch)
        self.controls_label.text = "[UP], [DOWN] to select an option, [SPACE] to select"

        self.by_label = pyglet.text.Label(batch = self.main_batch)
        self.by_label.text = "By NSTeamStrong - jtrain, kburd, danaran and rozifus. Piece."
        
        self.option_labels = [self.start_label, self.instructions_label,
                self.highscores_label, self.quit_label]
        self.all_labels = [self.game_label, self.controls_label, self.by_label]
        self.all_labels.extend(self.option_labels)
        
        self.layout_items()
        self.selected_option = 1
예제 #3
0
BUTTON_WIDTH = 100
CAR_X_SPEED = 5
DISPLAY_CAPTION = 'A bit Racey'
DISPLAY_HEIGHT = 600
DISPLAY_WIDTH = 800
FONT_NAME = 'comicsansms'
FPS = 60

pygame.init()

# Load resources from disk
image_car = pygame.image.load('assets/race_car.png')
font_small = pygame.font.SysFont(FONT_NAME, 25)
font_large = pygame.font.SysFont(FONT_NAME, 115)
sound_crash = pygame.mixer.Sound('assets/crash_sfx.wav')
music.load('assets/background_music.wav')

# Setup window
pygame.display.set_caption(DISPLAY_CAPTION)

display_surface = pygame.display.set_mode((DISPLAY_WIDTH, DISPLAY_HEIGHT))

icon_car = pygame.transform.scale(image_car, (32, 32))
pygame.display.set_icon(icon_car)

clock = pygame.time.Clock()


def draw_background_colour(background_colour):
    display_surface.fill(background_colour)