Esempio n. 1
0
    def draw(self, context):
        dash = list()
        context.set_dash(dash)
        context.set_line_width(self.thickness)

        context.save()
        context.new_path()
        context.translate(self.x, self.y)
        if (self.width > 0) and (self.height > 0):
            context.scale(self.width, self.height)
        context.rectangle(0, 0, 1, 1)

        if self.fill_style == GRADIENT:
            context.set_source(self.gradient.gradient)
        elif self.fill_style == COLOR:
            context.set_source_rgba(
                self.fill_color.red, self.fill_color.green, self.fill_color.blue, self.fill_color.alpha
            )
        context.fill_preserve()
        context.restore()

        context.set_source_rgba(
            self.stroke_color.red, self.stroke_color.green, self.stroke_color.blue, self.stroke_color.alpha
        )
        context.stroke()

        for i, separator in enumerate(self.separators):
            separator.synchronize(self)
            separator.draw(context)
            self.handler.control[ANONIMOUS + i] = separator.control

        Object.draw(self, context)
Esempio n. 2
0
 def sync_from_client(self, objects):
     
     result = {}
     for sob in objects:
         
         exists = False
         conflict = False
         
         for o in self.objects:
             if o.guid == sob.guid:
                 exists = True
                 o.value = sob.value
                 o.deleted = sob.deleted
                 self.counter += 1
                 o.lastupdate_counter = self.counter
             elif o.pk == sob.pk:
                 # pk conflict: do nothing because this should not occur on server
                 # client will always sync from server to client first and handle
                 # any pk conflicts before syncing from client to server
                 exists = True
                 conflict = True
                 result['statuscode'] = NOK
         
         if not exists:
             no = Object(pk=sob.pk, name=sob.name, value=sob.value, guid=sob.guid)
             no.deleted = sob.deleted
             self.counter += 1
             no.lastupdate_counter = self.counter
             self.objects.append(no)
     
     if 'statuscode' not in result:
         result['statuscode'] = OK
     result['servercounter']  = self.counter
     return result
Esempio n. 3
0
    def __init__(self):
        Object.__init__(self)

        self.set_property("radius", 10)

        control = Control()
        self.handler.control.append(control)
Esempio n. 4
0
	def __init__(self):
		Object.__init__(self)
		
		# VARS
		self.episode = 0 # The last episode played.
		self.since = 0 # How many times it's been since this series was last played.
		self.num = 0 # The amount of items in this series.
    def __init__(self):
        Object.__init__(self)

        self._name = "unknown"

        # body
        self._gender = 0
        self._skin_color = 0
        self._hair_style = 0
        self._hair_color = 0
        self._underwear_color = 0

        # dress
        self._mantle = None
        self._shoes = None
        self._legging = None
        self._hauberk = None
        self._armor = None
        self._cap = None

        # weapon
        self._weapon = None
        self._shield = None

        # an action is a tuple representing the action, its direction
        # and its duration in milliseconds.  eg: (SUFFER, NE, 1000)
        self.pending_actions = []
        self.loop_action = (STAND, N, 1000)
        self.current_action = self.loop_action

        # this is the current animation
        self._animation = self.create_animation(self.loop_action)

        # internal elapsed_time needed to remember the remaining time
        self.elapsed_time = sf.Time()
Esempio n. 6
0
 def __init__(self, imgLocation, xPos, yPos, width, height):
     Object.__init__(self, imgLocation, xPos, yPos, width, height)
     #Modify the rect to include only one of three states
     self.rect.height = self.rect.height / 3
     self.rect.center = (xPos, yPos)
     self.subrect = pygame.Rect(0, 0, self.rect.width, self.rect.height)
     self.state = ClickableButton.NORMAL
Esempio n. 7
0
	def __init__(self):
		threading.Thread.__init__(self)
		Object.__init__(self)
		
		# OBJECTS
		self.scheduler = Schedule() # The schedule object
		self.series = [] # List of series
Esempio n. 8
0
 def draw(self, context):
     ###context.save()
     context.set_dash(self.dash)
     context.set_line_width(self.thickness)
     context.new_path()
     context.move_to(self.x, self.y)
     context.curve_to(
         self.x,
         self.y,
         self.handler.control[8].x,
         self.handler.control[8].y,
         self.x + self.width / 2,
         self.y + self.height / 2,
     )
     context.curve_to(
         self.x + self.width / 2,
         self.y + self.height / 2,
         self.handler.control[9].x,
         self.handler.control[9].y,
         self.x + self.width,
         self.y + self.height,
     )
     context.set_source_rgba(
         self.stroke_color.red, self.stroke_color.green, self.stroke_color.blue, self.stroke_color.alpha
     )
     context.stroke()
     Object.draw(self, context)
