text - Python/Pygame Title Rendering -


i'm trying render title little project i'm working on. i've replicated same code used create options set (merely ease) yet isn't working. wondering if knows i'm going wrong? it's obvious i'm not experienced when comes python.

here's code:

import pygame  class option:      hovered = false      def __init__(self, text, pos):         self.text = text         self.pos = pos         self.set_rect()         self.draw()      def draw(self):         self.set_rend()         screen.blit(self.rend, self.rect)      def set_rend(self):         self.rend = menu_font.render(self.text, true, self.get_color())      def get_color(self):         if self.hovered:             return (255, 255, 255)         else:             return (100, 100, 100)      def set_rect(self):         self.set_rend()         self.rect = self.rend.get_rect()         self.rect.topleft = self.pos  class title:      hovered = false      def __init__(self, text, pos):         self.text = text         self.pos = pos         self.set_rect()         self.draw()      def draw(self):         self.set_rend()         screen.blit(self.rend, self.rect)      def set_rend(self):         self.rend = title_font.render(self.text, true, self.get_color())      def get_color(self):         if self.hovered:             return (255, 255, 255)         else:             return (255, 255, 255)      def set_rect(self):         self.set_rend()         self.rect = self.rend.get_rect()         self.rect.topleft = self.pos  pygame.init()  screen = pygame.display.set_mode((480, 320))  menu_font = pygame.font.font(none, 40) options = [option("play game", (140, 105)), option("options", (155, 155)),            option("quit", (180, 205)), option("notpong", (150,20))]  title_font = pygame.display.font.font(none, 42) title = [title("notpong", (150,20))  while true:     pygame.event.pump()     screen.fill((0, 0, 0))     option in options:         if option.rect.collidepoint(pygame.mouse.get_pos()):             option.hovered = true         else:             option.hovered = false         option.draw()     pygame.display.update()  while true:     pygame.event.pump()     screen.fill((0, 0, 0))     title in title:         if title.rect.collidepoint(pygame.mouse.get_pos()):             title.hovered = true         else:             title.hovered = false         title.draw()     pygame.display.update()  

i not know want happen. think simple have typos. line title = [title("notpong", (150,20)) needs title = [title("notpong", (150,20))] closing bracket. , line title_font = pygame.display.font.font(none, 42) needs title_font = pygame.font.font(none, 42) without .display part. after fixing errors menu screen appears not anything. i'm not sure if trying menu show or can't menu or show.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -