Esempio n. 1
0
    def do_main():
        """
        When run as main program, create Menu object and run main function
        """
        main_pyray = PyRay()
        main_config = Config("./config/starting_gate.json")

        main_pyray.init_window(240, 240, "Menu Test")
        main_pyray.set_target_fps(30)
        main_pyray.hide_cursor()

        main_font = main_pyray.load_font("fonts/Roboto-Black.ttf")
        menu = Menu(main_pyray, main_font, main_config)
        menu.process_menus()
Esempio n. 2
0
    def do_main():
        """
        When run as main program, create Menu object and run main function
        """
        pyray = PyRay()

        pyray.init_window(240, 240, "Menu Test")
        pyray.set_target_fps(30)
        pyray.hide_cursor()

        font = pyray.load_font("fonts/Roboto-Black.ttf")

        inp = Input(pyray, font)

        while True:
            string = inp.get_string()
            print("User input '", string, "'")
            if string == "done":
                break
Esempio n. 3
0
"""

raylib [core] example - Mouse input

"""
from raylib.pyray import PyRay
from raylib.colors import (
    RAYWHITE,
    DARKGRAY,
    MAROON,
    DARKBLUE,
    LIME,
)

pyray = PyRay()

# Initialization
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 450

pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT,
                  'raylib [core] example - mouse input')

ball_position = pyray.Vector2(-100, -100)
ball_color = DARKBLUE

pyray.set_target_fps(60)  # Set our game to run at 60 frames-per-second

# Main game loop
while not pyray.window_should_close():  # Detect window close button or ESC key
    # Update
Esempio n. 4
0
    def __init__(self, config):
        threading.Thread.__init__(self, daemon=True)

        self.config = config
        self.pyray = PyRay()

        # Value between 0.0 and 1.0 used to determine how far each car moves down
        # the screen on each iteration of the display loop. See __race_started() below.
        self.progress_threshold = 0.4

        # Initialize the dispatch table
        self.dispatch = {
            RaceState.WAIT_MENU: self.__wait_menu,
            RaceState.MENU_DONE: self.__menu_done,
            RaceState.WAIT_FINISH_LINE: self.__wait_finish_line,
            RaceState.WAIT_REMOTE_REGISTRATION:
            self.__wait_remote_registration,
            RaceState.REMOTE_REGISTRATION_DONE:
            self.__remote_registration_done,
            RaceState.WAIT_LOCAL_READY: self.__wait_local_ready,
            RaceState.WAIT_REMOTE_READY: self.__wait_remote_ready,
            RaceState.COUNTDOWN: self.__countdown,
            RaceState.RACE_STARTED: self.__race_started,
            RaceState.RACE_FINISHED: self.__race_finished,
            RaceState.RACE_TIMEOUT: self.__race_timeout
        }

        # Declare initial Y offset for car images at the start of a race
        self.y_starting_offset = 0
        self.local_y = [0, 0, 0, 0]
        self.remote_y = [0, 0, 0, 0]

        # Declare local texture variables. __load_textures() will load the appropriate
        # textures based on whether a single or multi track race is selected.
        self.background_texture = None

        self.local_textures = [None, None, None, None]
        self.remote_textures = [None, None, None, None]

        self.checkerboard_texture = None
        self.question_texture = None
        self.place_textures = []
        self.fail_texture = None

        self.countdown_start = None
        self.font = None
        self.menu = None
        self.results = None
        self.first_results_display = None

        self.menu_event = threading.Event()
        self.menu_event.clear()

        self.countdown_event = threading.Event()
        self.countdown_event.clear()

        self.remote_icons_loaded = False
        self.registration_event = threading.Event()
        self.registration_event.clear()

        self.state = RaceState.WAIT_MENU
        self.running = True
        self.start()
Esempio n. 5
0
from raylib.static import *
from raylib.pyray import PyRay
from .util import *
import pathlib
PATH = pathlib.Path(__file__).parent
screen = PyRay()

LIGHT_DIRECTIONAL = 0
LIGHT_POINT = 1


class LightSystem:
    MAX_LIGHTS = 4  #// Max dynamic lights supported by shader

    def __init__(self, ambient=[0.2, 0.2, 0.2, 1.0], *ls):
        self.lights = []
        self.lightsCount = 0
        self.shader = screen.load_shader(str(PATH / "basic_lighting.vs"),
                                         str(PATH / "basic_lighting.fs"))

        self.shader.locs[LOC_MATRIX_MODEL] = GetShaderLocation(
            self.shader, b"matModel")
        self.shader.locs[LOC_VECTOR_VIEW] = GetShaderLocation(
            self.shader, b"viewPos")

        self.ambientLoc = GetShaderLocation(self.shader, b"ambient")
        v = ffi.new("struct Vector4 *", ambient)
        SetShaderValue(self.shader, self.ambientLoc, v, UNIFORM_VEC4)

        for light in ls:
            self.add(light)