Esempio n. 9
0
	def addobject(self):
		"""Command of the "Add Object" option in "Object" menu.
		Creates an Object object to support object creation.
		"""
		
		newobj = Object(self)
		newobj.config()
Esempio n. 10
0
 def _pre_delete(self):
     Object._pre_delete(self)
     root = self.find_root()
     # Remove group name from User.groups
     root['users']._remove_group_name(self.__name__)
     # Remove group name from Content._local_roles
     root._remove_local_roles_for_principal('group:'+self.__name__)
Esempio n. 11
0
    def __init__(self):
        Object.__init__(self)

        self.set_property("radius", 10)

        control = Control()
        self.handler.control.append(control)
Esempio n. 12
0
 def __init__(self, name="unnamed game object", components=[]):
     Object.__init__(self)
     self.components = {}
     self.transform = Transform(self, name)
     self.components["Transform"] = self.transform
     for component in components:
         self.addComponent(component)
Esempio n. 13
0
 def __init__(self, latlng=None):
     Object.__init__(self)
     if latlng is None:
         raise ValueError('Trying to create marker with empty coordinates')
     self.latlng = latlng
     self.color = (1, 0, 0)
     self.size = 10
Esempio n. 14
0
	def __init__(self):
		Object.__init__(self)
		
		# VARS
		self.series = [] # List of series to play. 
		self.exclude_series = [] # List of series to exclude. If none, then none will be excluded.
		
		self.new_episodes = False # Only play new episodes.
		self.old_episodes = False # Only play old episodes.
		
		self.groups = [] # Only play from these groups
		self.exclude_groups = [] # Don't play any from these groups.
		
		self.use_ads = False # Play ads
		self.ads = [] # List of ads
		self.exclude_ads = [] # 
		
		self.ad_groups = [] # Play only ads from these groups
		self.ad_exclude_groups = [] # Don't play any ads from these groups.
		
		self.picker = settings.PICKER # The picker to use in this block.
		self.ad_picker = settings.AD_PICKER # Thi picker to use to pick adverts
		
		# REALTIME VARS
		self.current = False # If this block is currently being played.
Esempio n. 15
0
    def __init__(self, game, name, sprites, x, y, player):
        Object.__init__(self, game.stage)
        self.game = game
        self.name = name
        self.init_animations()
        self.image = self.animation.get_image()
        self.x = x
        self.y = y
        self.rect = pygame.Rect(self.x, self.y, 10, 10)
        self.flip = True
        self.change_state(Stand(self))
        self.dy = 0
        self.sprites = sprites
        self.last_attack = (0, 0)
        self.player = player
        self.shadow = shadow.Shadow(self)

        # Collision when is trowed
        self.collision_fly = None
        self.update_animation()

        if player:
            self.update()
            self.energy = energy.EnergyModel(name, 100, game.on_enemy_energy_model_change)
        else:
            Object.update(self)
            self.z = -self.y
Esempio n. 16
0
    def draw(self, context):
        dash = list()
        context.set_dash(dash)
        context.set_line_width(self.thickness)

        context.save()
        context.new_path()
        context.translate(self.x, self.y)
        if (self.width > 0) and (self.height > 0):
            context.scale(self.width, self.height)
        context.rectangle(0, 0, 1, 1)

        if self.fill_style == GRADIENT:
            context.set_source(self.gradient.gradient)
        elif self.fill_style == COLOR:
            context.set_source_rgba(self.fill_color.red, self.fill_color.green,
                                    self.fill_color.blue,
                                    self.fill_color.alpha)
        context.fill_preserve()
        context.restore()

        context.set_source_rgba(self.stroke_color.red, self.stroke_color.green,
                                self.stroke_color.blue,
                                self.stroke_color.alpha)
        context.stroke()

        for i, separator in enumerate(self.separators):
            separator.synchronize(self)
            separator.draw(context)
            self.handler.control[ANONIMOUS + i] = separator.control

        Object.draw(self, context)
