Example #1
0
min_dist_tag = TextObject([0, 0], [255, 0, 0], pygame.font.SysFont(
    'arial', 20), 'Minimum distance(px):    {}'.format(params['min_dist']))


def adj_min_dist_func():
    params.update({
        'min_dist':
        max(20, min(50, adjs['delta_min_dist'] + params['min_dist']))
    })
    min_dist_tag.set_text('Minimum distance(px):    {}'.format(
        params['min_dist']))
    min_dist_tag.__build__()
    pygame.time.wait(150)


adjust_min_dist = Button([0, 0], [255, 0, 0],
                         pygame.font.SysFont('arial', 20),
                         'Adjust Min Distance', [0, 255, 0], [30, 10],
                         on_hold=adj_min_dist_func)

toggle_min_dist_adj_direction = ToggleButton(
    [0, 0], [[255, 0, 0], [0, 255, 0]],
    pygame.font.SysFont('arial', 20), ['INCREASE', 'DECREASE'], [30, 10],
    on_click=lambda: adjs.update(
        {'delta_min_dist': adjs['delta_min_dist'] * -1}))

min_dist_row = RowBorder(
    [window_size[0] // 4, 240], [0, 255, 255], 950, 10,
    [min_dist_tag, adjust_min_dist, toggle_min_dist_adj_direction])
Example #2
0
from config import window_size
from config import params

from pygameui.clickable.toggle_button import ToggleButton
from pygameui.text_object import TextObject
from pygameui.row_border import RowBorder

import pygame

always_limit_speed_tag = TextObject([0, 0], [255, 0, 0],
                                    pygame.font.SysFont('arial', 20),
                                    'Always Limit Speed:   ')

toggle_always_limit_speed = ToggleButton(
    [0, 0], [[255, 0, 0], [255, 0, 0]],
    pygame.font.SysFont('arial', 20), ['ACTIVE', 'INACTIVE'], [30, 10],
    on_click=lambda: params.update({'always_limit_speed': False}) if params[
        'always_limit_speed'] else params.update({'always_limit_speed': True}))

always_limit_speed_row = RowBorder(
    [window_size[0] // 4, 590], [0, 255, 255], 950, 10,
    [always_limit_speed_tag, toggle_always_limit_speed])
Example #3
0
        max(20, min(800, adjs['delta_influence'] + params['influence']))
    })
    influence_tag.set_text('Visual perception(px):    {}'.format(
        params['influence']))
    influence_tag.__build__()
    pygame.time.wait(150)


adjust_influence = Button([0, 0], [255, 0, 0],
                          pygame.font.SysFont('arial', 20),
                          'Adjust Influence', [0, 255, 0], [30, 10],
                          on_hold=adj_influence_func)

toggle_influence_adj_direction = ToggleButton(
    [0, 0], [[255, 0, 0], [0, 255, 0]],
    pygame.font.SysFont('arial', 20), ['INCREASE', 'DECREASE'], [30, 10],
    on_click=lambda: adjs.update(
        {'delta_influence': adjs['delta_influence'] * -1}))

toggle_delta_influence = ToggleButton(
    [0, 0], [[255, 0, 0], [255, 0, 0], [255, 0, 0]],
    pygame.font.SysFont('arial', 20), ['1', '10', '100'], [30, 10],
    on_click=lambda: adjs.update(
        {'delta_influence': adjs['delta_influence'] * 10})
    if -100 < adjs['delta_influence'] < 100 else adjs.update(
        {'delta_influence': np.sign(adjs['delta_influence'])}))

influence_row = RowBorder([window_size[0] // 4, 170], [0, 255, 255], 950, 10, [
    influence_tag, adjust_influence, toggle_influence_adj_direction,
    toggle_delta_influence
])
Example #4
0
    })
    cohesion_factor_tag.set_text('Cohesion Factor:    {:.2f}'.format(
        round(params['cohesion_factor'], 2)))
    cohesion_factor_tag.__build__()
    pygame.time.wait(150)


adjust_cohesion_factor = Button([0, 0], [255, 0, 0],
                                pygame.font.SysFont('arial', 20),
                                'Adjust Cohesion Factor', [0, 255, 0],
                                [30, 10],
                                on_hold=adj_cohesion_factor_func)

toggle_cohesion_factor_adj_direction = ToggleButton(
    [0, 0], [[255, 0, 0], [0, 255, 0]],
    pygame.font.SysFont('arial', 20), ['INCREASE', 'DECREASE'], [30, 10],
    on_click=lambda: adjs.update(
        {'delta_cohesion_factor': adjs['delta_cohesion_factor'] * -1}))

toggle_delta_cohesion_factor = ToggleButton(
    [0, 0], [[255, 0, 0], [255, 0, 0], [255, 0, 0]],
    pygame.font.SysFont('arial', 20), ['0.01', '0.1'], [30, 10],
    on_click=lambda: adjs.update({
        'delta_cohesion_factor':
        0.1 * np.sign(adjs['delta_cohesion_factor'])
    }) if -0.05 < adjs['delta_cohesion_factor'] < 0.05 else adjs.update({
        'delta_cohesion_factor':
        0.01 * np.sign(adjs['delta_cohesion_factor'])
    }))

cohesion_factor_row = RowBorder(