コード例 #1
0
def Init():
    """Initialise everything. Run once on startup"""
    w,h = (1280,720)
    globals.tile_scale            = Point(1,1)
    globals.scale                 = Point(3,3)
    globals.screen                = Point(w,h)/globals.scale
    globals.screen_root           = ui.UIRoot(Point(0,0),globals.screen)
    globals.quad_buffer           = drawing.QuadBuffer(131072)
    globals.screen_texture_buffer = drawing.QuadBuffer(131072)
    globals.ui_buffer             = drawing.QuadBuffer(131072)
    globals.nonstatic_text_buffer = drawing.QuadBuffer(131072)
    globals.colour_tiles          = drawing.QuadBuffer(131072)
    globals.mouse_relative_buffer = drawing.QuadBuffer(1024)
    globals.line_buffer           = drawing.LineBuffer(16384)
    globals.tile_dimensions       = Point(16,16)*globals.tile_scale
    globals.sounds                = sounds.Sounds()
    globals.zoom_scale            = None

    globals.dirs = globals.types.Directories('resource')

    pygame.init()
    screen = pygame.display.set_mode((w,h),pygame.OPENGL|pygame.DOUBLEBUF)
    pygame.display.set_caption('The Gosh Signal')
    drawing.Init(globals.screen.x,globals.screen.y)

    globals.text_manager = drawing.texture.TextManager()
コード例 #2
0
ファイル: rogueplanet.py プロジェクト: tompudding/rogueplanet
def Init():
    """Initialise everything. Run once on startup"""
    #w,h = (1600,1100)
    w, h = (1280, 720)
    globals.tile_scale = Point(1, 1)
    globals.scale = Point(2, 2)
    globals.screen_abs = Point(w, h)
    globals.screen = globals.screen_abs / globals.scale
    globals.screen_root = ui.UIRoot(Point(0, 0), globals.screen_abs)
    globals.mouse_screen = Point(0, 0)
    globals.lights = []
    globals.cone_lights = []
    globals.non_shadow_lights = []
    globals.uniform_lights = []

    globals.quad_buffer = drawing.QuadBuffer(131072)
    globals.screen_texture_buffer = drawing.QuadBuffer(131072, ui=True)
    globals.ui_buffer = drawing.QuadBuffer(131072, ui=True)
    globals.nonstatic_text_buffer = drawing.QuadBuffer(131072, ui=True)
    globals.light_quads = drawing.QuadBuffer(16384)
    globals.nightlight_quads = drawing.QuadBuffer(16)
    globals.temp_mouse_light = drawing.QuadBuffer(16)
    globals.colour_tiles = drawing.QuadBuffer(131072)
    globals.mouse_relative_buffer = drawing.QuadBuffer(1024,
                                                       ui=True,
                                                       mouse_relative=True)
    globals.line_buffer = drawing.LineBuffer(16384)
    globals.shadow_quadbuffer = drawing.ShadowQuadBuffer(256 * 4)
    globals.temp_mouse_shadow = globals.shadow_quadbuffer.NewLight()
    globals.tile_dimensions = Point(16, 16) * globals.tile_scale
    globals.sounds = sounds.Sounds()
    globals.zoom_scale = None
    globals.time_step = 0.05

    #WTF?
    globals.mouse_light_quad = drawing.Quad(globals.temp_mouse_light)
    #globals.mouse_light_quad.SetVertices(Point(0,0),
    #                                         Point(500,500),10)
    #globals.mouse_light_quad.Disable()

    globals.dirs = globals.types.Directories('resource')

    pygame.init()
    screen = pygame.display.set_mode((w, h), pygame.OPENGL | pygame.DOUBLEBUF)
    pygame.display.set_caption('Rogue Planet')
    drawing.Init(globals.screen.x, globals.screen.y)

    globals.text_manager = drawing.texture.TextManager()
コード例 #3
0
    def __init__(self):
        self.master = Tk()

        self.canvas = Canvas(self.master)
        self.canvas.pack(fill='both', expand='yes')
        x, y = self.get_center(self.canvas)

        # Sound configuration
        self.sounds = sounds.Sounds(audio_library=sounds.PYDUB)
        self.playing = False
        self.c = self.canvas.create_text(x, y, text='')
        self.counter = 0

        def key(event):
            key_press = event.char.lower()
            if key_press in 'abcdefghijklmnopqrstuvwxyz123456789' and not self.playing:
                playlist = []
                self.canvas.delete(self.c)
                text_x, text_y = self.get_center(self.canvas)
                self.c = self.canvas.create_text(
                    text_x,
                    text_y,
                    text=f'{key_press.upper()} {key_press.lower()}',
                    font=self.get_font(self.canvas),
                )
                letter = self.sounds.get_random_sound(key_press)
                word = self.sounds.get_random_word(key_press)
                if word:
                    playlist.append(word)
                if letter:
                    playlist.append(letter)
                t = Thread(target=self.play_thread, args=[playlist])
                t.setDaemon(True)
                t.start()

        self.master.bind('<Key>', key)

        self.master.mainloop()