Esempio n. 17
0
    def start_anim(self, colourList, lineConfigList, objConfigList, gui):

        for i in range(0, 3):
            Obj = Object(gui.mass_list[i] * phys.MASS_SCALING, phys.State(gui.xy[2 * i], \
                gui.xy[2 * i + 1], gui.vel_list[2 * i], gui.vel_list[2 * i+1], i+1))
            self.objectList.append(Obj)
            traceLine, = self.ax.plot([], [], lineConfigList[i], lw=1)
            self.traceLineList.append(traceLine)
            particleDiameter = Obj.get_radius(
            ) * 2 * phys.PLOT_DPI * phys.PLOT_SIZE / phys.GRID_SIZE
            particleLine, = self.ax.plot([], [],
                                         objConfigList[i],
                                         ms=particleDiameter)
            self.particleList.append(particleLine)

        from time import time
        t0 = time()
        self.animate(0)
        t1 = time()
        interval = (10**5) * self.dt - (t1 - t0)
        animFig = plt.figure(num=1, figsize=(phys.PLOT_SIZE, phys.PLOT_SIZE))
        animFig.set_size_inches(phys.PLOT_SIZE, phys.PLOT_SIZE, forward=True)
        ani = animation.FuncAnimation(animFig, self.animate, frames=ANIMATION_FRAMES, \
                              interval=interval, blit=True, init_func=self.init)
        plt.show()
        return ani
Esempio n. 18
0
 def add_object(self, pk, name, value):
     ''' Create object on server (do not use this function to add
     object from a client sync '''
     obj = Object(pk=pk, name=name, value=value)
     self.counter += 1
     obj.lastupdate_counter = self.counter
     self.objects.append(obj)
Esempio n. 19
0
 def __init__(self, player):
     Object.__init__(self)
     self.player = player
     self.animation = animation.Animation('bandage')
     self.rect = pygame.Rect(player.x, player.y, 0, 0)
     self.step = 0
     self.set_state('starting')
Esempio n. 20
0
    def __init__(self,
                 x,
                 y,
                 name,
                 oid=None,
                 use_function=None,
                 prev_monster=None):
        Object.__init__(self, x, y, name, oid=oid)
        self.blocks_sight = False
        self.blocks_movement = False

        # For items which were previously a monster.  Used for
        # resurrection, de-stoning, etc.
        self.prev_monster = prev_monster

        if use_function is None:
            if self.name == 'healing potion':
                self.use_function = spell.cast_heal
            elif self.name == 'scroll of fireball':
                self.use_function = spell.cast_fireball
            elif self.name == 'scroll of lightning':
                self.use_function = spell.cast_lightning
            elif self.name == 'scroll of confusion':
                self.use_function = spell.cast_confuse
            else:
                self.use_function = None
        else:
            self.use_function = use_function
Esempio n. 21
0
    def setup(self):
        """
            Characters from maps and objects random, run pygame, listener input
        """
        grid = Grid()
        maps = grid.loading('grid.txt')

        # Mac gyver
        macgyver = Character('grid.txt', 'M')
        #self.macgyver = macgyver

        # Guardian
        #Character('grid.txt', 'G')

        # Needle
        o_n = Object(maps)
        maps = grid.set_position('needle', (o_n.position_x, o_n.position_y),
                                 maps)

        # Ether
        o_e = Object(maps)
        maps = grid.set_position('ether', (o_e.position_x, o_e.position_y),
                                 maps)

        # Tube
        o_t = Object(maps)
        maps = grid.set_position('tube', (o_t.position_x, o_t.position_y),
                                 maps)

        self.display.init_pygame(macgyver, maps, grid)
        self.display.set_text("BEGIN")

        grid.draw(maps)
        self.display.update()
        self.display.listener()
Esempio n. 22
0
    def line_reader(self, file):
        name = False
        location = False
        velocity = False
        mass = False
        density = False

        for line in file:
            line = line.strip()

            if line != "":
                if line[0] == '#':
                    if name == True and location == True and velocity == True and mass == True and density == True:
                        self.system.new_object(
                            Object(self.name, self.location, self.velocity,
                                   self.mass, self.density))

                    name = False
                    location = False
                    velocity = False
                    mass = False
                    density = False

                    self.name = line[1:int(len(line))]
                    name = True

                elif line[0:1] != "//" or line.strip() == "":
                    word = line.split(':')

                    if word[0].strip() == "location":
                        data = word[1].split(',')
                        self.location = [
                            float(data[0].rstrip()),
                            float(data[1].rstrip()),
                            float(data[2].rstrip())
                        ]
                        location = True

                    elif word[0].strip() == "velocity":
                        data = word[1].split(',')
                        self.velocity = [
                            float(data[0].rstrip()),
                            float(data[1].rstrip()),
                            float(data[2].rstrip())
                        ]
                        velocity = True

                    elif word[0].strip() == "mass":
                        self.mass = float(word[1].rstrip())
                        mass = True

                    elif word[0].strip() == "density":
                        self.density = float(word[1].rstrip())
                        density = True

        if name == True and location == True and velocity == True and mass == True and density == True:
            self.system.new_object(
                Object(self.name, self.location, self.velocity, self.mass,
                       self.density))
