예제 #1
0
    def ui_layout(self):

        start_game_button_anchor = AnchorLayout(
            anchor_x='center',
            anchor_y='bottom',
            padding=[dp(25), dp(25), dp(25), dp(25)])

        self.start_game_button = MDFloatingActionButton(icon='play',
                                                        size=[dp(56),
                                                              dp(56)])
        self.start_game_button.md_bg_color = App.get_running_app(
        ).theme_cls.primary_color
        self.start_game_button.text_color = [1, 1, 1, 1]

        if platform not in ['ios', 'android']:
            self.start_game_button.bind(on_press=lambda x: self.start_game())

        start_game_button_anchor.add_widget(self.start_game_button)

        game_card = MDCard(padding=dp(24),
                           spacing=dp(24),
                           orientation='vertical',
                           size_hint_x=0.85,
                           size_hint_y=0.7,
                           pos_hint={
                               'top': 0.85,
                               'center_x': 0.5
                           })
        rules = """Snakes and ladders is a game to play with your friends. Navigate your piece from start to finish, avoid the snakes, and take shortcuts going up the ladders.


How to play:

Each player starts from base. Both players alternatively roll the dice and move the respective pawns.
If your pawn lands at the bottom of a ladder, you can move up to the top of the ladder.
If your pawn lands on the head of a snake, you must slide down to the bottom of the snake.
The first player to get to the last tile numbered '100'  is the winner."""
        game_label = MDLabel(text=rules,
                             font_style='Body1',
                             halign='center',
                             size_hint=(1, 0.5))
        game_label.theme_text_color = 'Custom'
        game_label.text_color = [1, 1, 1, 1]
        game_card.add_widget(game_label)
        game_card.md_bg_color = App.get_running_app().theme_cls.accent_color
        game_card.elevation = 15

        self.add_widget(game_card)
        self.add_widget(start_game_button_anchor)

        # Nav Bar
        self.nav_bar = MyNavigationLayout()
        self.nav_bar_anchor = AnchorLayout(anchor_x='center', anchor_y='top')
        self.nav_bar_anchor.add_widget(self.nav_bar)
        self.add_widget(self.nav_bar_anchor)
예제 #2
0
    def ui_layout(self):

        start_game_button_anchor = AnchorLayout(
            anchor_x='center',
            anchor_y='bottom',
            padding=[dp(25), dp(25), dp(25), dp(25)])

        self.start_game_button = MDFloatingActionButton(icon='play',
                                                        size=[dp(56),
                                                              dp(56)])
        self.start_game_button.md_bg_color = App.get_running_app(
        ).theme_cls.primary_color
        self.start_game_button.text_color = [1, 1, 1, 1]

        if platform not in ['ios', 'android']:
            self.start_game_button.bind(on_press=lambda x: self.start_game())

        start_game_button_anchor.add_widget(self.start_game_button)

        game_card = MDCard(padding=dp(24),
                           spacing=dp(24),
                           orientation='vertical',
                           size_hint_x=0.85,
                           size_hint_y=0.7,
                           pos_hint={
                               'top': 0.85,
                               'center_x': 0.5
                           })
        rules = """You probably already know how to play Tic-Tac-Toe. It's a really simple game, right? That's what most people think. But if you really wrap your brain around it, you'll discover that Tic-Tac-Toe isn't quite as simple as you think!
        
        1. The game is played on a grid that's 3 squares by 3 squares.

        2. You are X, your friend (or the computer in this case) is O. Players take turns putting their marks in empty squares.

        3. The first player to get 3 of her marks in a row (up, down, across, or diagonally) is the winner.

        4. When all 9 squares are full, the game is over. If no player has 3 marks in a row, the game ends in a tie."""
        game_label = MDLabel(text=rules,
                             font_style='Body1',
                             halign='center',
                             size_hint=(1, 0.5))
        game_label.theme_text_color = 'Custom'
        game_label.text_color = [1, 1, 1, 1]
        game_card.add_widget(game_label)
        game_card.md_bg_color = App.get_running_app().theme_cls.accent_color
        game_card.elevation = 15

        self.add_widget(game_card)
        self.add_widget(start_game_button_anchor)

        # Nav Bar
        self.nav_bar = MyNavigationLayout()
        self.nav_bar_anchor = AnchorLayout(anchor_x='center', anchor_y='top')
        self.nav_bar_anchor.add_widget(self.nav_bar)
        self.add_widget(self.nav_bar_anchor)
