コード例 #1
0
ファイル: MenuWidget.py プロジェクト: majormunky/PygEngine
 def __init__(self,
              list_items,
              x,
              y,
              text_color=(0, 0, 0),
              disabled_color=(200, 200, 200),
              font_size=40,
              font_face=None,
              menu_spacing=1.5):
     self.x = x
     self.y = y
     self.font_size = font_size
     self.font_face = font_face
     self.list_items = list_items
     self.disabled_items = []
     self.item_images = {}
     self.current_item = 0
     self.text_color = text_color
     self.disabled_color = disabled_color
     self.menu_height = 0
     self.menu_spacing = menu_spacing
     self.bullet_character = ">"
     self.bullet = text_surface(self.bullet_character,
                                font_size=self.font_size,
                                color=self.text_color)
     self.title = None
     self.render_images()
コード例 #2
0
 def draw_title(self, title):
     y_pos = self.padding
     title = text_surface(title, font_size=40, color=(255, 255, 255))
     self.image.blit(title, (self.padding, self.padding))
     y_pos += title.get_rect().height
     pygame.draw.line(self.image, (255, 255, 255), (self.padding, y_pos),
                      (self.page_width - (self.padding * 2), y_pos), 2)
コード例 #3
0
ファイル: main.py プロジェクト: giurix/P3
    def __init__(self):
        self.money= 500
        self.irand= randint(3, 10)
        self.screenrect = get_screenrect()
        self.surface = pygame.Surface((1280, 720))
        self.background_image = load_image("bg.png")
        self.surface.blit(self.background_image, (0, 0))
        self.game_timer = 0
        self.wave_times2 = [[100]]
        self.wave_times = [
            [100, 1000, 1500, 2500, 3000, 6000],
            [100, 500, 1000],
            [100, 500, 1300, 2400]
        ]
        self.wave_time_index = 0
        self.money_index = 500
        self.current_wave = self.wave_times[self.wave_time_index]
        self.current_wave_completed = False
        self.current_wave_index = 0
        self.tower_pos = [
            [150, 50, "down"],
            [150, 120, "down"],

        ]
        self.slots = []
        self.towers = []
        self.waypoint_list = [
            [100, 0],
            [100, 620],
            [400, 620],
            [400, 100],
            [700, 100],
            [700, 620],
            [1000, 620],
            [1000, 100],
            [1280, 100]
        ]
        self.enemies = []
        self.spawned = 0
        self.killed = 0
        self.wave_text = text_surface("Wave: 1", font_size=24)
        self.money_text = text_surface("Danish Dollars: 500", font_size=24)
        self.health_index = 100
        self.health_text = text_surface("Health: 100", font_size=24)
        self.post_init()
        self.lost = text_surface("YOU LOST!", font_size=50)
コード例 #4
0
 def render(self):
     self.image = pygame.Surface((self.rect.width, self.rect.height),
                                 pygame.SRCALPHA)
     self.image.fill(self.background_color)
     self.image.blit(
         self.title_text,
         ((self.rect.width / 2) -
          (self.title_text.get_rect().width / 2), 20),
     )
     ants_looking = [
         ant for ant in self.game.ants if ant.state == "searching"
     ]
     looking_text = text_surface("Looking: {}".format(len(ants_looking)),
                                 font_size=36)
     self.image.blit(
         looking_text,
         ((self.rect.width / 2) - (looking_text.get_rect().width / 2), 50),
     )
     ants_scanning = [
         ant for ant in self.game.ants if ant.state == "scanning"
     ]
     scanning_text = text_surface("Scanning: {}".format(len(ants_scanning)),
                                  font_size=36)
     self.image.blit(
         scanning_text,
         ((self.rect.width / 2) - (scanning_text.get_rect().width / 2), 80),
     )
     ants_found = [
         ant for ant in self.game.ants
         if ant.state in ["found", "found_waiting"]
     ]
     found_text = text_surface("Found: {}".format(len(ants_found)),
                               font_size=36)
     self.image.blit(
         found_text,
         ((self.rect.width / 2) - (found_text.get_rect().width / 2), 110),
     )
     exit_found = [
         ant for ant in self.game.ants if ant.state == "moving_to_exit"
     ]
     exit_text = text_surface("Exiting: {}".format(len(exit_found)),
                              font_size=36)
     self.image.blit(
         exit_text,
         ((self.rect.width / 2) - (exit_text.get_rect().width / 2), 140),
     )
コード例 #5
0
	def render_images(self):
		for item in self.list_items:
			if item in self.disabled_items:
				color = self.disabled_color
			else:
				color = self.text_color
			self.item_images[item] = text_surface(item, 40, color)
			self.menu_height += self.item_images[item].get_rect().height
		print(self.menu_height)
コード例 #6
0
ファイル: main.py プロジェクト: majormunky/PygameBreakout
    def draw(self, canvas):
        pygame.draw.rect(canvas, (0, 0, 200), self.player_rect)
        pygame.draw.circle(canvas, (0, 200, 0), self.ball_pos,
                           self.ball_radius)
        left_key = text_surface("Left Key: {}".format(
            self.keys_pressed[pygame.K_LEFT]),
                                color=(255, 255, 255),
                                font_size=24)
        right_key = text_surface("Right Key: {}".format(
            self.keys_pressed[pygame.K_RIGHT]),
                                 color=(255, 255, 255),
                                 font_size=24)
        ball_vel = text_surface("Ball Velocity: {}".format(self.ball_velocity),
                                color=(255, 255, 255),
                                font_size=24)

        for block in self.blocks:
            block.draw(canvas)
