コード例 #1
0
ファイル: processrunner.py プロジェクト: feitianyiren/pymei
    def draw(self, screen):
        super(ProcessRunner, self).draw(screen)

        if not self._pid:
            self._start()

        text1 = '%s is currently running!' % self._cmd[0]
        text2 = 'Command: %s "%s"' % (self._cmd[0], '" "'.join(self._cmd[1:]))

        (width1, height1) = self._font.size(text1)
        (width2, height2) = self._font.size(text2)

        height = height1 + height2

        (screen_width, screen_height) = screen.get_size()
        x1 = (screen_width - width1) / 2
        x2 = (screen_width - width2) / 2
        y = (screen_height - height) / 2

        util.drawText(screen, self._font, (x1, y), text1,
                      self._theme['font_color'])
        util.drawText(screen, self._font, (x2, y + height1), text2,
                      self._theme['font_color'])

        self._clock.tick(1)

        if self._process_dead:
            self._quit()
コード例 #2
0
ファイル: splash.py プロジェクト: G33kX/trelby
    def OnPaint(self, event):
        dc = wx.PaintDC(self)

        dc.SetFont(self.font)
        dc.SetTextForeground(self.textColor)

        if self.pic.Ok():
            dc.DrawBitmap(self.pic, 0, 0, False)

        util.drawText(dc, "Version %s" % (misc.version), 200, 170, util.ALIGN_RIGHT)

        util.drawText(dc, "http://www.trelby.org/", 200, 185, util.ALIGN_RIGHT)

        if self.quote:
            dc.SetFont(self.sourceFont)
            dc.DrawText(self.quote.source, 50, 280)

            dc.SetFont(self.quoteFont)

            for i, line in enumerate(self.quote.lines):
                x = 10
                y = 260 - (len(self.quote.lines) - i - 1) * 17

                if i == 0:
                    dc.DrawText(u"“", x - 5, y)

                if i == (len(self.quote.lines) - 1):
                    line = line + u"”"

                dc.DrawText(line, x, y)
コード例 #3
0
ファイル: splash.py プロジェクト: reubenbrown13/scrupulous
    def OnPaint(self, event):
        dc = wx.PaintDC(self)

        dc.SetFont(self.font)
        dc.SetTextForeground(self.textColor)

        if self.pic.Ok():
            dc.DrawBitmap(self.pic, 0, 0, False)

        util.drawText(dc, "%s" % (misc.version), 200, 170, util.ALIGN_RIGHT)

        util.drawText(dc, "Chapter One", 200, 185, util.ALIGN_RIGHT)

        if self.quote:
            dc.SetFont(self.sourceFont)
            dc.DrawText(self.quote.source, 50, 280)

            dc.SetFont(self.quoteFont)

            for i, line in enumerate(self.quote.lines):
                x = 10
                y = 260 - (len(self.quote.lines) - i - 1) * 17

                if i == 0:
                    dc.DrawText(u"“", x - 5, y)

                if i == (len(self.quote.lines) - 1):
                    line = line + u"”"

                dc.DrawText(line, x, y)
コード例 #4
0
def notify(world, font, message, from_scene, to_scene):
    entity = world.create_entity()
    world.add_component(entity, components.Position(640, 500))
    world.add_component(entity, components.Image("speech.png"))
    util.drawText(world.component_for_entity(entity, components.Image).image, message, (255, 255, 255), pygame.Rect(30, 20, 246, 134), font)
    world.add_component(entity, components.Size(307, 173))
    world.add_component(entity, components.Delay(2, fade_up, world, entity, from_scene, to_scene))
    return entity
コード例 #5
0
def FireballMessage(world):
    #since this isnt a class, we have to manually get font.
    
    font_path_for_fireball = os.path.join(components.get_base_path(), "kenpixel.ttf")
    small_font_fire = pygame.font.Font(font_path_for_fireball, 16)
    bubble = create_entity(world, "speech.png", pygame.Rect(200, 100, 307, 173))
    world.add_component(bubble, components.Hang())
    image = world.component_for_entity(bubble, components.Image).image
    #I used random strs
    firetexts = ["AHHHHH HOW ARE YOU SHOOTING FIREBALLS AHHHHH!!!!!!!!!!","OH MY GOD HE IS A DEMON!!! RUN!!!","CALL THE FIRE DEPARTMENT NAN JUST SPIT UP A FIREBALL!!!!"]
    util.drawText(image,str(random.choice(firetexts)),(255, 255, 255), pygame.Rect(30, 20, 246, 134),small_font_fire)