예제 #3
0
    def ui_layout(self):

        start_game_button_anchor = AnchorLayout(
            anchor_x='center',
            anchor_y='bottom',
            padding=[dp(25), dp(25), dp(25), dp(25)])

        self.start_game_button = MDFloatingActionButton(icon='play',
                                                        size=[dp(56),
                                                              dp(56)])
        self.start_game_button.md_bg_color = App.get_running_app(
        ).theme_cls.primary_color
        self.start_game_button.text_color = [1, 1, 1, 1]

        if platform not in ['ios', 'android']:
            self.start_game_button.bind(on_press=lambda x: self.start_game())

        start_game_button_anchor.add_widget(self.start_game_button)

        game_card = MDCard(padding=dp(24),
                           spacing=dp(24),
                           orientation='vertical',
                           size_hint_x=0.85,
                           size_hint_y=0.7,
                           pos_hint={
                               'top': 0.85,
                               'center_x': 0.5
                           })
        rules = """Catch em all is a game where you have to catch the ever escaping target.
With a limited amount you need to catch the target as fast as you can..

How to play:
A random target appears all over the screen
Click on it before it disappears and moves to another target
Collect the target 10 times before the timer runs out to finish the game.
Clicking on any obstacle or any area outside the ground gives a penalty of 4 seconds"""
        game_label = MDLabel(text=rules,
                             font_style='Body1',
                             halign='center',
                             size_hint=(1, 0.5))
        game_label.theme_text_color = 'Custom'
        game_label.text_color = [1, 1, 1, 1]
        game_card.add_widget(game_label)
        game_card.md_bg_color = App.get_running_app().theme_cls.accent_color
        game_card.elevation = 15

        self.add_widget(game_card)
        self.add_widget(start_game_button_anchor)

        # Nav Bar
        self.nav_bar = MyNavigationLayout()
        self.nav_bar_anchor = AnchorLayout(anchor_x='center', anchor_y='top')
        self.nav_bar_anchor.add_widget(self.nav_bar)
        self.add_widget(self.nav_bar_anchor)
예제 #4
0
    def ui_layout(self):

        start_game_button_anchor = AnchorLayout(
            anchor_x='center',
            anchor_y='bottom',
            padding=[dp(25), dp(25), dp(25), dp(25)])

        self.start_game_button = MDFloatingActionButton(icon='play',
                                                        size=[dp(56),
                                                              dp(56)])
        self.start_game_button.md_bg_color = App.get_running_app(
        ).theme_cls.primary_color
        self.start_game_button.text_color = [1, 1, 1, 1]

        if platform not in ['ios', 'android']:
            self.start_game_button.bind(on_press=lambda x: self.start_game())

        start_game_button_anchor.add_widget(self.start_game_button)

        game_card = MDCard(padding=dp(24),
                           spacing=dp(24),
                           orientation='vertical',
                           size_hint_x=0.85,
                           size_hint_y=0.7,
                           pos_hint={
                               'top': 0.85,
                               'center_x': 0.5
                           })
        rules = """Hit the blocks popping up before they disappear!
Hit the blocks a specific number of times to win the game! Keep in mind, you just have limited chances to hit the blocks. So buckle up for some exciting fun! """
        game_label = MDLabel(text=rules,
                             font_style='Body1',
                             halign='center',
                             size_hint=(1, 0.5))
        game_label.theme_text_color = 'Custom'
        game_label.text_color = [1, 1, 1, 1]
        game_card.add_widget(game_label)
        game_card.md_bg_color = App.get_running_app().theme_cls.accent_color
        game_card.elevation = 15

        self.add_widget(game_card)
        self.add_widget(start_game_button_anchor)

        # Nav Bar
        self.nav_bar = MyNavigationLayout()
        self.nav_bar_anchor = AnchorLayout(anchor_x='center', anchor_y='top')
        self.nav_bar_anchor.add_widget(self.nav_bar)
        self.add_widget(self.nav_bar_anchor)
예제 #5
0
    def __init__(self, stack_height=10):
        super(AudioIndicatorStack, self).__init__()
        self.orientation = 'vertical'
        self.padding = dp(2)
        self.spacing = dp(2)
        self.rect_array = []
        self.stack_height = stack_height
        self.color_tuple = [
            App.get_running_app().theme_cls.primary_color, [0, 0, 0, 0]
        ]

        # Builds a stack of rectangle box layouts
        for i in range(self.stack_height):
            rect = MDCard(size_hint=(1, 1))
            rect.md_bg_color = App.get_running_app().theme_cls.primary_color
            self.rect_array.append(rect)
            self.add_widget(rect)