Esempio n. 23
0
    def draw(self, context):
        ###context.save()

        rows = int(self.rows)
        columns = self.columns.split(':')
        n_columns = len(columns)

        titles = self.titles.split(':')

        self.width = 0
        self.height = 0

        context = pangocairo.CairoContext(context)  # XXX
        total_width = 0

        for column in range(n_columns):
            for row in range(rows):
                layout = pangocairo.CairoContext.create_layout(context)
                fontname = self.font
                if fontname.endswith(
                    ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9")):  # XXX
                    description = fontname
                else:
                    size = int(self.size)
                    description = "%s %d" % (fontname, size)
                font = pango.FontDescription(description)
                layout.set_font_description(font)
                title = titles[column]
                layout.set_markup(title)

                if row == 0:
                    context.set_source_rgb(0.0, 0.0, 0.0)
                else:
                    context.set_source_rgb(0.75, 0.75, 0.75)

                width, height = layout.get_size()

                if columns[column] == '0':
                    width /= pango.SCALE
                    columns[column] = str(width)
                else:
                    width = int(columns[column])

                height /= pango.SCALE

                x = self.x + total_width + self.horizontal_spacing * column
                y = self.y + (self.vertical_spacing + height) * row

                context.move_to(x, y)
                context.show_layout(layout)

            self.height = (self.vertical_spacing + height) * rows

            total_width += width

        self.columns = ':'.join(columns)

        self.width = n_columns * self.horizontal_spacing - self.horizontal_spacing + total_width
        Object.draw(self, context)
Esempio n. 24
0
class Display:
    ''' Init the map and place the objects '''
    def __init__(self):
        with open('map.json', 'r') as f:
            self.map = json.load(f)
            pygame.init()
            self.needle = Object(1, 1, 'N')
            self.map = self.needle.object_dispatch(self.map)
            self.tube = Object(1, 1, 'T')
            self.map = self.tube.object_dispatch(self.map)
            self.ether = Object(1, 1, 'E')
            self.map = self.ether.object_dispatch(self.map)

    ''' Display map, convert the coordinates '''

    def display_map(self):
        self.window = pygame.display.set_mode((600, 600))
        line_index, ord = 0, 0
        for line in self.map:
            char_index, abs = 0, 0
            for char in line:
                if self.map[char_index][line_index] == 'O':
                    sprite_w =\
                        pygame.image.load("ressources/wall.png").convert()
                    self.window.blit(sprite_w, (ord, abs))
                else:
                    sprite_t =\
                        pygame.image.load("ressources/tile.png").convert()
                    self.window.blit(sprite_t, (ord, abs))
                    self.display_objects(char_index, line_index, ord, abs)
                char_index, abs = char_index + 1, abs + 40
            line_index, ord = line_index + 1, ord + 40
        pygame.display.flip()

    ''' Display objects and character on the map '''

    def display_objects(self, char_index, line_index, ord, abs):
        if self.map[char_index][line_index] == 'G':
            picture =\
                pygame.image.load("ressources/gardien.png").convert_alpha()
            self.window.blit(picture, (ord, abs))
        elif self.map[char_index][line_index] == 'N':
            picture =\
                pygame.image.load("ressources/aiguille.png").convert_alpha()
            self.window.blit(picture, (ord, abs))
        elif self.map[char_index][line_index] == 'T':
            picture =\
                pygame.image.load("ressources/tube_plastique.png").convert()
            picture.set_colorkey((255, 255, 255))
            self.window.blit(picture, (ord, abs))
        elif self.map[char_index][line_index] == 'E':
            picture =\
                pygame.image.load("ressources/ether.png").convert()
            picture.set_colorkey((1, 1, 1))
            self.window.blit(picture, (ord, abs))
        elif self.map[char_index][line_index] == 'P':
            character =\
                pygame.image.load("ressources/macgyver.png").convert_alpha()
            self.window.blit(character, (ord, abs))
Esempio n. 25
0
    def draw(self, context):
        type = self.get_property('type')

        surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, int(self.width), int(self.height))

        lines = (
            ('AMD Athlon II X3 425', 34.5),
            ('Intel Celeron E3300 @ 2.50GHz', 31),
            ('AMD Athlon II X2 240', 30.7),
            ('AMD Phenom 9750 Quad-Core', 29.9),
            ('AMD Athlon 64 X2 Dual Core 6000+', 29.2),
            ('Dual-Core AMD Opteron 1216', 27.1),
            ('AMD Sempron 140', 26.3),
            ('Pentium Dual-Core E5400 @ 2.70GHz', 24.7),
            ('Intel Core i7 920 @ 2.67GHz', 19.3),
            ('Intel Core2 Quad Q8200 @ 2.33GHz', 17.7),
            ('Intel Core2 Duo E7500 @ 2.93GHz', 17.2),
            )

        options = {
            'axis': {
                'x': {
                    'ticks': [dict(v=i, label=l[0]) for i, l in enumerate(lines)],
                    'label': 'Microprocesador',
                    'rotate': 25,
                    },
                'y': {
                    'tickCount': 4,
                    'rotate': 25,
                    'label': 'Relación precio rendimiento'
                }
            },

            'legend': {
                'hide': True,
                },
            }

        chart = get_chart_from_type(surface, type, options)

        dataSet = (
            ('AMD Athlon II X3 425', ((0, 34.5), )),
            ('Intel Celeron E3300 @ 2.50GHz', ((0, 31), )),
            ('AMD Athlon II X2 240', ((0, 30.7), )),
            ('AMD Phenom 9750 Quad-Core', ((0, 29.9), )),
            ('AMD Athlon 64 X2 Dual Core 6000+', ((0, 29.2), )),
            ('Dual-Core AMD Opteron 1216', ((0, 27.1), )),
            ('AMD Sempron 140', ((0, 26.3), )),
            ('Pentium Dual-Core E5400 @ 2.70GHz', ((0, 24.7), )),
            ('Intel Core i7 920 @ 2.67GHz', ((0, 19.3), )),
            ('Intel Core2 Quad Q8200 @ 2.33GHz', ((0, 17.7), )),
            ('Intel Core2 Duo E7500 @ 2.93GHz', ((0, 17.2), )),
            )

        chart.addDataset(dataSet)
        chart.render()
        context.set_source_surface(surface, self.x, self.y)
        context.paint()
        Object.draw(self, context)
