Beispiel #1
0
    def initialize(self):
        Peripherals.init()
        if self.emulateSensor:
            self.sensor = FakeSensor()
        else:
            self.sensor = Sensor(Peripherals.devices["Pillow"])
        #self.led = LED(Peripherals.devices["Basestation"])
        #self.led.setLum(0, 0)

        actions.powerplug.PowerPlug.init()

        # toDo: ggf. zentraler Display Manager
        self.screenMult = 4
        #self.display = Display(self.screenMult*320, self.screenMult*240, self.isRaspberry)
        self.display = Display(1024, 600, self.isRaspberry)
        #self.graph = Graph(self.display, self.sensor)
        self.clock = Clock(self.display)
        self.settings = Settings(self.display)
        self.settings.onButton = self.onButton
        self.settings.onSetLight = self.onSetLight

        self.scheduler = Scheduler()
        # ToDo: Alarme in config File, periodisch auslesen
        self.scheduler.addAlarm("*", "7", "45",
                                actions.powerplug.PowerPlug.alarm)
Beispiel #2
0
    def __init__(self):
        self.board = ChessBoard()
        self.display = Display(self)
        self.player1 = PolicyPlayer(1, 2, self)
        self.player2 = PolicyPlayer(2, 1, self)

        super(PolicyPKPolicyGame, self).__init__(self.board, self.display,
                                                 self.player1, self.player2)
    def __init__(self, surface):
        self.surface = surface
        self.display = Display(self.surface)

        self.clock = pg.time.Clock()

        self.car_img_width = 66
        self.car_img_height = 142

        self.player = PlayerBuilder().get_player()
Beispiel #4
0
 def __init__(self):
     super().__init__()
     self.window_close = False
     self.display = Display(self.interface)
     self.map = None
     self.hero_acted = False
     self.sprites = self.interface.GroupSprite()
     self.level = 0
     self.last_level = 2
     self.animations = []
Beispiel #5
0
 def _simulate_play(self, state):
     board = ChessBoard(self.game.board.width, self.game.board.height,
                        self.game.board.n_in_row, state)
     game = Game(board, None, None, None)
     display = Display(game)
     player1 = PolicyPlayer(self.other_index, self.index, game)
     player2 = PolicyPlayer(self.index, self.other_index, game)
     game.display = display
     game.player = game.player1 = player1
     game.player2 = player2
     game.mainloop()
     return display.win_player is not None and display.win_player.index == self.index
Beispiel #6
0
def main():
    try:
        opts, args = getopt.getopt(
            sys.argv[1:], "hs:lL:n:t:",
            ["help", "server=", "localhost", "logging=", "name=", "title="])
    except getopt.GetoptError as e:
        print(str(e))
        usage()
        sys.exit(1)

    show_help = False
    server = "rookie.cs.dixie.edu"
    name = DEFAULT_TEAM_NAME
    title = DEFAULT_GAME_TITLE
    logging_level = "error"
    for o, a in opts:
        if o in ("-h", "--help"):
            show_help = True
        elif o in ("-s", "--server"):
            server = a
        elif o in ("-l", "--localhost"):
            server = "127.0.0.1"
        elif o in ("-L", "--logging"):
            logging_level = a
        elif o in ("-n", "--name"):
            name = a
        elif o in ("-t", "--title"):
            title = a
        else:
            print("Unexpected option: %s" % (o))
            usage()
            sys.exit(1)
    if show_help:
        usage()
        sys.exit(1)

    if logging_level == "info":
        logging.basicConfig(level=logging.INFO)
    elif logging_level == "debug":
        logging.basicConfig(level=logging.DEBUG)
    elif logging_level == "warning":
        logging.basicConfig(level=logging.WARNING)
    elif logging_level == "error":
        logging.basicConfig(level=logging.ERROR)
    else:
        logging.basicConfig(level=logging.ERROR)

    display = Display(WINDOW_WIDTH, WINDOW_HEIGHT)
    control = Control(WINDOW_WIDTH, WINDOW_HEIGHT)
    g = PygameClient(display, control, WINDOW_WIDTH, WINDOW_HEIGHT,
                     FRAMES_PER_SECOND, name, title, server)
    g.main_loop()
    return
Beispiel #7
0
    def execute(self):
        display_init = Display(self.app_name, self.icon, self.display_size[0],
                               self.display_size[1])
        display_init.run()
        display = display_init.display

        app_quit = False

        while not app_quit:
            if self.state == States.menu:
                menu = Menu(self.app_name, display, self.display_size)
                self.state = States(menu.run())
            elif self.state == States.game:
                game = Game(self.app_name, display, self.display_size)
                self.state = States(game.run())
            elif self.state == States.settings:
                self.state = States(self.settings.run())
            elif self.state == States.app_exit:
                app_quit = True
    def __init__(self,
                 width,
                 height,
                 frame_rate,
                 name,
                 title,
                 server_host="localhost",
                 server_port=20149):
        PygameSocketGame.__init__(self, title, width, height, frame_rate,
                                  server_host, server_port)
        self.name = name
        self.display = Display(width, height)
        self.control = Control(width, height)
        self.control.player_image = "duck2.png"

        # music_path = os.path.join('display', 'music', 'LukHash_-_ARCADE_JOURNEYS.wav')
        # pygame.mixer.music(music_path).play(-1)

        return