예제 #6
0
    def ui_layout(self):

        start_game_button_anchor = AnchorLayout(anchor_x='center', anchor_y='bottom',
                                            padding=[dp(25), dp(25), dp(25), dp(25)])


        self.start_game_button = MDFloatingActionButton(icon='play', size=[dp(56), dp(56)])
        self.start_game_button.md_bg_color = App.get_running_app().theme_cls.primary_color
        self.start_game_button.text_color = [1, 1, 1, 1]

        if platform not in ['ios', 'android']:
            self.start_game_button.bind(on_press=lambda x: self.start_game())


        start_game_button_anchor.add_widget(self.start_game_button)


        game_card = MDCard(padding=dp(24), spacing=dp(24), orientation='vertical',
                             size_hint_x=0.85, size_hint_y=0.7,
                             pos_hint={'top': 0.85, 'center_x': 0.5})
        rules = """The objective of Battleship is to try and sink all of the other player's before they sink all of your ships. All of the other player's ships are somewhere on his/her board.  


Player's take turns guessing out the coordinates of the enemy ships. If it's a hit the cell turns RED. If its a miss the cell turns BLUE.
The first played to guess and hit all the ships completely wins!"""
        game_label = MDLabel(text=rules, font_style='Body1', halign='center',
                               size_hint=(1, 0.5))
        game_label.theme_text_color = 'Custom'
        game_label.text_color = [1, 1, 1, 1]
        game_card.add_widget(game_label)
        game_card.md_bg_color = App.get_running_app().theme_cls.accent_color
        game_card.elevation = 15

        self.add_widget(game_card)
        self.add_widget(start_game_button_anchor)

        # Nav Bar
        self.nav_bar = MyNavigationLayout()
        self.nav_bar_anchor = AnchorLayout(anchor_x='center', anchor_y='top')
        self.nav_bar_anchor.add_widget(self.nav_bar)
        self.add_widget(self.nav_bar_anchor)
예제 #7
0
    def build(self):

        # AC Card
        self.ac_card = AcCard((0.5, 0.5))
        self.add_widget(self.ac_card)

        # all the features for ac
        features_layout = MDGridLayout()
        features_layout.cols = 2

        # Temp incease, decrease
        new_box_layout = MDFloatLayout()
        dec_button = Buttonn('temp-', colors['cold_color'])
        new_box_layout.add_widget(dec_button)
        dec_button.on_press = partial(self.ac_features_send, dec_button)
        features_layout.add_widget(new_box_layout)

        new_box_layout = MDFloatLayout()
        inc_button = MDCard(
            orientation='vertical',
            padding='10dp',
            pos_hint={
                'center_x': 0.5,
                'center_y': 0.5
            },
            size_hint=(0.75, 0.75),
        )
        inc_button.md_bg_color = ['warm_color']
        inc_button.add_widget(MDLabel(text='Temp+'))
        inc_button.id = 'temp+'
        inc_button.on_press = partial(self.ac_features_send, inc_button)
        new_box_layout.add_widget(inc_button)
        features_layout.add_widget(new_box_layout)

        features_layout.add_widget(btn(text='TODO'))
        features_layout.add_widget(btn(text='TODO'))
        features_layout.add_widget(btn(text='TODO'))
        features_layout.add_widget(btn(text='TODO'))

        self.add_widget(features_layout)