Esempio n. 26
0
    def move_left(self):
        Object.move_left(self, self.movement_speed)
        self.tile_position.move_left(self.movement_speed)

        self.arena.physics.resolve_player_collision(self, Direction.LEFT)

        self.current_face_direction = Direction.LEFT
        self.player_left_sprite.play()
Esempio n. 27
0
    def __init__(self, engine, position=(0,0,0)):
        Object.__init__(self, engine, position)
        self.engine = engine
        self.x = position[0]
        self.y = position[1]
        self.z = position[2]

        self.faces = []
Esempio n. 28
0
    def move_down(self):
        Object.move_down(self, self.movement_speed)
        self.tile_position.move_down(self.movement_speed)

        self.arena.physics.resolve_player_collision(self, Direction.DOWN)

        self.current_face_direction = Direction.DOWN
        self.player_down_sprite.play()
Esempio n. 29
0
    def draw(self, context):
        ###context.save()

        rows = int(self.rows)
        columns = self.columns.split(':')
        n_columns = len(columns)

        titles = self.titles.split(':')

        self.width = 0
        self.height = 0

        context = pangocairo.CairoContext(context) # XXX
        total_width = 0

        for column in range(n_columns):
            for row in range(rows):
                layout = pangocairo.CairoContext.create_layout(context)
                fontname = self.font
                if fontname.endswith(("0", "1", "2", "3", "4", "5", "6", "7", "8", "9")): # XXX
                    description = fontname
                else:
                    size = int(self.size)
                    description = "%s %d" % (fontname, size)
                font = pango.FontDescription(description)
                layout.set_font_description(font)
                title = titles[column]
                layout.set_markup(title)

                if row == 0:
                    context.set_source_rgb(0.0, 0.0, 0.0)
                else:
                    context.set_source_rgb(0.75, 0.75, 0.75)

                width, height = layout.get_size()

                if columns[column] == '0':
                    width /= pango.SCALE
                    columns[column] = str(width)
                else:
                    width = int(columns[column])

                height /= pango.SCALE

                x = self.x + total_width + self.horizontal_spacing * column
                y = self.y + (self.vertical_spacing + height) * row

                context.move_to(x, y)
                context.show_layout(layout)

            self.height = (self.vertical_spacing + height) * rows

            total_width += width

        self.columns = ':'.join(columns)

        self.width = n_columns * self.horizontal_spacing - self.horizontal_spacing + total_width
        Object.draw(self, context)
