Exemple #1
0
	def __init__(self, renderer, score, end_reason=DEFEAT):
		super().__init__(renderer, 'Thy name: ')
		self.title = hud.Text(
			'GAME OVER' if end_reason==GameOver.DEFEAT else 'YOU WIN',
			renderer, Constants.TITLE_FONT_SIZE,
			Colour.Burgundy if end_reason==GameOver.DEFEAT else Colour.Green
		)
		self.subtitle = hud.Text('Thy score: {}'.format(score), renderer, Constants.MENU_FONT_SIZE)

		self.title.position.y = int(20 * Constants._scale_ratio)
		self.title.centerHorizontally()
		self.subtitle.position.y = int(100 * Constants._scale_ratio)
		self.subtitle.centerHorizontally()

		self.score = score
Exemple #2
0
	def render(self, renderer):
		"""Render the level."""
		renderer.copy(Wall.TEXTURE, None, (0, 0, Constants.SIDE_MARGIN, Constants.WINDOW_SIZE.y))
		renderer.copy(Wall.TEXTURE, None, (Constants.WINDOW_SIZE.x-Constants.SIDE_MARGIN, 0, Constants.SIDE_MARGIN, Constants.WINDOW_SIZE.y))

		self.palette.render(renderer)
		if not self.endgame:
			self.ball.render(renderer)
		for i in self.bricks:
			i.render(renderer)
		for j in self.bonuses:
			j.render(renderer)

		h = hud.Text(str(self.score), renderer, size=Constants.UPPER_MARGIN-10)
		h.render(renderer, (Constants.SIDE_MARGIN + 50, 5))

		msg = '{} live{}'.format(self.lives, 's' if self.lives != 1 else '')
		h.load(msg, renderer, size=Constants.UPPER_MARGIN-10)
		h.render(renderer, (Constants.WINDOW_SIZE.x - 4*Constants.BRICKSIZE.x, 5))

		if self.tech_support:
			self.renderTechSupport(renderer)

		if self.fading:
			self.fader.draw(renderer)
			if self.fader.finished():
				self.fading = False
				self.fader.reset()
				self.completeBreak()
Exemple #3
0
    def __init__(self, renderer, highscores=None):
        # Background stuff.
        Menu.bg_offset_at_start = 250
        Menu.bg_offset = Menu.bg_offset_at_start
        Menu.bg_dimness_peak = 0x88
        Menu.bg_dimness_current = 0xff
        Menu.bg_diminish_rate = 0.33

        self.choice = None
        self.is_open = True

        self.title = hud.Text('pyNoid', renderer, Constants.TITLE_FONT_SIZE)
        self.title.position = vec2(50, 50)

        self.credits = hud.Text('Kacper Tonia 2017/18', renderer,
                                Constants.TINY_FONT_SIZE)
        self.credits.position = self.title.position + vec2(
            self.title.size[0] // 2, self.title.size[1])

        grey = Colour.greyscale(0.75)

        sub1 = hud.Button.buildClickableText('New Game', renderer,
                                             Colour.White, grey, grey,
                                             Constants.MENU_FONT_SIZE)
        sub2 = hud.Button.buildClickableText('Exit', renderer, Colour.White,
                                             grey, grey,
                                             Constants.MENU_FONT_SIZE)
        self.menu = hud.VerticalContainer([sub1, sub2],
                                          Constants.WINDOW_SIZE.y // 2)

        if highscores:
            leaderboard = []
            player_name_length = max([len(x[0]) for x in highscores])
            score_length = max([len(str(x[1])) for x in highscores])
            s_format = '{:>%d} {}{}' % player_name_length
            for idx, item in enumerate(highscores):
                leaderboard.append(
                    hud.Text(
                        s_format.format(
                            item[0], item[1],
                            ' ' * (score_length - len(str(item[1])))),
                        renderer, Constants.FONT_SIZE_1,
                        Colour.greyscale((5 - idx) / 5.0)))
            self.render_content = hud.VerticalContainer(
                leaderboard, Constants.WINDOW_SIZE.y * 3 // 4)
        else:
            self.render_content = []
Exemple #4
0
	def render(self, renderer):
		if self.message:
			self.message.render(renderer)
		if self.input:
			out1 = hud.Text(self.input, renderer, Constants.FONT_SIZE_1)
			out1.position = vec2(self.message.position.x+self.message.size[0], self.message.position[1])
			out1.render(renderer)

		if self.fading:
			self.fader.draw(renderer)
			if self.fader.finished():
				self.fading = False
				self.fader.reset()
				self.is_open = False
Exemple #5
0
	def __init__(self, renderer, message=''):
		self.message = hud.Text(message, renderer, Constants.FONT_SIZE_1)
		self.message.center()

		self.input = ''
		self.is_open = True