예제 #8
0
    def ui_layout(self):
        record_button_anchor = AnchorLayout(
            anchor_x='center',
            anchor_y='bottom',
            padding=[dp(25), dp(25), dp(25), dp(25)])

        self.record_button = MDFloatingActionButton(icon='record',
                                                    size=[dp(56),
                                                          dp(56)])
        self.record_button.md_bg_color = App.get_running_app(
        ).theme_cls.primary_color
        self.record_button.text_color = [1, 1, 1, 1]
        if platform not in ['ios', 'android']:
            self.record_button.bind(on_press=lambda x: self.decode_audio())
        record_button_anchor.add_widget(self.record_button)

        self.decode_input = MDTextFieldRound(pos_hint={
            'center_x': 0.5,
            'center_y': 0.5
        },
                                             size_hint=(0.85, 0.5))
        self.decode_input.icon_left_dasabled = True
        # Moves widget out of the field of view
        self.decode_input.children[2].children[2].pos_hint = {
            'center_x': 500,
            'center_y': 500
        }
        # This binds the right icon to record the input
        self.decode_input.icon_right = 'database-export'
        self.decode_input.children[2].children[0].bind(
            on_press=lambda x: self.clear_text())

        decode_card = MDCard(padding=dp(24),
                             spacing=dp(24),
                             orientation='vertical',
                             size_hint_x=0.85,
                             size_hint_y=0.7,
                             pos_hint={
                                 'top': 0.85,
                                 'center_x': 0.5
                             })
        decode_label = MDLabel(text='Decode Morse Code Audio',
                               font_style='Body1',
                               halign='center',
                               size_hint=(1, 0.5))
        decode_label.theme_text_color = 'Custom'
        decode_label.text_color = [1, 1, 1, 1]
        decode_card.add_widget(decode_label)

        decode_text = 'Hit record or enter Morse Code below to start decoding'
        self.decode_output_label = MDLabel(text=decode_text,
                                           font_style='Body1',
                                           halign='center',
                                           size_hint=(1, 0.5))
        self.decode_output_label.theme_text_color = 'Custom'
        self.decode_output_label.text_color = [1, 1, 1, 1]
        if platform not in ['ios', 'android']:
            self.audio_indicator = AudioIndicator(
                stack_width=self.amr.bits_per_frame)
        else:
            self.audio_indicator = AudioIndicator(stack_width=40)
        self.audio_indicator.size_hint = (1, 2)

        decode_card.add_widget(self.audio_indicator)
        decode_card.add_widget(self.decode_output_label)
        decode_card.add_widget(self.decode_input)
        decode_card.md_bg_color = App.get_running_app().theme_cls.accent_color
        decode_card.elevation = 15

        self.add_widget(decode_card)
        self.add_widget(record_button_anchor)

        # Nav Bar
        self.nav_bar = MyNavigationLayout()
        self.nav_bar_anchor = AnchorLayout(anchor_x='center', anchor_y='top')
        self.nav_bar_anchor.add_widget(self.nav_bar)
        self.add_widget(self.nav_bar_anchor)
예제 #9
0
    def ui_layout(self):
        play_button_anchor = AnchorLayout(
            anchor_x='center',
            anchor_y='bottom',
            padding=[dp(25), dp(25), dp(25), dp(25)])

        # disable play button for now
        play_button = MDFloatingActionButton(icon='play',
                                             size=[dp(56), dp(56)])
        play_button.disabled = True
        play_button.opacity = 0
        # [76/255, 175/255, 80/255, 1]
        # play_button.md_bg_color = App.get_running_app().theme_cls.primary_color
        # play_button.text_color = [1, 1, 1, 1]
        # play_button.bind(on_press=lambda x: self.play_audio())
        # play_button_anchor.add_widget(play_button)

        self.encode_input = MDTextFieldRound(pos_hint={
            'center_x': 0.5,
            'center_y': 0.5
        },
                                             size_hint=(0.85, 0.5))
        self.encode_input.icon_right = 'send'

        self.encode_input.children[2].children[0].bind(
            on_press=lambda x: self.play_prompt())
        self.encode_input.icon_left = 'close-circle'
        self.encode_input.children[2].children[2].disabled = False
        self.encode_input.children[2].children[2].bind(
            on_press=lambda x: self.clear_input())

        encode_card = MDCard(padding=dp(24),
                             spacing=dp(24),
                             orientation='vertical',
                             size_hint_x=0.85,
                             size_hint_y=0.7,
                             pos_hint={
                                 'top': 0.85,
                                 'center_x': 0.5
                             })
        encode_label = MDLabel(text='Encode Morse Code Audio',
                               font_style='Body1',
                               halign='center',
                               size_hint=(1, 0.5))
        encode_label.theme_text_color = 'Custom'
        encode_label.text_color = [1, 1, 1, 1]

        self.encode_output_label = MDLabel(
            text='Enter text to convert to morse code',
            halign='center',
            size_hint=(1, 0.5))
        self.encode_output_label.theme_text_color = 'Custom'
        self.encode_output_label.text_color = [1, 1, 1, 1]

        self.audio_indicator = AudioIndicator()
        self.audio_indicator.size_hint = (1, 2)
        Clock.schedule_interval(self.update_audio_indicator, 0.1)

        encode_card.add_widget(encode_label)
        encode_card.add_widget(self.audio_indicator)
        encode_card.add_widget(self.encode_output_label)
        encode_card.add_widget(self.encode_input)
        encode_card.md_bg_color = App.get_running_app().theme_cls.accent_color
        encode_card.elevation = 15

        self.add_widget(encode_card)
        self.add_widget(play_button_anchor)

        # Nav Bar
        self.nav_bar = MyNavigationLayout()
        self.nav_bar_anchor = AnchorLayout(anchor_x='center', anchor_y='top')
        self.nav_bar_anchor.add_widget(self.nav_bar)
        self.add_widget(self.nav_bar_anchor)

        self.cur_sound_index = 0
        self.sound_list = []
        self.cur_sound = None