Esempio n. 30
0
 def _getFileAutocreate(self, realFileName):
     fileObj = self.store.find(Object, Object.realFileName == realFileName).any()
     if fileObj is None:
         fileObj = Object()
         fileObj.realFileName = realFileName
         self.store.add(fileObj)
         return fileObj
     else:
         return fileObj
Esempio n. 31
0
 def update(self, image):
     width = image.get_width()
     height = image.get_height()
     self._rImage = image.subsurface(
         Object(size=(width / 2, height)).asRect())
     self._oImage = image.subsurface(
         Object(rect=(width / 2, 0, width / 2, height)).asRect())
     self._rImage.fill(self._rColor)
     self._oImage.fill(self._oColor)
Esempio n. 32
0
 def __init__(self):
     """
     @brief Creates an EntryBox
     """
     Object.__init__(self)
     self._text = ""
     
     self._hidden = False
     self._hidden_character = '*'
Esempio n. 33
0
    def load(self, name: str):
        """load a save of environment with json compatible

        Args:
            name (str): name of the folder

        Returns:
            [type]: [description]
        """
        if name[-5:] != ".json":
            name += ".json"

        try:
            f = open(name, 'r')
            dic = json.load(f)
        except:
            print("Unable to open file, invalid file!")
            print("nom : ", name)
            return None

        try:
            drones = []
            for drone in dic['drones']:
                position = Vector(drone["position"]["x"],
                                  drone["position"]["y"])
                vitesse = Vector(drone["speed"]["vx"], drone["speed"]["vy"])
                radius = drone["radius"]
                color = (drone["color"][0], drone["color"][1],
                         drone["color"][2])
                name = drone["name"]

                drones.append(Drone(position, vitesse, radius, name, color))

            objs = []
            for obj in dic['objects']:
                points = []
                for point in obj["points"]:
                    points.append(Vector(point["x"], point["y"]))

                objs.append(Object(points))

            try:
                points = []
                for point in dic['goal']["points"]:
                    points.append(Vector(point["x"], point["y"]))
                self.goal = Object(points)

            except:
                self.goal = None

            self.objects = objs
            self.drones = drones
            self.nb_drones = len(drones)
            self.nb_objects = len(objs)
        except:
            print("invalid file type!")
            return None
Esempio n. 34
0
 def __init__(self, text=""):
     """
     @brief constructs a button with a given text.
     
     @var text: The label of the Button
     """
     self._text = text
     Object.__init__(self)
     self._forecolor = ""
Esempio n. 35
0
 def __init__(self, image, x, y):
     Object.__init__(self)
     self.image = image
     self.x, self.y = x, y
     self.rect = self.image.get_rect()
     self.rect.centerx = x
     self.rect.bottom = y
     self.dy = 0
     self.z = -y
Esempio n. 36
0
    def __init__(self):
        threading.Thread.__init__(self)
        Object.__init__(self)

        # VARS
        self.running = False  # Whether or not the schedular is running
        self.blocks = []  # blocks active
        self.player = settings.PLAYERS[settings.PLAYER]()
        self.play_advert = False
Esempio n. 37
0
 def __init__(self, *args, **keywordArgs):
     """
     The Object class is the base-class for every object in a :class:`network <Network.Network.Network>`.
     
     Any number of user-defined attributes or stimuli can be added to an object.  The connectivity of objects can also be investigated.
     """
     
     Object.__init__(self, *args, **keywordArgs)
     
     self.stimuli = []
Esempio n. 38
0
    def setUp(self):
        self.system = System(0.02)

        maa = Object("Maa", [1.4960 * (10**8) * (10**3), 0, 0], [0, 29800, 0],
                     5.974 * 10**24, 5517)
        kuu = Object("Kuu", [385400000 + 1.4960 * (10**8) * (10**3), 0, 0],
                     [0, 1023 + 29800, 0], 5 * 10**22, 3344)

        self.system.new_object(maa)
        self.system.new_object(kuu)