コード例 #6
0
ファイル: charmapdlg.py プロジェクト: millingjon/scrupulous
    def drawCharBox(self, dc, text, char, x, y, xinc):
        dc.SetFont(self.smallFont)
        dc.DrawText(text, x, y)

        boxX = x + xinc

        dc.DrawRectangle(boxX, y, self.boxSize, self.boxSize)

        dc.SetFont(self.bigFont)
        util.drawText(dc, char, boxX + self.boxSize // 2 + 1,
            y + self.boxSize // 2 + 1, util.ALIGN_CENTER, util.VALIGN_CENTER)
コード例 #7
0
ファイル: charmapdlg.py プロジェクト: HuBandiT/trelby
    def drawCharBox(self, dc, text, char, x, y, xinc):
        dc.SetFont(self.smallFont)
        dc.DrawText(text, x, y)

        boxX = x + xinc

        dc.DrawRectangle(boxX, y, self.boxSize, self.boxSize)

        dc.SetFont(self.bigFont)
        util.drawText(dc, char, boxX + self.boxSize // 2 + 1,
            y + self.boxSize // 2 + 1, util.ALIGN_CENTER, util.VALIGN_CENTER)
コード例 #8
0
ファイル: charmapdlg.py プロジェクト: Mac-H/trelby
    def OnPaint(self, event):
        dc = wx.BufferedPaintDC(self, self.screenBuf)

        size = self.GetClientSize()
        dc.SetBrush(wx.WHITE_BRUSH)
        dc.SetPen(wx.WHITE_PEN)
        dc.DrawRectangle(0, 0, size.width, size.height)

        dc.SetPen(wx.BLACK_PEN)
        dc.SetTextForeground(wx.BLACK)

        for y in range(self.rows + 1):
            util.drawLine(dc, self.offset, self.offset + y * self.cellSize,
                          self.cols * self.cellSize + 1, 0)

        for x in range(self.cols + 1):
            util.drawLine(dc, self.offset + x * self.cellSize,
                self.offset, 0, self.rows * self.cellSize)

        dc.SetFont(self.normalFont)

        for y in range(self.rows):
            for x in range(self.cols):
                i = y * self.cols + x
                if i < len(self.chars):
                    util.drawText(dc, self.chars[i],
                        x * self.cellSize + self.offset + self.cellSize // 2 + 1,
                        y * self.cellSize + self.offset + self.cellSize // 2 + 1,
                        util.ALIGN_CENTER, util.VALIGN_CENTER)

        y = self.offset + self.rows * self.cellSize
        pad = 5

        if self.selected:
            self.drawCharBox(dc, "Selected:", self.selected, self.offset,
                             y + pad, 75)

            c = util.upper(self.selected)
            if c == self.selected:
                c = util.lower(self.selected)
                if c == self.selected:
                    c = None

            if c:
                self.drawCharBox(dc, "Opposite case:", c, self.offset + 150,
                                 y + pad, 110)

            dc.SetFont(self.smallFont)
            dc.DrawText("Character code: %d" % ord(self.selected),
                        360, y + pad)
        else:
            dc.SetFont(self.smallFont)
            dc.DrawText("Click on a character to select it.", self.offset,
                        y + pad)
コード例 #9
0
 def puzzle_complete():
     if self.world.component_for_entity(mug, components.Flammable).lit:
         p = self.world.component_for_entity(player, components.Player)
         if p.holding is mug:
             p.holding = None
         self.world.delete_entity(mug)
         #self.switch_to_scene(text.TextScene("NaN was unsure how much longer he could go on like this. He still wanted to help people, but was filled with thoughts of inadequacy and self doubt.", SceneSeven()))
         notify(self.world, self.small_font, "Way to take your time.", self, text.TextScene("Eventually he'd had enough. He decided he would get revenge on his town for treating him this way.", SceneSeven()))
     else:
         complaint = create_entity(self.world, "speech.png", pygame.Rect(640, 500, 307, 173))
         self.world.add_component(complaint, components.ChangeAlpha(0, 4, interpolation.Smooth()))
         util.drawText(self.world.component_for_entity(complaint, components.Image).image, "It's cold! Heat it up for me.", (255, 255, 255), pygame.Rect(30, 20, 246, 134), self.small_font)
コード例 #10
0
    def init(self):
        scenebase.SceneBase.init(self)

        bg = create_entity(self.world, "HouseScene3BG.png", pygame.Rect(640, 360, 1280, 720))
        self.world.add_component(bg, components.Background())

        player = get_player(self.world)

        floor = self.world.create_entity()
        self.world.add_component(floor, components.Position(640, 560))
        self.world.add_component(floor, components.Size(1280, 100))
        #self.world.add_component(floor, components.Image("box1.png"))

        def spider_tally():
            self.count += 1
            if self.count == 3:
                puzzle_complete()

        for i in [(200, 320), (280, 240), (420, 230), (440, 400), (590, 300), (680, 170), (760, 390), (830, 230)]:
            spider = create_entity(self.world, "Cobweb.png", pygame.Rect(i[0], i[1], 80, 80))
            self.world.add_component(spider, components.Hang())
            self.world.add_component(spider, components.Flammable())
            self.world.add_component(spider, components.Audio("light"))
            self.world.add_component(spider, components.Touch(floor, touch=spider_tally))

        box = create_entity(self.world, "box1.png", pygame.Rect(520, 560, 80, 80))
        self.world.add_component(box, components.Velocity())
        self.world.add_component(box, components.Flammable(True))
        self.world.add_component(box, components.Audio("light"))

        guy = create_entity(self.world, "NPC3.png", pygame.Rect(210, 560, 80, 80))
        self.world.add_component(guy, components.Velocity())
        self.world.add_component(guy, components.Flammable())
        self.world.add_component(guy, components.Audio("grunt"))

        def puzzle_complete():
            notify(self.world, self.small_font, "Now get out of my barn!", self, text.TextScene("Lack of real adventuring work not only wore on NaN, but it dulled him. His body atrophied as his mind numbed, and he realized he could no longer perform the same feats he'd grown accustomed to.", SceneFive()))

        cat = create_entity(self.world, "Cat.png", pygame.Rect(1190, 560, 80, 80))
        self.world.add_component(cat, components.Velocity(0,0))
        self.world.add_component(cat, components.Flammable())
        self.world.add_component(cat, components.Audio("light"))

        bubble = create_entity(self.world, "speech.png", pygame.Rect(1000, 100, 307, 173))
        self.world.add_component(bubble, components.Hang())
        image = self.world.component_for_entity(bubble, components.Image).image
        util.drawText(image, "My barn is dusty and full of cobwebs. NaN! Come here and do this for me.", (255, 255, 255), pygame.Rect(30, 20, 246, 134), self.small_font)

        self.world.add_processor(processors.RenderProcessor())
        self.world.add_processor(processors.InputProcessor(), priority=10)
        self.world.add_processor(processors.PhysicsProcessor(600), priority=5)
        self.world.add_processor(processors.AnimationProcessor(), priority=5)
        self.world.add_processor(processors.PlayerProcessor(player, 75), priority=25)
コード例 #11
0
ファイル: scenenav.py プロジェクト: reubenbrown13/scrupulous
 def OnDrawItem(self, dc, rect, index):
     item = self.items[index]
     x = rect.x + NAV_MARK_WIDTH
     i = 0
     for typ, txt in item.lns:
         y = rect.y + self.itemheight * i + 1
         if typ == NAVITEM_SCENE:
             dc.SetFont(self.scenefont)
             dc.SetTextForeground(self.scenecolor)
             util.drawText(dc, txt, x, y)
         elif typ == NAVITEM_BLURB:
             if item.annotated:
                 dc.SetFont(self.annotatedfont)
             else:
                 dc.SetFont(self.blurbfont)
             dc.SetTextForeground(self.blurbcolor)
             util.drawText(dc, txt, x, y)
         elif typ == NAVITEM_NOTE:
             dc.SetFont(self.blurbfont)
             dc.SetTextForeground(self.notecolor)
             util.drawText(dc, txt, x + 5, y)
         else:
             #NAVITEM_TRANSITION
             dc.SetFont(self.blurbfont)
             dc.SetTextForeground(self.transitioncolor)
             util.drawText(dc, txt, rect.x + rect.width - 2, y,
                             align=util.ALIGN_RIGHT)
         i += 1
コード例 #12
0
    def init(self):
        scenebase.SceneBase.init(self)

        bg = create_entity(self.world, "OutsideSceneBG.png", pygame.Rect(640, 360, 1280, 720))
        self.world.add_component(bg, components.Background())

        player = get_player(self.world)

        flower = create_entity(self.world, "Flower.png", pygame.Rect(240, 560, 80, 80))
        self.world.add_component(flower, components.Velocity())
        self.world.add_component(flower, components.Flammable())
        self.world.add_component(flower, components.Audio("light"))

        vase = create_entity(self.world, "Vase.png", pygame.Rect(510, 560, 80, 80))
        self.world.add_component(vase, components.Velocity())
        self.world.add_component(vase, components.Flammable())
        self.world.add_component(vase, components.Audio("light"))

        guy = create_entity(self.world, "NPC2.png", pygame.Rect(340, 560, 80, 80))
        self.world.add_component(guy, components.Velocity())
        self.world.add_component(guy, components.Flammable())
        self.world.add_component(guy, components.Audio("grunt"))

        guy2 = create_entity(self.world, "NPC1.png", pygame.Rect(950, 560, 80, 80))
        self.world.add_component(guy2, components.Velocity())
        self.world.add_component(guy2, components.Flammable())
        self.world.add_component(guy2, components.Audio("grunt"))
        self.world.component_for_entity(guy2, components.Image).image = pygame.transform.flip(self.world.component_for_entity(guy2, components.Image).image, False, False)

        def puzzle_complete():
            notify(self.world, self.small_font, "You better not have dropped her or anything.", self, text.TextScene("With adventuring work in low demand and the cost of living constantly increasing, NaN was forced to stoop to more and more menial work.", SceneThree()))
            
        cat = create_entity(self.world, "Cat.png", pygame.Rect(1100, 170, 80, 80))
        self.world.add_component(cat, components.Hang())
        self.world.add_component(cat, components.Flammable())
        self.world.add_component(cat, components.Touch(guy, touch=puzzle_complete))
        self.world.add_component(cat, components.Audio("light"))

        bubble = create_entity(self.world, "speech.png", pygame.Rect(200, 100, 307, 173))
        self.world.add_component(bubble, components.Hang())
        image = self.world.component_for_entity(bubble, components.Image).image
        util.drawText(image, "Oh no! My wonderful cat has found herself stuck in a tree! Won't someone please help me?", (255, 255, 255), pygame.Rect(30, 20, 246, 134), self.small_font)

        self.world.add_processor(processors.RenderProcessor())
        self.world.add_processor(processors.InputProcessor(), priority=10)
        self.world.add_processor(processors.PhysicsProcessor(600), priority=5)
        self.world.add_processor(processors.AnimationProcessor(), priority=5)
        self.world.add_processor(processors.PlayerProcessor(player, 95), priority=25)
コード例 #13
0
    def init(self):
        scenebase.SceneBase.init(self)

        bg = create_entity(self.world, "OutsideSceneBG.png", pygame.Rect(640, 360, 1280, 720))
        self.world.add_component(bg, components.Background())

        player = get_player(self.world)

        flower = create_entity(self.world, "Flower.png", pygame.Rect(240, 560, 80, 80))
        self.world.add_component(flower, components.Velocity())
        self.world.add_component(flower, components.Flammable())
        self.world.add_component(flower, components.Audio("light"))

        vase = create_entity(self.world, "Vase.png", pygame.Rect(510, 560, 80, 80))
        self.world.add_component(vase, components.Velocity())
        self.world.add_component(vase, components.Flammable())
        self.world.add_component(vase, components.Audio("light"))

        guy = create_entity(self.world, "NPC2.png", pygame.Rect(340, 560, 80, 80))
        self.world.add_component(guy, components.Velocity())
        self.world.add_component(guy, components.Flammable())
        self.world.add_component(guy, components.Audio("grunt"))

        guy2 = create_entity(self.world, "NPC1.png", pygame.Rect(950, 560, 80, 80))
        self.world.add_component(guy2, components.Velocity())
        self.world.add_component(guy2, components.Flammable())
        self.world.add_component(guy2, components.Audio("grunt"))
        self.world.component_for_entity(guy2, components.Image).image = pygame.transform.flip(self.world.component_for_entity(guy2, components.Image).image, False, False)

        def puzzle_complete():
            notify(self.world, self.small_font, "MY CAT!!! GET THE HECK OUT OF HERE!!!!", self, text.TextScene("NaN was so overjoyed with his power he decided to slay a dragon. Not just any dragon. The hardest dragon known to man.", SceneTen()))
            
        cat = create_entity(self.world, "Cat.png", pygame.Rect(1100, 170, 80, 80))
        self.world.add_component(cat, components.Hang())
        self.world.add_component(cat, components.Flammable())
        self.world.add_component(cat, components.Touch(guy, touch=puzzle_complete))
        self.world.add_component(cat, components.Audio("light"))

        bubble = create_entity(self.world, "speech.png", pygame.Rect(200, 100, 307, 173))
        self.world.add_component(bubble, components.Hang())
        image = self.world.component_for_entity(bubble, components.Image).image
        util.drawText(image, "Hey NaN, yeah you! Get my cat out of that tree! Note: giv her cat to continue, all other scenes are like this now!", (255, 255, 255), pygame.Rect(30, 20, 246, 134), self.small_font)

        self.world.add_processor(processors.RenderProcessor())
        self.world.add_processor(processors.InputProcessor(), priority=10)
        self.world.add_processor(processors.PhysicsProcessor(600), priority=5)
        self.world.add_processor(processors.AnimationProcessor(), priority=5)
        self.world.add_processor(processors.FireballPlayerProcessor(player, 95), priority=25)
コード例 #14
0
ファイル: misc.py プロジェクト: cowmix/trelby
    def OnPaint(self, event):
        cfgGui = self.getCfgGui()

        cy = (TAB_BAR_HEIGHT - 1) // 2
        xoff = 5

        dc = wx.PaintDC(self)
        w, h = self.GetClientSizeTuple()

        dc.SetBrush(cfgGui.tabBarBgBrush)
        dc.SetPen(cfgGui.tabBarBgPen)
        dc.DrawRectangle(0, 0, w, h)

        dc.SetPen(cfgGui.tabTextPen)
        dc.SetTextForeground(cfgGui.tabTextColor)

        pageText = "Page %d / %d" % (self.page, self.pageCnt)
        dc.SetFont(self.font)

        util.drawText(dc, pageText, MyStatus.WIDTH - xoff, cy,
            util.ALIGN_RIGHT, util.VALIGN_CENTER)

        s1 = "%s [Enter]" % self.enterNext
        s2 = "%s [Tab]" % self.tabNext

        x = MyStatus.X_ELEDIVIDER + xoff
        dc.DrawText(s1, x, 0)
        dc.DrawText(s2, x, cy)

        x = xoff
        s = "%s" % self.elemType
        dc.SetFont(self.elementFont)
        util.drawText(dc, s, x, cy, valign = util.VALIGN_CENTER)

        dc.SetPen(cfgGui.tabBorderPen)
        dc.DrawLine(0, h-1, w, h-1)

        for x in (MyStatus.X_ELEDIVIDER, 0):
            dc.DrawLine(x, 0, x, h-1)
コード例 #15
0
    def OnPaint(self, event):
        cfgGui = self.getCfgGui()

        cy = (TAB_BAR_HEIGHT - 1) // 2
        xoff = 5

        dc = wx.PaintDC(self)
        w, h = self.GetClientSizeTuple()

        dc.SetBrush(cfgGui.tabBarBgBrush)
        dc.SetPen(cfgGui.tabBarBgPen)
        dc.DrawRectangle(0, 0, w, h)

        dc.SetPen(cfgGui.tabTextPen)
        dc.SetTextForeground(cfgGui.tabTextColor)

        pageText = "Page %d / %d" % (self.page, self.pageCnt)
        dc.SetFont(self.font)

        util.drawText(dc, pageText, MyStatus.WIDTH - xoff, cy,
                      util.ALIGN_RIGHT, util.VALIGN_CENTER)

        s1 = "%s [Enter]" % self.enterNext
        s2 = "%s [Tab]" % self.tabNext

        x = MyStatus.X_ELEDIVIDER + xoff
        dc.DrawText(s1, x, 0)
        dc.DrawText(s2, x, cy)

        x = xoff
        s = "%s" % self.elemType
        dc.SetFont(self.elementFont)
        util.drawText(dc, s, x, cy, valign=util.VALIGN_CENTER)

        dc.SetPen(cfgGui.tabBorderPen)
        dc.DrawLine(0, h - 1, w, h - 1)

        for x in (MyStatus.X_ELEDIVIDER, 0):
            dc.DrawLine(x, 0, x, h - 1)
コード例 #16
0
ファイル: game.py プロジェクト: thepaperpilot/NaN
 def puzzle_complete():
     if self.world.component_for_entity(mug, components.Flammable).lit:
         p = self.world.component_for_entity(player, components.Player)
         if p.holding is mug:
             p.holding = None
         self.world.delete_entity(mug)
         #self.switch_to_scene(text.TextScene("NaN was unsure how much longer he could go on like this. He still wanted to help people, but was filled with thoughts of inadequacy and self doubt.", SceneSeven()))
         notify(
             self.world, self.small_font, "Way to take your time.",
             self,
             text.TextScene(
                 "Eventually he'd had enough. There was no way he could go back to adventuring, but he similarly could not stop here. He began a new journey, leaving his town without a single goodbye. Thanks for playing.",
                 title.TitleScene()))
     else:
         complaint = create_entity(self.world, "speech.png",
                                   pygame.Rect(640, 500, 307, 173))
         self.world.add_component(
             complaint,
             components.ChangeAlpha(0, 4, interpolation.Smooth()))
         util.drawText(
             self.world.component_for_entity(complaint,
                                             components.Image).image,
             "It's cold! Heat it up for me.", (255, 255, 255),
             pygame.Rect(30, 20, 246, 134), self.small_font)
コード例 #17
0
ファイル: game.py プロジェクト: thepaperpilot/NaN
    def init(self):
        scenebase.SceneBase.init(self)

        bg = create_entity(self.world, "HouseScene1BG.png",
                           pygame.Rect(640, 360, 1280, 720))
        self.world.add_component(bg, components.Background())

        player = get_player(self.world)

        for i in [("WoodPlatform3.png", 520, 390, 720, 40),
                  ("WoodPlatformHalf.png", 1000, 500, 120, 40),
                  ("WoodPlatformThird.png", 920, 440, 80, 40),
                  ("WoodPlatformThird.png", 1080, 560, 80, 40)]:
            platform = create_entity(self.world, i[0],
                                     pygame.Rect(i[1], i[2], i[3], i[4]))
            self.world.add_component(platform, components.Platform())
            self.world.add_component(platform, components.Background())

        for i in [(520, 330), (760, 330), (280, 560), (520, 560)]:
            bed = create_entity(self.world, "Bed.png",
                                pygame.Rect(i[0], i[1], 160, 80))
            self.world.add_component(bed, components.Velocity())
            self.world.add_component(bed, components.Flammable())
            self.world.add_component(bed, components.Audio("heavy"))

        guy = create_entity(self.world, "NPC2.png",
                            pygame.Rect(1000, 460, 80, 80))
        self.world.add_component(guy, components.Velocity())
        self.world.add_component(guy, components.Flammable())
        self.world.add_component(guy, components.Audio("grunt"))

        table = create_entity(self.world, "TableBig.png",
                              pygame.Rect(280, 330, 160, 80))
        self.world.add_component(table, components.Velocity())
        self.world.add_component(table, components.Flammable())
        self.world.add_component(table, components.Audio("heavy"))

        def puzzle_complete():
            if self.world.component_for_entity(mug, components.Flammable).lit:
                p = self.world.component_for_entity(player, components.Player)
                if p.holding is mug:
                    p.holding = None
                self.world.delete_entity(mug)
                #self.switch_to_scene(text.TextScene("NaN was unsure how much longer he could go on like this. He still wanted to help people, but was filled with thoughts of inadequacy and self doubt.", SceneSeven()))
                notify(
                    self.world, self.small_font, "Way to take your time.",
                    self,
                    text.TextScene(
                        "Eventually he'd had enough. There was no way he could go back to adventuring, but he similarly could not stop here. He began a new journey, leaving his town without a single goodbye. Thanks for playing.",
                        title.TitleScene()))
            else:
                complaint = create_entity(self.world, "speech.png",
                                          pygame.Rect(640, 500, 307, 173))
                self.world.add_component(
                    complaint,
                    components.ChangeAlpha(0, 4, interpolation.Smooth()))
                util.drawText(
                    self.world.component_for_entity(complaint,
                                                    components.Image).image,
                    "It's cold! Heat it up for me.", (255, 255, 255),
                    pygame.Rect(30, 20, 246, 134), self.small_font)

        mug = create_entity(self.world, "Mug.png",
                            pygame.Rect(250, 160, 80, 80))
        self.world.add_component(mug, components.Hang())
        self.world.add_component(mug, components.Flammable())
        self.world.add_component(
            mug, components.Touch(guy, True, touch=puzzle_complete))
        self.world.add_component(mug, components.Audio("light"))

        lamp = create_entity(self.world, "Chandelier.png",
                             pygame.Rect(520, 160, 80, 80))
        self.world.add_component(lamp, components.Flammable(True))
        self.world.add_component(lamp, components.Hang())

        lamp2 = create_entity(self.world, "Chandelier.png",
                              pygame.Rect(760, 160, 80, 80))
        self.world.add_component(lamp2, components.Flammable(True))
        self.world.add_component(lamp2, components.Hang())

        fireplace = create_entity(self.world, "Fireplace.png",
                                  pygame.Rect(760, 520, 160, 160))
        self.world.add_component(fireplace, components.Flammable(True))
        self.world.add_component(fireplace, components.Velocity())
        self.world.add_component(fireplace, components.Background())

        # shelf
        create_entity(self.world, "shelf.png", pygame.Rect(250, 210, 80, 20))

        bubble = create_entity(self.world, "speech.png",
                               pygame.Rect(1000, 100, 307, 173))
        self.world.add_component(bubble, components.Hang())
        image = self.world.component_for_entity(bubble, components.Image).image
        util.drawText(
            image,
            "About time you got here, NaN. I need my coffee stat! It's probably been sitting there for hours!",
            (255, 255, 255), pygame.Rect(30, 20, 246, 134), self.small_font)

        self.world.add_processor(processors.RenderProcessor())
        self.world.add_processor(processors.InputProcessor(), priority=10)
        self.world.add_processor(processors.PhysicsProcessor(600), priority=5)
        self.world.add_processor(processors.AnimationProcessor(), priority=5)
        self.world.add_processor(processors.PlayerProcessor(player, 40),
                                 priority=25)
コード例 #18
0
ファイル: game.py プロジェクト: thepaperpilot/NaN
    def init(self):
        scenebase.SceneBase.init(self)

        bg = create_entity(self.world, "HouseSceneBlacksmithBG.png",
                           pygame.Rect(640, 360, 1280, 720))
        self.world.add_component(bg, components.Background())

        player = get_player(self.world)

        for i in [("WoodPlatform3.png", 760, 390, 720, 40),
                  ("WoodPlatformHalf.png", 280, 500, 120, 40),
                  ("WoodPlatformThird.png", 360, 440, 80, 40),
                  ("WoodPlatformThird.png", 200, 560, 80, 40)]:
            platform = create_entity(self.world, i[0],
                                     pygame.Rect(i[1], i[2], i[3], i[4]))
            self.world.add_component(platform, components.Platform())
            self.world.add_component(platform, components.Background())

        anvil = create_entity(self.world, "Anvil.png",
                              pygame.Rect(710, 560, 80, 80))
        self.world.add_component(anvil, components.Velocity())
        self.world.add_component(anvil, components.Audio("heavy"))

        bed = create_entity(self.world, "Bed.png",
                            pygame.Rect(500, 330, 160, 80))
        self.world.add_component(bed, components.Velocity())
        self.world.add_component(bed, components.Flammable())
        self.world.add_component(bed, components.Audio("heavy"))

        bookshelf = create_entity(self.world, "Bookshelf.png",
                                  pygame.Rect(640, 290, 80, 160))
        self.world.add_component(bookshelf, components.Velocity())
        self.world.add_component(bookshelf, components.Flammable())
        self.world.add_component(bookshelf, components.Audio("heavy"))

        guy = create_entity(self.world, "NPC3.png",
                            pygame.Rect(280, 560, 80, 80))
        self.world.add_component(guy, components.Velocity())
        self.world.add_component(guy, components.Flammable())
        self.world.add_component(guy, components.Audio("grunt"))

        left_chair = create_entity(self.world, "Chair.png",
                                   pygame.Rect(480, 560, 80, 80))
        self.world.add_component(left_chair, components.Velocity())
        self.world.add_component(left_chair, components.Flammable())
        self.world.add_component(left_chair, components.Audio("light"))

        top_chair = create_entity(self.world, "Chair.png",
                                  pygame.Rect(770, 330, 80, 80))
        self.world.add_component(top_chair, components.Velocity())
        self.world.add_component(top_chair, components.Flammable())
        self.world.add_component(top_chair, components.Audio("light"))

        table = create_entity(self.world, "Table.png",
                              pygame.Rect(570, 560, 80, 80))
        self.world.add_component(table, components.Velocity())
        self.world.add_component(table, components.Flammable())
        self.world.add_component(table, components.Audio("heavy"))

        def puzzle_complete():
            notify(
                self.world, self.small_font,
                "You got a crack in it. Thanks for nothing.", self,
                text.TextScene(
                    "NaN was depressed. For the majority of his life he was the strongest, fastest, all around best adventurer in the whole realm. But it was his own effectiveness led to his now pitiful existence.",
                    SceneSix()))

        def open_container(container, item_string):
            if container is not None:
                p = self.world.component_for_entity(container,
                                                    components.Position)
                self.world.delete_entity(container)
                item = create_entity(self.world, item_string,
                                     pygame.Rect(p.x, p.y, 80, 80))
                self.world.add_component(item, components.Audio("light"))
                self.world.add_component(item, components.Flammable())
                if container is chest:
                    self.world.add_component(
                        item,
                        components.Touch(guy,
                                         rect=pygame.Rect(0, 0, 0, 0),
                                         touch=puzzle_complete))
                if self.world.component_for_entity(
                        player, components.Player).holding == container:
                    self.world.component_for_entity(
                        player, components.Player).holding = item
                    i = self.world.component_for_entity(item, components.Image)
                    s = self.world.component_for_entity(item, components.Size)
                    i.image = pygame.transform.rotate(i.image, 90)
                    tmp = s.width
                    s.width = s.height
                    s.height = tmp
                else:
                    v = self.world.component_for_entity(
                        container, components.Velocity)
                    self.world.add_component(item,
                                             components.Velocity(v.x, v.y))
                self.world.component_for_entity(item,
                                                components.Audio).sound.play()

        chest = create_entity(self.world, "chest.png",
                              pygame.Rect(1070, 330, 80, 80))
        self.world.add_component(chest, components.Velocity())
        self.world.add_component(chest, components.Flammable())
        self.world.add_component(
            chest,
            components.Touch(anvil, False, pygame.Rect(0, 0, 0, 0),
                             open_container, chest, "Vase.png"))
        self.world.add_component(chest, components.Audio("chest"))

        box = create_entity(self.world, "box1.png",
                            pygame.Rect(860, 330, 80, 80))
        self.world.add_component(box, components.Velocity())
        self.world.add_component(box, components.Flammable())
        self.world.add_component(
            box,
            components.Touch(anvil, False, pygame.Rect(0, 0, 0, 0),
                             open_container, box, "Chair.png"))
        self.world.add_component(box, components.Audio("heavy"))

        box2 = create_entity(self.world, "box2.png",
                             pygame.Rect(950, 330, 80, 80))
        self.world.add_component(box2, components.Velocity())
        self.world.add_component(box2, components.Flammable())
        self.world.add_component(
            box2,
            components.Touch(anvil, False, pygame.Rect(0, 0, 0, 0),
                             open_container, box2, "PileOfBooks.png"))
        self.world.add_component(box2, components.Audio("heavy"))

        lamp = create_entity(self.world, "Chandelier.png",
                             pygame.Rect(520, 170, 80, 80))
        self.world.add_component(lamp, components.Flammable(True))
        self.world.add_component(lamp, components.Hang())

        lamp2 = create_entity(self.world, "Chandelier.png",
                              pygame.Rect(1000, 170, 80, 80))
        self.world.add_component(lamp2, components.Flammable(True))
        self.world.add_component(lamp2, components.Hang())

        forge = create_entity(self.world, "Forge.png",
                              pygame.Rect(1040, 520, 80, 160))
        self.world.add_component(anvil, components.Velocity())
        self.world.add_component(forge, components.Flammable(True))
        self.world.add_component(anvil, components.Audio("heavy"))

        workbench = create_entity(self.world, "Workbench.png",
                                  pygame.Rect(870, 560, 160, 80))
        self.world.add_component(workbench, components.Velocity())
        self.world.add_component(workbench, components.Flammable())
        self.world.add_component(workbench, components.Audio("heavy"))

        bubble = create_entity(self.world, "speech.png",
                               pygame.Rect(200, 100, 307, 173))
        self.world.add_component(bubble, components.Hang())
        util.drawText(
            self.world.component_for_entity(bubble, components.Image).image,
            "Shoot, now where did that vase go? NaN, you touched it last. You need to find it for me!",
            (255, 255, 255), pygame.Rect(30, 20, 246, 134), self.small_font)

        self.world.add_processor(processors.RenderProcessor())
        self.world.add_processor(processors.InputProcessor(), priority=10)
        self.world.add_processor(processors.PhysicsProcessor(600), priority=5)
        self.world.add_processor(processors.AnimationProcessor(), priority=5)
        self.world.add_processor(processors.PlayerProcessor(player, 60),
                                 priority=25)
コード例 #19
0
ファイル: game.py プロジェクト: thepaperpilot/NaN
    def init(self):
        scenebase.SceneBase.init(self)

        bg = create_entity(self.world, "HouseScene2BG.png",
                           pygame.Rect(640, 360, 1280, 720))
        self.world.add_component(bg, components.Background())

        player = get_player(self.world)

        floor2 = create_entity(self.world, "WoodPlatform2.png",
                               pygame.Rect(400, 390, 480, 40))
        self.world.add_component(floor2, components.Platform())
        self.world.add_component(floor2, components.Background())

        stair = create_entity(self.world, "WoodPlatform1.png",
                              pygame.Rect(760, 500, 240, 40))
        self.world.add_component(stair, components.Platform())
        self.world.add_component(stair, components.Background())

        bed = create_entity(self.world, "Bed.png",
                            pygame.Rect(260, 330, 160, 80))
        self.world.add_component(bed, components.Velocity())
        self.world.add_component(bed, components.Flammable())
        self.world.add_component(bed, components.Audio("heavy"))

        bookshelf = create_entity(self.world, "Bookshelf.png",
                                  pygame.Rect(420, 290, 80, 160))
        self.world.add_component(bookshelf, components.Velocity())
        self.world.add_component(bookshelf, components.Flammable())
        self.world.add_component(bookshelf, components.Audio("heavy"))

        chest = create_entity(self.world, "chest.png",
                              pygame.Rect(540, 330, 80, 80))
        self.world.add_component(chest, components.Velocity())
        self.world.add_component(chest, components.Flammable())
        self.world.add_component(chest, components.Audio("chest"))

        guy = create_entity(self.world, "NPC1.png",
                            pygame.Rect(280, 560, 80, 80))
        self.world.add_component(guy, components.Velocity())
        self.world.add_component(guy, components.Flammable())
        self.world.add_component(guy, components.Audio("grunt"))

        left_chair = create_entity(self.world, "Chair.png",
                                   pygame.Rect(430, 560, 80, 80))
        self.world.add_component(left_chair, components.Velocity())
        self.world.add_component(left_chair, components.Flammable())
        self.world.add_component(left_chair, components.Audio("light"))

        right_chair = create_entity(self.world, "Chair.png",
                                    pygame.Rect(610, 560, 80, 80))
        self.world.add_component(right_chair, components.Velocity())
        self.world.add_component(right_chair, components.Flammable())
        self.world.add_component(right_chair, components.Audio("light"))
        self.world.component_for_entity(
            right_chair, components.Image).image = pygame.transform.flip(
                self.world.component_for_entity(right_chair,
                                                components.Image).image, False,
                False)

        table = create_entity(self.world, "Table.png",
                              pygame.Rect(520, 560, 80, 80))
        self.world.add_component(table, components.Velocity())
        self.world.add_component(table, components.Flammable())
        self.world.add_component(table, components.Audio("heavy"))

        def puzzle_complete():
            p = self.world.component_for_entity(player, components.Player)
            if p.holding is books:
                p.holding = None
            self.world.delete_entity(books)
            notify(
                self.world, self.small_font,
                "Wow, you got the books dirty. I can't use these anymore.",
                self,
                text.TextScene(
                    "These thankless jobs took their toll on NaN. He put on a friendly face, but inside he was growing weary...",
                    SceneFour()))

        books = create_entity(self.world, "PileOfBooks.png",
                              pygame.Rect(1000, 560, 80, 80))
        self.world.add_component(books, components.Velocity())
        self.world.add_component(books, components.Flammable())
        self.world.add_component(
            books,
            components.Touch(bookshelf,
                             rect=pygame.Rect(5, 0, -10, 0),
                             touch=puzzle_complete))
        self.world.add_component(books, components.Audio("light"))

        lamp = create_entity(self.world, "Chandelier.png",
                             pygame.Rect(760, 170, 80, 80))
        self.world.add_component(lamp, components.Flammable(True))
        self.world.add_component(lamp, components.Hang())
        self.world.add_component(lamp, components.Audio("glass.ogg"))

        bubble = create_entity(self.world, "speech.png",
                               pygame.Rect(1000, 100, 307, 173))
        self.world.add_component(bubble, components.Hang())
        image = self.world.component_for_entity(bubble, components.Image).image
        util.drawText(
            image,
            "Ah! NaN, just in time! I need your help putting my books away. They are very important!",
            (255, 255, 255), pygame.Rect(30, 20, 246, 134), self.small_font)

        self.world.add_processor(processors.RenderProcessor())
        self.world.add_processor(processors.InputProcessor(), priority=10)
        self.world.add_processor(processors.PhysicsProcessor(600), priority=5)
        self.world.add_processor(processors.AnimationProcessor(), priority=5)
        self.world.add_processor(processors.PlayerProcessor(player, 85),
                                 priority=25)
コード例 #20
0
    def init(self):
        scenebase.SceneBase.init(self)

        text = self.world.create_entity()
        image = pygame.Surface([1280, 720], pygame.SRCALPHA,
                               32).convert_alpha()
        util.drawText(image, self.text, (255, 255, 255),
                      pygame.Rect(100, 100, 1080, 520), self.font)
        self.world.add_component(text, components.Position(640, 240))
        self.world.add_component(text, components.Image(image=image, alpha=0))
        self.world.add_component(
            text, components.Size(image.get_width(), image.get_height()))
        self.world.add_component(text, components.ChangePosition((640, 340),
                                                                 .5))
        self.world.add_component(text, components.ChangeAlpha(1, 1))

        #self.world.add_component(text, components.Reactive())

        def fade_out(entity):
            self.world.add_component(
                entity,
                components.ChangeAlpha(.5, 1, interpolation.Circle(), fade_in,
                                       entity))

        def fade_in(entity):
            self.world.add_component(
                entity,
                components.ChangeAlpha(1, 1, interpolation.Circle(), fade_out,
                                       entity))

        continue_text = self.world.create_entity()
        image = self.font.render("press any button to continue", False,
                                 (32, 128, 255))
        self.world.add_component(continue_text, components.Position(640, 640))
        self.world.add_component(continue_text, components.Image(image=image))
        self.world.add_component(
            continue_text,
            components.Size(image.get_width(), image.get_height()))
        #self.world.add_component(continue_text, components.Reactive())
        fade_in(continue_text)

        def fade_scene():
            for ent in [text, continue_text]:
                if self.world.has_component(ent, components.ChangeAlpha):
                    self.world.remove_component(ent, components.ChangeAlpha)
                self.world.add_component(ent, components.ChangeAlpha(0, .5))
                self.world.add_component(
                    ent,
                    components.ChangePosition(
                        (640,
                         self.world.component_for_entity(
                             ent, components.Position).y + 50), .5))

            self.world.add_component(text, components.Delay(1, next_scene))
            pygame.mixer.Sound(
                os.path.join(components.get_base_path(), 'audio',
                             'click')).play()

        def next_scene():
            self.switch_to_scene(self.scene)

        self.world.add_processor(processors.RenderProcessor())
        self.world.add_processor(processors.AnimationProcessor(), priority=5)
        self.world.add_processor(processors.TextProcessor(fade_scene),
                                 priority=10)
        self.world.add_processor(processors.InputProcessor())
コード例 #21
0
    def OnPaint(self, event):
        dc = wx.BufferedPaintDC(self, self.screenBuf)

        size = self.GetClientSize()
        dc.SetBrush(wx.WHITE_BRUSH)
        dc.SetPen(wx.WHITE_PEN)
        dc.DrawRectangle(0, 0, size.width, size.height)

        dc.SetPen(wx.BLACK_PEN)
        dc.SetTextForeground(wx.BLACK)

        for y in range(self.rows + 1):
            util.drawLine(dc, self.offset, self.offset + y * self.cellSize,
                          self.cols * self.cellSize + 1, 0)

        for x in range(self.cols + 1):
            util.drawLine(dc, self.offset + x * self.cellSize, self.offset, 0,
                          self.rows * self.cellSize)

        dc.SetFont(self.normalFont)

        for y in range(self.rows):
            for x in range(self.cols):
                i = y * self.cols + x
                if i < len(self.chars):
                    util.drawText(
                        dc, self.chars[i], x * self.cellSize + self.offset +
                        self.cellSize // 2 + 1, y * self.cellSize +
                        self.offset + self.cellSize // 2 + 1,
                        util.ALIGN_CENTER, util.VALIGN_CENTER)

        y = self.offset + self.rows * self.cellSize
        pad = 5

        if self.selected:
            code = ord(self.selected)

            self.drawCharBox(dc, "Selected", self.selected, self.offset,
                             y + pad, 75)

            c = util.upper(self.selected)
            if c == self.selected:
                c = util.lower(self.selected)
                if c == self.selected:
                    c = None

            if c:
                self.drawCharBox(dc, "Opposite Case", c, self.offset + 150,
                                 y + pad, 110)

            dc.SetFont(self.smallFont)
            dc.DrawText("Character Code: %d" % code, 360, y + pad)

            if code == 32:
                dc.DrawText("Normal Space", 360, y + pad + 30)
            elif code == 160:
                dc.DrawText("Non-breaking Space", 360, y + pad + 30)

        else:
            dc.SetFont(self.smallFont)
            dc.DrawText("Select a character", self.offset, y + pad)
コード例 #22
0
    def init(self):
        scenebase.SceneBase.init(self)

        
        bg = create_entity(self.world, "HouseScene2BG.png", pygame.Rect(640, 360, 1280, 720))
        self.world.add_component(bg, components.Background())

        player = get_player(self.world)

        floor2 = create_entity(self.world, "WoodPlatform2.png", pygame.Rect(400, 390, 480, 40))
        self.world.add_component(floor2, components.Platform())
        self.world.add_component(floor2, components.Background())

        stair = create_entity(self.world, "WoodPlatform1.png", pygame.Rect(760, 500, 240, 40))
        self.world.add_component(stair, components.Platform())
        self.world.add_component(stair, components.Background())

        bed = create_entity(self.world, "Bed.png", pygame.Rect(260, 330, 160, 80))
        self.world.add_component(bed, components.Velocity())
        self.world.add_component(bed, components.Flammable())
        
        self.world.add_component(bed, components.Audio("heavy"))

        bookshelf = create_entity(self.world, "Bookshelf.png", pygame.Rect(420, 290, 80, 160))
        self.world.add_component(bookshelf, components.Velocity())
        self.world.add_component(bookshelf, components.Flammable())
        self.world.add_component(bookshelf, components.Audio("heavy"))

        chest = create_entity(self.world, "chest.png", pygame.Rect(540, 330, 80, 80))
        self.world.add_component(chest, components.Velocity())
        self.world.add_component(chest, components.Flammable())
        self.world.add_component(chest, components.Audio("chest"))

        guy = create_entity(self.world, "NPC1.png", pygame.Rect(280, 560, 80, 80))
        self.world.add_component(guy, components.Velocity())
        self.world.add_component(guy, components.Flammable())
        self.world.add_component(guy, components.Audio("grunt"))

        left_chair = create_entity(self.world, "Chair.png", pygame.Rect(430, 560, 80, 80))
        self.world.add_component(left_chair, components.Velocity())
        self.world.add_component(left_chair, components.Flammable())
        self.world.add_component(left_chair, components.Audio("light"))

        right_chair = create_entity(self.world, "Chair.png", pygame.Rect(610, 560, 80, 80))
        self.world.add_component(right_chair, components.Velocity())
        self.world.add_component(right_chair, components.Flammable())
        self.world.add_component(right_chair, components.Audio("light"))
        self.world.component_for_entity(right_chair, components.Image).image = pygame.transform.flip(self.world.component_for_entity(right_chair, components.Image).image, False, False)

        table = create_entity(self.world, "Table.png", pygame.Rect(520, 560, 80, 80))
        self.world.add_component(table, components.Velocity())
        self.world.add_component(table, components.Flammable())
        self.world.add_component(table, components.Audio("heavy"))
        puzzledone = False
        def puzzle_complete():
            puzzledone = True
            p = self.world.component_for_entity(player, components.Player)
            if p.holding is bed:
                p.holding = None
            self.world.delete_entity(books)
            notify(self.world, self.small_font, "OH MY GOD. MY HOUSE. GET THE HECK OUT OF HERE.", self, text.TextScene("These thankless jobs took their toll on NaN. He put on a friendly face, but inside he was growing weary...", SceneFour()))

        books = create_entity(self.world, "PileOfBooks.png", pygame.Rect(1000, 560, 80, 80))
        self.world.add_component(books, components.Velocity())
        self.world.add_component(books, components.Flammable())
        self.world.add_component(books, components.Touch(bookshelf, rect=pygame.Rect(5, 0, -10, 0)))
        self.world.add_component(books, components.Audio("light"))

        lamp = create_entity(self.world, "Chandelier.png", pygame.Rect(760, 170, 80, 80))
        self.world.add_component(lamp, components.Flammable(True))
        self.world.add_component(lamp, components.Hang())
        self.world.add_component(lamp, components.Audio("glass.ogg"))

        bubble = create_entity(self.world, "speech.png", pygame.Rect(1000, 100, 307, 173))
        self.world.add_component(bubble, components.Hang())
        image = self.world.component_for_entity(bubble, components.Image).image
        util.drawText(image, "Where the heck is NaN? My other books fell off! Note: you must scene select next scene", (255, 255, 255), pygame.Rect(30, 20, 246, 134), self.small_font)

        
        
        def move_up(entity):
            self.world.add_component(entity, components.ChangePosition((0, -40), 1, interpolation.Smooth(), True, move_down, entity))
        def move_down(entity):
            self.world.add_component(entity, components.ChangePosition((0, 40), 1, interpolation.Smooth(), True, move_up, entity))  
        tutorial = self.world.create_entity()
        image = self.font.render("press f to launch a fireball", False, (32, 255, 128))
        self.world.add_component(tutorial, components.Position(640, 680))
        self.world.add_component(tutorial, components.Image(image=image))
        self.world.add_component(tutorial, components.Size(image.get_width(), image.get_height()))
        move_up(tutorial)
        
        
        
        self.world.add_processor(processors.RenderProcessor())
        self.world.add_processor(processors.InputProcessor(), priority=10)
        self.world.add_processor(processors.PhysicsProcessor(600), priority=5)
        self.world.add_processor(processors.AnimationProcessor(), priority=5)
        self.world.add_processor(processors.FireballPlayerProcessor(player, 85), priority=25)