コード例 #4
0
ファイル: state_controller.py プロジェクト: RoboErik/RUBIK
    def __init__(self, gui, solver, simon, gears):
        self._in_game = False
        self._state = STATE_HOME
        self._ui_state = Gui.UI_HOME
        self._temp_data = None
        self._reset_timer = None
        self._reset_buttons = None
        self._last_event_time = time.time()
        self._is_screen_off = False

        self._event_queue = Queue()
        self._sounds = sounds.Sounds()

        self._gui = gui
        self._gui_queue = gui.get_queue()
        gui.set_event_queue(self._event_queue)

        self._solver = solver
        self._solver_queue = solver.get_queue()
        solver.set_event_queue(self._event_queue)
        solver.start()

        self._simon = simon
        self._simon_queue = simon.get_queue()
        simon.set_event_queue(self._event_queue)
        simon.start()

        self._gears = gears
        self._gears_queue = gears.get_queue()
        self._gear_sound = None
        gears.set_event_queue(self._event_queue)
        gears.start()

        self._gui.set_ui_state(Gui.UI_HOME)
        self._scores = None
        self.load_scores()

        threading.Thread.__init__(self)
コード例 #5
0
def main():
    fullscreen = False
    width, height = 960, 600
    level_path = None

    i = 1
    while i < len(sys.argv):
        if sys.argv[i] == '--fullscreen':
            fullscreen = True
        elif sys.argv[i] == '--window':
            try:
                width, height = map(int, sys.argv[i + 1].split('x'))
            except:
                Usage()
            i += 1
        elif level_path:
            Usage()
        else:
            level_path = sys.argv[i]
        i += 1

    pygame.init()

    flags = pygame.OPENGL | pygame.DOUBLEBUF | pygame.HWSURFACE
    if fullscreen:
        width, height = 0, 0
        flags |= pygame.FULLSCREEN

    pygame.display.set_caption('Moon')

    screen = pygame.display.set_mode((width, height), flags)

    render = renderer.Render(screen)
    snds = sounds.Sounds()

    if level_path:
        print 'Debugging map %s.' % level_path
        m = mission.Mission(level_path)
        g = game.Game(render, snds, m)
        result = g.Run()
        print 'Result: %i, took %0.1f seconds' % (result, g.play_time)
    else:
        levels = ('data/c0_m0.txt', 'data/c1_m0.txt', 'data/c1_m1.txt',
                  'data/c1_m2.txt')
        par_times = (72.5, 29.2, 89.6, 88.4)
        play_times = [None] * len(levels)
        i = 0
        while i < len(levels):
            level_path = levels[i]
            m = mission.Mission(level_path)
            g = game.Game(render, snds, m)
            result = g.Run()
            if result == game.Game.ABORTED:
                break
            if result == game.Game.VICTORY:
                play_times[i] = g.play_time
                i += 1

        if i > 0:
            print 'Your times:'
            for i, (play_time,
                    par_time) in enumerate(zip(play_times, par_times)):
                if play_time is None:
                    continue
                print('Mission %i: %5.1fs    Par time: %5.1fs' %
                      (i + 1, play_time, par_time))
コード例 #6
0
import time

import pygame
pygame.mixer.pre_init(44100, -16, 1,
                      512)  # must be called before pygame.init!!!
pygame.init()
import sounds
sounds = sounds.Sounds()

import hardware
hardware = hardware.Hardware()

hardware.setWeaponCharacteristics(playerid=123, damage=42, laser_duration=1)
while True:
    if hardware.isWeaponButtonDown(0):
        sounds.play('pew', False)
        hardware.shootWeapon(laser0=1, laser1=0)
        time.sleep(0.3)
    time.sleep(0.005)
コード例 #7
0
ファイル: app.py プロジェクト: MarioCruz/2xlReBot
import os, signal, time
import topics, questions, sounds, ui
from datetime import datetime

curdir = os.path.dirname(os.path.realpath(__file__))
topics = topics.Topics(curdir)
bank = questions.QuestionBank(curdir, topics.topic_directory_name,
                              topics.current_topic_directory(),
                              topics.topic_file_name)
sounds = sounds.Sounds(curdir)
ui = ui.UserInterface(topics, bank, sounds)

# the entry point to the application...
if __name__ == "__main__":
    signal.signal(signal.SIGINT, ui.cleanup)
    while ui.running:
        time.sleep(0.5)