Esempio n. 39
0
    def __init__(self, *args, **keywordArgs):
        """
        The Object class is the base-class for every object in a :class:`network <Network.Network.Network>`.
        
        Any number of user-defined attributes or stimuli can be added to an object.  The connectivity of objects can also be investigated.
        """

        Object.__init__(self, *args, **keywordArgs)

        self.stimuli = []
Esempio n. 40
0
 def _getFileAutocreate(self, realFileName):
     fileObj = self.store.find(Object,
                               Object.realFileName == realFileName).any()
     if fileObj is None:
         fileObj = Object()
         fileObj.realFileName = realFileName
         self.store.add(fileObj)
         return fileObj
     else:
         return fileObj
Esempio n. 41
0
 def __init__(self, x, y, datadir):
     Object.__init__(self)
     self.x, self.y = rand(x - 20, x + 20), rand(y - 20, y + 20)
     color = rand(0, 2)
     self.frame = Frames(datadir, 'hit%d_6.png' %(color))
     self.step = -1
     self.delay = 0
     self.update_animation()
     self.rect = pygame.Rect(self.x, self.y, 0, 0)
     self.z = -2000
 def display_detection(self,grid):
     fig, ax = plt.subplots(1)
     ax.imshow(self.labels, cmap='nipy_spectral')
     for obj in self.objects:
         Object.display_object(obj)
         rect=patches.Rectangle((obj.grid_x-0.5,
                                 obj.grid_y-0.5),
                                 obj.grid_l, obj.grid_w,
                                 linewidth=1, edgecolor='r', facecolor='none')
         ax.add_patch(rect)
     plt.show()
Esempio n. 43
0
    def __init__(self):
        Object.__init__(self)
        self.dash = list()
        self.radius = 20

        control = Control()
        self.handler.control.append(control)
        control = Control()
        self.handler.control.append(control)

        self.block = False
Esempio n. 44
0
    def __init__(self):
        Object.__init__(self)
        self.handler.line = True
        self.dash = list()

        self.start = Point()
        self.end = Point()

        self.set_property("arrow-tip-length", 4 * 4)
        self.set_property("arrow-length", 8 * 4)
        self.set_property("arrow-width", 3 * 4)
Esempio n. 45
0
    def __init__(self):
        Object.__init__(self)
        self.dash = list()
        self.radius = 20

        control = Control()
        self.handler.control.append(control)
        control = Control()
        self.handler.control.append(control)

        self.block = False
Esempio n. 46
0
 def __init__(self, x=100, y=400):
     Object.__init__(self)
     self.normal = common.load_image("cursor.png")
     self.invisible = common.load_image("invisible.png")
     self.set_visible(False)
     self.x, self.y = x, y
     self.rect = self.normal.get_rect()
     self.rect.centerx = x
     self.rect.bottom = y
     self.dy = 0
     self.z = -y
Esempio n. 47
0
    def test_collision(self):
        crasher1 = Object("c1", [0, 0, 0], [0, 0, 0], 100, 100)
        crasher2 = Object("c2", [1, 0, 0], [0, 0, 0], 100, 100)

        self.system.new_object(crasher1)
        self.system.new_object(crasher2)

        self.system.update_objects()

        self.assertTrue(self.system.get_collision(),
                        "Collision should be True")
Esempio n. 48
0
    def __init__(self, rows=5, columns="0", titles=_("Column 1")):
        Object.__init__(self)
        self.vertical_spacing = 5
        self.horizontal_spacing = 5

        self.control = MANUAL

        self.rows = rows
        self.columns = columns
        self.titles = titles
        self.font = "Verdana"
        self.size = 16
Esempio n. 49
0
    def __init__(self, x, y, char, name, color, fighter_component, race, job, start_equipment=None):
        self.level = 1
        self.job = job
        self.race = race
        self.inventory = []
        if start_equipment is not None:
            self.inventory.append(start_equipment)
            start_equipment.equipment.is_equipped = True
            fighter_component.hp += start_equipment.equipment.max_hp_bonus
            self.job.mp += start_equipment.equipment.max_mp_bonus

        Object.__init__(self, x, y, char, name, color, blocks=True, fighter=fighter_component, race=race)