コード例 #7
0
 def __init__(self, rect, game):
     self.background_color = (20, 0, 0)
     self.game = game
     self.rect = rect
     self.image = None
     self.title_text = text_surface("Ants", font_size=36)
     self.update_limit = 400
     self.update_timer = 0
     self.render()
コード例 #8
0
ファイル: MenuWidget.py プロジェクト: majormunky/PygEngine
 def render_images(self):
     for item in self.list_items:
         if item in self.disabled_items:
             color = self.disabled_color
         else:
             color = self.text_color
         self.item_images[item] = text_surface(item,
                                               self.font_size,
                                               color,
                                               font_face=self.font_face)
コード例 #9
0
ファイル: Dialog.py プロジェクト: majormunky/RPG
    def render(self):
        self.image = pygame.Surface(
            (self.screenrect.width, self.screenrect.height), pygame.SRCALPHA)
        self.image.fill((100, 100, 100, 128))
        pygame.draw.rect(self.image, (0, 0, 200), self.dialog_rect)

        x = self.dialog_rect.x + self.padding
        y = self.dialog_rect.y + self.padding

        for line in self.lines:
            text = text_surface(line, font_size=32)
            self.image.blit(text, (x, y))
            y += text.get_rect().height + self.padding
コード例 #10
0
 def render_images(self):
     self.menu_height = 0
     self.item_images = {}
     for item in self.list_items:
         if item in self.disabled_items:
             color = self.disabled_color
         else:
             color = self.text_color
         self.item_images[item] = text_surface(item,
                                               self.font_size,
                                               color,
                                               font_face=self.font_face)
         self.menu_height += self.item_images[item].get_rect().height
コード例 #11
0
ファイル: main.py プロジェクト: majormunky/pygame_tower
 def __init__(self):
     self.screenrect = get_screenrect()
     self.surface = pygame.Surface((480, 320))
     self.background_image = load_image("bg.png")
     self.surface.blit(self.background_image, (0, 0))
     self.game_timer = 0
     self.wave_times2= [[100]]
     self.wave_times = [
         [100, 1000, 1500, 2500, 3000, 6000],
         [100, 500, 1000],
         [100, 500, 1300, 2400]
     ]
     self.wave_time_index = 0
     self.current_wave = self.wave_times[self.wave_time_index]
     self.current_wave_completed = False
     self.current_wave_index = 0
     self.tower_pos = [
         [60, 32, "down"],
         [150, 32, "down"],
         [240, 32, "down"],
         [330, 32, "down"],
         [370, 124, "up"],
         [280, 124, "up"],
         [190, 124, "up"],
         [100, 124, "up"],
         [60, 218, "up"],
         [150, 218, "up"],
         [240, 218, "up"],
         [330, 218, "up"],
     ]
     self.slots = []
     self.towers = []
     self.waypoint_list = [
         [0, 100],
         [440, 100],
         [440, 194],
         [35, 194],
         [35, 286],
         [380, 286],
     ]
     self.enemies = []
     self.spawned = 0
     self.killed = 0
     self.wave_text = text_surface("Wave: 1", font_size=24)
     self.post_init()
コード例 #12
0
ファイル: Enemy.py プロジェクト: majormunky/pygame_tower
 def update_image(self):
     self.info_layer.fill((0, 0, 0, 1.0))
     hp_text = text_surface(self.current_hp, font_size=18)
     self.info_layer.blit(hp_text, (0, 0))
コード例 #13
0
ファイル: Enemy.py プロジェクト: giurix/P3
 def update_image(self):
     self.info_layer.fill((0, 0, 0, 1.0))
     hp_text = text_surface(self.current_hp, font_size=18)
     self.info_layer.blit(hp_text, (0, 0))
コード例 #14
0
ファイル: main.py プロジェクト: giurix/P3
 def update_money_label(self):
     self.money_text = text_surface("Danish Dollars: " + str(self.money_index), font_size=24)
コード例 #15
0
ファイル: main.py プロジェクト: giurix/P3
 def update_health_text(self):
     self.health_text = text_surface("Health: " + str(self.health_index), font_size=24)
コード例 #16
0
ファイル: MenuWidget.py プロジェクト: majormunky/PygEngine
 def set_title(self, text):
     self.title = text_surface(text,
                               font_size=self.font_size,
                               color=self.text_color)
コード例 #17
0
ファイル: main.py プロジェクト: giurix/P3
 def update_wave_label(self):
     self.wave_text = text_surface("Wave: {}".format(self.wave_time_index), font_size=24)
コード例 #18
0
ファイル: main.py プロジェクト: majormunky/pygame_tower
 def update_wave_label(self):
     self.wave_text = text_surface("Wave: {}".format(self.wave_time_index), font_size=24)
コード例 #19
0
ファイル: IntroScene.py プロジェクト: majormunky/pyrpg-2019
 def __init__(self, manager):
     self.manager = manager
     self.intro_text = text_surface("Intro", font_size=36, color=(0, 0, 0))