Beispiel #9
0
    def __init__(self):
        # Camera and display
        self.display = Display(SCREEN_WIDTH, SCREEN_HEIGHT)
        self.camera = CameraCapture()
        self.mqttClient = MqttClient(self.parsingPacket)

        self.teacherId = -1
        self.studentId = -1
        self.teacherStart = datetime.now()
        self.teacherTime = 0
        self.teacherDistance = 0
        self.studentStart = datetime.now()
        self.studentTime = 0
        self.studentDistance = 0
        self.studentLastTime = timedelta(seconds=0)
        self.studentLastDistance = 0

        # Face detection
        self.faceRecs = []
        self.showRecsCount = 0

        self.updateTime()
        self.updateCamera()
Beispiel #10
0
# Read about what each thing does in the respective class
# !!! WARNING !!! The game will break if the level does not contain the player ("C") within; the game may break if the door Top and Bottom is not found as well.

import pygame

from Entities.player import Player
from Entities.platform import Platform
from Entities.door import Door
from Entities.coins import Coins
from Entities.spike import Spike
from Entities.trophies import Trophy
from display.display import Display
from BuildFunctions.directory import Directory

Display = Display()
Directory = Directory()


class LevelLoader(object):
    """
    This class actually handles a lot of things; while also handling the level loading, it also must be used to call from another class in the game
    class itself.  For example, to use anything from the Player class, the user must have LevelLoader()getPlayer().functionHere.
    In all honesty, this class handles pretty much everything that has anything to do with levels.
    """
    def __init__(self):
        self.level = 0
        self.platforms = []

        self.doorsClosed = True

        self.entities = pygame.sprite.Group()
Beispiel #11
0
    def __init__(self):
        self.display = Display()
        self.registration = Registration()

        self.on = False
        self.channels = []
        self.instance = vlc.Instance()
        self.log = vlc.Log()
        self.player = self.instance.media_player_new()
        self.events = self.player.event_manager()
        self.media = self.instance.media_new("")
        self.selectedChannel = None
        self.lastPowerState = None
        self.volume = int(os.environ["mnm_volume"])
        self.setVolume(self.volume)
        self.turnOnTime = None

        # A variable to hold the buffer timer.
        # Removes buffer from the state if there hasn't been sent another buffer event
        # since the timer started.
        self.bufferTimer = None

        # What the state was previous to buffering
        self.preBufferState = None

        # Is set when fetching channels. If it fails, we assume the server is down.
        self.serverUp = True

        # Bitrates
        # Put an int in the bitrate variable, and the stream closest to that bitrate will be used.
        # 32 kbps - Poor audio quality
        # 48 kbps - A reasonable lower end rate for longer speech-only podcasts
        # 64 kbps - A common bitrate for speech podcasts.
        # 128 kbps - Common standard for musical and high quality podcasts.
        # 320 kbps - Very high quality - almost indistinguishable from a CD.
        self.bitrate = int(os.environ["mnm_bitrate"])

        # Is set if the radio is updating (Dictionary)
        self.updating = None

        # String
        # Is set if there is a global error (ie. not related to channels)
        self.error = None

        # String
        # Is set if there is an error on the channel
        # Ie. if we couldn't open the channel
        self.channelError = None

        # State of radio (Dictionary)
        # { code: "buffering" || "ended" || "opening" || "paused" || "playing" || "stopped", text: "text description" }
        self.state = {"code": "starting", "text": _("Starting")}

        # When the user started listening. For analytics purposes.
        self.startedListeningTime = None

        self.saveListeningHistory = helpers.castToBool(
            os.environ["mnm_saveListeningHistory"])
        self.sendState = helpers.castToBool(os.environ["mnm_sendState"])

        # Listen for VLC events
        self.instance.log_set(logCallback, None)
        self.events.event_attach(vlc.EventType.MediaPlayerOpening,
                                 self.openingEvent)
        self.events.event_attach(vlc.EventType.MediaPlayerBuffering,
                                 self.bufferingEvent)
        self.events.event_attach(vlc.EventType.MediaPlayerPlaying,
                                 self.playingEvent)
        self.events.event_attach(vlc.EventType.MediaPlayerPaused,
                                 self.pausedEvent)
        self.events.event_attach(vlc.EventType.MediaPlayerStopped,
                                 self.stoppedEvent)
        self.events.event_attach(vlc.EventType.MediaPlayerEndReached,
                                 self.endReachedEvent)
        self.events.event_attach(vlc.EventType.MediaPlayerEncounteredError,
                                 self.errorEvent)
Beispiel #12
0
 def __init__(self, width, height, frame_rate, name, title, server_host="localhost", server_port=20149):
     PygameSocketGame.__init__(self, title, width, height, frame_rate, server_host, server_port)
     self.name = name
     self.display = Display(width, height)
     self.control = Control(width, height)
     return
Beispiel #13
0
from display.display import Display
import config

if __name__ == "__main__":
    server = Display(config)
    #server.run()
Beispiel #14
0
  print('| mode 5: show boxplot               |')
  print('| mode 6: show scatter               |')
  print('| mode 7: show scatter (one pos)     |')
  print('--------------------------------------')
  mode = input('Enter a mode(0~7) or -1 to exit this program: ')
  mode = int(mode)
  
  if mode == 0:
    if my_display:
      my_display.reset()
    # Unused position
    pos_list = []
    # Unused time
    time = ['2020 02 02', '2020 02 03']
    # create a Display object
    my_display = Display(pos_list, time)
    # get and print recent data
    my_display.get_all_data()
    my_display.print_recent_data()
    break

  elif mode == 1:
    if my_display:
      my_display.reset()
    # input time & a position
    time = input_time()
    pos_list = input_pos(multiple=False)
    # create a Display object
    my_display = Display(pos_list, time)
    # plt
    my_display.get_data_by_pos()