Example #1
0
    def run(self):
        self.levels = []
        self.bool = False
        client = pymongo.MongoClient(
            "mongodb+srv://Player:[email protected]/test?retryWrites=true&w=majority"
        )
        db = client['TonksDB']
        col = db['Levels']

        for i in col.find({}, {'_id': 0}):
            self.levels.append(i)

        for i in range(len(mongo_client.levels)):
            name = mongo_client.levels[i]['name']
            buttons.append(
                Button(name,
                       screen_width - 270,
                       240 + i * 32,
                       small_font,
                       WHITE, (77, 132, 168),
                       db_level_click,
                       static_w=200,
                       static_h=32))

        self.bool = True
Example #2
0
    def __init__(self):
        super(Game, self).__init__()
        self.done = False

        self.buttons = []
        self.buttons.append(Button.NewButton(16, 16))

        self.organisms = []

        self.nutrientmap = []
        self.moisturemap = []
        self.heatmap = []
        self.regenmap = [
        ]  # Values on the regenmap correspond to tile regeneration rates on the nutrient map

        self.map_surface = pygame.Surface((screen_dimensions_without_hud[0],
                                           screen_dimensions_without_hud[1]))
        self.camera_offset = [0, 0]

        self.target_organism = None

        self.total_creature_count = 0

        self.toggle = False
Example #3
0
import logging.handlers

format = "%(asctime)s %(pid)s %(levelname)s %(name)s: %(message)s"

from dicts.ras_dic import PinsBuzzer, PinsDown, PinsOK
from lib import Display, CardReader, PasBuz, Button
from lib import OdooXMLrpc, Tasks
import traceback
from io import StringIO

_logger = logging.getLogger(__name__)

Buz = PasBuz.PasBuz(PinsBuzzer)
Disp = Display.Display()
Reader = CardReader.CardReader()
B_Down = Button.Button(PinsDown)
B_OK = Button.Button(PinsOK)
Hardware = [Buz, Disp, Reader, B_Down, B_OK]

Odoo = OdooXMLrpc.OdooXMLrpc()  # communicate via xlm
Tasks = Tasks.Tasks(Odoo, Hardware)


def ask_twice():
    # user asked twice before executing -'are you sure?'
    Buz.Play("OK")
    Disp.display_msg("sure?")
    B_OK.pressed = False  # avoid false positives
    B_Down.pressed = False
    time.sleep(0.4)  # allow time to take the finger
    # away from the button
Example #4
0
def create_colour(h):
    colour = colorsys.hsv_to_rgb(h / 360, 1.0, 1.0)
    return colour[0] * 255, colour[1] * 255, colour[2] * 255


def function(button_name, cur_level):
    global if_no_level, selected_level
    selected_level = button_name
    if_no_level = f'assets/levels/{button_name}.txt'
    #print(button_name)


for i in range(len(level_names)):
    buttons.append(
        Button(level_names[i], 50, 240 + i * 32, small_font, WHITE,
               (77, 132, 168), function, 200, 32))


def play_button(q, cur_level):
    if cur_level == "Nothing":
        return
    global main_menu
    main_menu = False


buttons.append(
    Button('Play', screen_width // 2 - 65, screen_height - 100, medium_font,
           WHITE, GREEN, play_button, 120, 70))
loadtime = 0
while main_menu:
    screen.fill(BLACK)