Esempio n. 50
0
class Display:
    def __init__(self):

        self.running = True

        self.rows = 10
        self.cols = 20

        # Create the display grid
        self.grid = []
        for i in range(self.rows):
            # Append a row of dots to the grid
            self.grid.append(["."] * self.cols)

        # Create a moveable object at position (5, 5)
        self.obj = Object("o", 5, 5, self)

    def process_command(self, c):
        # Process w/a/s/d inputs into directional movement
        directions = {"w": "north", "a": "west", "s": "south", "d": "east"}
        if c in directions:
            # Move in the direction specified
            self.obj.move(directions[c])

    def print_screen(self):
        clear_screen()

        # Print each row in the grid
        for row in self.grid:
            # Make sure every character in the row is a string
            char_row = [str(c) for c in row]
            # Separate each character in the row with a single space
            print(' '.join(char_row))
        print("Type `w`, `a`, `s`, `d` to move.")
        print("Type `q` to quit.")

    def run(self):

        self.print_screen()

        kb = kbhit.KBHit()

        while self.running:

            if kb.kbhit():
                c = kb.getch()
                if c == "q":  # Hit `q` to break out of the loop
                    self.running = False
                self.process_command(c)

                self.print_screen()

        kb.set_normal_term()  # Reset terminal to normal
Esempio n. 51
0
    def _create_monster(self, x, y):

        monster = None
        if libtcod.random_get_int(0, 0,
                                  100) < 80:  # 80% chance of getting an orc
            # Orc
            monster = Object(x, y, 'o', 'Orc', libtcod.desaturated_green, True)
        else:
            # Troll
            monster = Object(x, y, 'T', 'Troll', libtcod.darker_green, True)

        return monster
Esempio n. 52
0
    def draw(self, context):
        context.save()

        surface = cairo.ImageSurface.create_from_png(self.image)
        width = surface.get_width()
        height = surface.get_height()
        x, y = self.scale(context, width, height)
        context.set_source_surface(surface, self.x / x, self.y / y)

        context.paint()
        context.restore()
        Object.draw(self, context)
Esempio n. 53
0
    def __init__(self, x_pos, y_pos):
        self.width = 5
        self.height = 15
        self.velocity = []
        self.speed = 5
        self.thrusters = False
        self.velocity.append(0)
        self.velocity.append(0)

        Object.__init__(self, x_pos, y_pos, self.width, self.height,
                        self.velocity)
        self.type = "player"
Esempio n. 54
0
 def add_object(self, pk, name, value):
     ''' Create object on client (do not use this function to add object from
     a server sync) '''
     
     # Check for duplicate primary key
     if any(o.pk == pk for o in self.objects):
         print "Error creating new object on client {}: primary key {} already in use".format(self.name, pk)
     
     no = Object(pk, name, value)
     self.counter += 1
     no.lastupdate_counter = self.counter
     self.objects.append(no)
Esempio n. 55
0
    def __init__(self):
        Object.__init__(self)
        self.angle_start = 0.0
        self.angle_stop = 360.0
        self.radius_horizontal = 0
        self.radius_vertical = 0
        self.centre_x = 0
        self.centre_y = 0
        self.closed = False
        self.closed_at_centre = False

        self.handler.control.append(Control())
        self.handler.control.append(Control())
Esempio n. 56
0
 def _updateMap(self, block):
     try:
         self._tiles.setdefault(block.getType(), []).remove(block)
     except ValueError:
         pass
     self._tiles.setdefault(block.getType(), []).append(block)
     self._display.update(Surface((const.res, const.res)), block)
     self._display.update(
         self._tileset,
         Object(rect=(block.mapX * const.res, block.mapY * const.res,
                      const.res, const.res)),
         Object(rect=(0, block.getTile() * const.res, const.res,
                      const.res)))
Esempio n. 57
0
    def get_random_object(self):
        if self.snake:
            curr_head = self.snake.head
        else:
            curr_head = None

        random_object = Object(randint(0, self.grid_width - 1),
                               randint(0, self.grid_height - 1))
        while random_object == curr_head or random_object == self.apple:
            random_object = Object(randint(0, self.grid_width - 1),
                                   randint(0, self.grid_height - 1))

        return random_object
Esempio n. 58
0
File: tau.py Progetto: emitc2h/CDER
    def __init__(self, pt, eta, phi):
        """
        Constructor
        """

        ## Base class constructor
        Object.__init__(self, pt, eta, phi)

        ## Define colors for charged and neutral particles
        self.color_charged = (0.45, 0.45, 0.00)
        self.color_neutral = (0.40, 0.45, 0.50)

        # Generate the decay products
        self.generate()