Beispiel #1
0
    def build(self):

        data_dir = getattr(
            self, 'user_data_dir')  #get a writable path to save our score
        self.store = JsonStore(join(
            data_dir,
            'score.json'))  # create a JsonScore file in the available location

        if (not self.store.exists('score')
            ):  # if there is no file, we need to save the best score as 1
            self.store.put('score', best=1)

        if platform(
        ) == 'android':  # if we are on Android, we can initialize the ADs service
            revmob.start_session('54c247f420e1fb71091ad44a')

        self.screens = {}  # list of app screens
        self.screens['menu'] = MenuScreen(
            self
        )  #self the MainApp instance, so others objects can change the screen
        self.screens['game'] = GameScreen(self)
        self.root = FloatLayout()

        self.open_screen('menu')

        self.sound = SoundLoader.load(
            'res/background.mp3')  # open the background music
        # kivy support music loop, but it was not working on Android. I coded in a different way to fix it
        # but if fixed, we can just set the loop to True and call the play(), so it'll auto repeat
        # self.sound.loop = True It # was not working on android, so I wrote the following code:
        self.sound.play()  # play the sound
        Clock.schedule_interval(self.check_sound,
                                1)  #every second force the music to be playing

        return self.root
Beispiel #2
0
    def build(self):

        data_dir = getattr(self, 'user_data_dir') #get a writable path to save our score
        self.store = JsonStore(join(data_dir, 'score.json')) # create a JsonScore file in the available location

        if(not self.store.exists('score')): # if there is no file, we need to save the best score as 1
            self.store.put('score', best=1)

        if platform() == 'android': # if we are on Android, we can initialize the ADs service
            revmob.start_session('54c247f420e1fb71091ad44a')

        self.screens = {} # list of app screens
        self.screens['menu'] = MenuScreen(self) #self the MainApp instance, so others objects can change the screen
        self.screens['game'] = GameScreen(self)
        self.root = FloatLayout()

        self.open_screen('menu')

        self.sound = SoundLoader.load('res/background.mp3') # open the background music
        # kivy support music loop, but it was not working on Android. I coded in a different way to fix it
        # but if fixed, we can just set the loop to True and call the play(), so it'll auto repeat
        # self.sound.loop = True It # was not working on android, so I wrote the following code:
        self.sound.play() # play the sound
        Clock.schedule_interval(self.check_sound, 1) #every second force the music to be playing

        return self.root
Beispiel #3
0
 def run(self):
     self.best_score = self.app.store.get('score')[
         'best']  # get the best score saved
     self.ids.label_best.text = 'Best score: ' + str(
         self.best_score)  #show it
     if platform(
     ) == 'android':  # if we are using android, we can show an ADs
         if (random.randint(
                 0, 5) == 1):  # get a random and show a ads in the menu
             revmob.show_popup()
Beispiel #4
0
 def new_game(self):
     if use_ads:
         revmob.show_popup()
     self.content.clear_widgets()
     self.content.add_widget(Image(source='assets/graphics/ui/loading.png', size=Window.size, allow_stretch=True))
     Clock.schedule_once(self.post_splash)
Beispiel #5
0
    use_ads = True
except ImportError:
    use_ads = False

Builder.load_file('gameScreen.kv')
Builder.load_file('mainMenu.kv')

if use_ads:
    if platform() == 'android':
        REVMOB_APP_ID = 'android_id'
    elif platform() == 'ios':
        REVMOB_APP_ID = 'ios_id'
    else:
        REVMOB_APP_ID = 'unknown platform for RevMob'

    revmob.start_session(REVMOB_APP_ID)


class HexTap(App):
    def __init__(self, **kwargs):
        super(HexTap, self).__init__(**kwargs)
        self.difficulty = 1
        self.first_run = True
        self.current_state = 'mainMenu'
        self.content = BoxLayout()
        self.main_menu = MainMenu()
        self.help_menu = HelpMenu()
        self.game_map = None
        self.content.add_widget(self.main_menu)
        self.music = SoundLoader.load('assets/audio/music.ogg')
        self.soundsOption = True
Beispiel #6
0
 def run(self):
     self.best_score = self.app.store.get('score')['best'] # get the best score saved
     self.ids.label_best.text = 'Best score: ' + str(self.best_score) #show it
     if platform() == 'android': # if we are using android, we can show an ADs
         if(random.randint(0, 5) == 1): # get a random and show a ads in the menu
             revmob.show_popup()
Beispiel #7
0
 def on_pause(self):
     self.sound.stop() # the stop the sound
     Clock.unschedule(self.check_sound)
     if platform() == 'android': #if on android, we load an ADs and show it
         revmob.show_popup()
     return True
Beispiel #8
0
 def print_environment_information(instance):
     revmob.print_environment_information()
Beispiel #9
0
 def disable_testing_mode(instance):
     revmob.set_testing_mode(revmob.TESTING_MODE_DISABLED)
Beispiel #10
0
 def set_testing_mode_without_ads(instance):
     revmob.set_testing_mode(revmob.TESTING_MODE_WITHOUT_ADS)
Beispiel #11
0
 def open_link(instance):
     revmob.open_link()
Beispiel #12
0
 def show_popup(instance):
     revmob.show_popup()
Beispiel #13
0
 def show_fullscreen(instance):
     revmob.show_fullscreen()
Beispiel #14
0
 def start_session(instance):
     revmob.start_session(REVMOB_APP_ID)
Beispiel #15
0
 def on_pause(self):
     self.sound.stop()  # the stop the sound
     Clock.unschedule(self.check_sound)
     if platform() == 'android':  #if on android, we load an ADs and show it
         revmob.show_popup()
     return True