Exemple #1
0
    def __init__(self, character, cellMap, **kwargs):
        super(SpylightGame, self).__init__(**kwargs)

        if character == 'merc':
            self.character = Mercenary(game=self, cellMap=cellMap, server=server)
            shadow = Shadow('art/spy.png')
            if server:
                clientNetworker = ClientNetworker(np.MERCENARY_TYPE)
        else:
            self.character = Spy(game=self, cellMap=cellMap, server=server)
            shadow = Shadow('art/mercenary.png')
            if server:
                clientNetworker = ClientNetworker(np.SPY_TYPE)

        if server:
            clientNetworker.connect(server, 9999)

        self.soundBeep = SoundLoader.load("music/beep.wav")
        self.soundShot = SoundLoader.load("music/shot.wav")
        self.soundReload = SoundLoader.load("music/reload.wav")
        self.soundModem = SoundLoader.load("music/modem.wav")
        self.soundPunch = SoundLoader.load("music/punch.wav")
        self.soundBoom = SoundLoader.load("music/boom.wav")

        self.add_widget(MapView(map=map, character=self.character, shadow=shadow))
        self.add_widget(self.character)
        # self.capInfo = CapInfo()
        # self.add_widget(capInfo)
        self.started = False
Exemple #2
0
class SpylightGame(Widget):
    character = ObjectProperty(None)

    def __init__(self, character, cellMap, **kwargs):
        super(SpylightGame, self).__init__(**kwargs)

        if character == 'merc':
            self.character = Mercenary(game=self, cellMap=cellMap, server=server)
            shadow = Shadow('art/spy.png')
            if server:
                clientNetworker = ClientNetworker(np.MERCENARY_TYPE)
        else:
            self.character = Spy(game=self, cellMap=cellMap, server=server)
            shadow = Shadow('art/mercenary.png')
            if server:
                clientNetworker = ClientNetworker(np.SPY_TYPE)

        if server:
            clientNetworker.connect(server, 9999)

        self.soundBeep = SoundLoader.load("music/beep.wav")
        self.soundShot = SoundLoader.load("music/shot.wav")
        self.soundReload = SoundLoader.load("music/reload.wav")
        self.soundModem = SoundLoader.load("music/modem.wav")
        self.soundPunch = SoundLoader.load("music/punch.wav")
        self.soundBoom = SoundLoader.load("music/boom.wav")

        self.add_widget(MapView(map=map, character=self.character, shadow=shadow))
        self.add_widget(self.character)
        # self.capInfo = CapInfo()
        # self.add_widget(capInfo)
        self.started = False

    def update(self, useless, **kwargs):
        self.character.update(kwargs)
        # self.capInfo.update(kwargs)

    def playBeep(self):
        self.soundBeep.play()

    def playShot(self):
        self.soundShot.play()

    def playReload(self):
        self.soundReaload.play()

    def playModem(self):
        self.soundModem.play()

    def stopModem(self):
        self.soundModem.stop()

    def playPunch(self):
        self.soundPunch.play()

    def playBoom(self):
        self.soundBoom.play()

    def end(self):
        game.playShot()
        print "The mercenary won!"
        sys.exit()

    def start(self):
        timer = Timer()
        game.add_widget(timer)
        Clock.schedule_interval(timer.updateTime, 1)
        self.started = True