Пример #1
0
    def __init__(self, colors, city):
        frames.Frame.__init__(self, colors)

        owmkey = open("owmkey", "r")
        self.__owmApiCall = ('http://api.openweathermap.org/data/2.5/weather?id=' \
                              + city + '&APPID=' + owmkey.read()).split()[0]
        owmkey.close()

        self.weatherLastUpdate = datetime.datetime.now()

        titleRect = shapes.Rect((0, 0), (frames.WIDTH, frames.HEIGHT // 4),
                                "black", 0, 0)
        sideTable = shapes.Table((0, frames.HEIGHT // 4), (frames.WIDTH // 3, frames.HEIGHT), \
                             "black", 255, 0, 2, 6)
        mainRect = shapes.Rect((frames.WIDTH // 3, frames.HEIGHT // 4), \
                            (frames.WIDTH, (3 * frames.HEIGHT) // 4), "black", 255, 0)
        bottomRect = shapes.Rect((frames.WIDTH // 3, (3 * frames.HEIGHT) // 4), \
                            (frames.WIDTH, frames.HEIGHT), "black", 255, 0)
        city = shapes.Text('City', (frames.WIDTH // 2, 23), "black", 25, 255)
        date = shapes.Text('Date: ', (frames.WIDTH // 2, 55), "black", 25, 255)
        temp = shapes.Text('Temperature: ', (225, frames.HEIGHT // 4 + 30),
                           "black", 24, 0)
        clouds = shapes.Text('Clouds: ', (200, 200), "black", 20, 0)
        weather = shapes.Text('weatherDesc', (335, 200), "black", 20, 0)
        weatherMain = shapes.Picture((frames.WIDTH - 160, frames.HEIGHT // 4 - 20), \
                               (frames.WIDTH, frames.HEIGHT // 4 + 160 - 20), \
                               "black", 0, 0, "OWM/10d_black", "OWM/10d_red")
        tempSym = shapes.Picture((frames.WIDTH // 3, frames.HEIGHT // 4 + 10), \
                                 (frames.WIDTH // 3 + 50, frames.HEIGHT // 4 + 50 + 10), \
                                 "black", 0, 0, "Icons/temp_black", "Icons/temp_red")

        # setup texts, last 6 are placeholders
        sideTable.addShapes([shapes.Picture((0,0), (50,50), "black", 0, 0, \
                             "Icons/sunrise_black", "Icons/sunrise_red"), \
                           shapes.Picture((0, 0), (50, 50), "black", 0, 0, \
                             "Icons/sunset_black", "Icons/sunset_red"), \
                           shapes.Picture((0, 0), (50, 50), "black", 0, 0, \
                             "Icons/pressure_black", "Icons/pressure_red"), \
                           shapes.Picture((0, 0), (50, 50), "black", 0, 0, \
                             "Icons/humidity_black", "Icons/humidity_red"), \
                           shapes.Picture((0, 0), (50, 50), "black", 0, 0, \
                             "Icons/windspeed_black", "Icons/windspeed_red"), \
                           shapes.Picture((0, 0), (50, 50), "black", 0, 0, \
                             "Icons/winddir_black", "Icons/winddir_red"), \
                           shapes.Text('sunr', (0,0), "black", 16, 0), \
                           shapes.Text('suns', (0,0), "black", 16, 0), \
                           shapes.Text('press', (0,0), "black", 16, 0), \
                           shapes.Text('humid', (0,0), "black", 16, 0), \
                           shapes.Text('win', (0,0), "black", 16, 0), \
                           shapes.Text('n/a', (0,0), "black", 16, 0)])

        sideTable.addBackground("black", 255, 255)

        self.addShapes([titleRect, sideTable, mainRect, bottomRect, city, date, \
                                   temp, clouds, weather, weatherMain, tempSym])

        self.updateWeather()
Пример #2
0
 def f(*args):
     key = args[0]
     desc = args[1]
     cio = desc.get('create_if_owned', False)
     if (not cio) and vars.someone_owns(key):
         # item is in inventory. don't create it
         return None
     pos = desc.get('pos')
     model = desc.get('model', None)
     #text = monkey.engine.read(desc.get('text'))
     s = None
     if model:
         anim = monkey.engine.read(desc.get('anim', None))
         s = entity.Sprite(model=model, pos=pos, anim= anim)
     else:
         s = entity.Entity(pos = pos)
     #s.tag = desc.get('tag', None)
     s.tag= key
     # if a size is provided, add a hotspot
     size = desc.get('size', None)
     if size:
         prio = desc.get('priority', 0)
         s.add_component(compo.HotSpot(shape=shapes.Rect(width=size[0], height=size[1]), priority=prio,
                                       onenter=func.hover_on(key),
                                       onleave=func.hover_off(key),
                                       onclick=func.prova()))
     return s
Пример #3
0
 def f(*args):
     shape = None
     tile_set_id = kwargs['id']
     tile_set = vars.tile_data['tile_sets'][tile_set_id]
     pos = makePos2(*args)
     sheet_id = tile_set['sheet']
     sheet = vars.tile_data['tile_sheets'][sheet_id]
     width = tile_set['size'][0]
     height = tile_set['size'][1]
     solid = tile_set['solid']
     data = tile_set['data']
     e = entity.Entity(pos=pos)
     e.add_component(
         comp.TiledGfx(tile_sheet=sheet['file'],
                       sheet_size=sheet['sheet_size'],
                       tile_data=data,
                       width=width,
                       height=height,
                       size=vars.tile_size))
     if solid:
         shape = sh.Rect(width=width * vars.tile_size,
                         height=height * vars.tile_size)
         e.add_component(
             comp.Collider(flag=vars.flags.platform,
                           mask=1,
                           tag=1,
                           shape=shape))
     return e
Пример #4
0
 def make_trunk(self):
     trunk_height = self.height * .1
     trunk_width = self.width / 3
     x = self.pos[0]
     y = self.pos[1] + trunk_height / 2
     r = shapes.Rect((x, y), trunk_width, trunk_height)
     self.trunk = Component(r, self.trunk_color, False)
Пример #5
0
 def make_walls(self):
     height = self.height * .6
     width = self.width * .75
     offset = (0, height / 2)
     rect = shapes.Rect(self.pos, width, height, offset)
     wall = Component(rect, self.wall_color)
     self.components.append(wall)
Пример #6
0
    def __init__(self, colors):
        frames.Frame.__init__(self, colors)

        textfile = open("sets.txt", "r")  # later use sqlite db
        setArray = textfile.read().split('\n')
        textfile.close()
        sets = []

        titleHeight = 60

        table = shapes.Table((0, titleHeight+1), (frames.WIDTH - 1, frames.HEIGHT - 1), \
                              "black", 255, 0, 3, 10)

        titleRect = shapes.Rect((0, 0), (frames.WIDTH, titleHeight), "red", 0,
                                0)
        title = shapes.Text('Liegestuetz', titleRect.getCenter(), "red", \
                            titleHeight // 3 * 2, 255)

        for i in range(0, len(setArray) - 1):
            sets.append(shapes.Text(setArray[i], (0,0), "black", \
                                    (frames.HEIGHT - titleHeight) // 15, 0))
            table.addShape(sets[i])

        table.addBackground("black", 255, 0)

        table.invertCells(range(0, 6))
        table.swapCells([5])

        # add shapes to training frame
        self.addShape(titleRect)
        self.addShape(title)
        self.addShape(table)
Пример #7
0
    def __init__(self, function, args, pos, label_name, width, height, color,
                 border_color, hover_color, label_color, label_hover_color):
        self.function = function
        self.args = args
        self.label_name = label_name
        self.pos = pos
        self.width = width
        self.height = height
        self.color = color
        self.border_color = border_color
        self.hover_color = hover_color
        self.label_color = label_color
        self.label_hover_color = label_hover_color
        self.shape = shapes.Rect(self.pos, self.width, self.height)

        self.num_points = len(self.shape.triangular_points) // 2
        self.num_border_points = len(self.shape.lines_points) // 2
        self.vertices = ("v2f", self.shape.triangular_points)
        self.border_vertices = ("v2f", self.shape.lines_points)

        self.vertices_colors = (f"c{len(self.color)}B",
                                self.color * self.num_points)

        self.border_vertices_colors = (f"c{len(self.border_color)}B",
                                       self.border_color *
                                       self.num_border_points)
Пример #8
0
 def make_door(self):
     height = self.height * .4
     width = self.width * .2
     offset = (0, height / 2)
     rect = shapes.Rect(self.pos, width, height, offset)
     door = Component(rect, self.door_color, False)
     self.components.append(door)
Пример #9
0
 def f(*args):
     desc = args[1]
     pos = desc.get('pos')
     size = desc.get('size')
     s = entity.Entity(pos=pos)
     fu = getattr(scripts.actions, desc.get('func'))
     s.add_component(compo.HotSpot(shape=shapes.Rect(width=size[0], height=size[1]), onclick=fu))
     return s
Пример #10
0
 def f(*args):
     desc = args[1]
     pos = desc.get('pos')
     size = desc.get('size')
     s = entity.Entity(pos=pos)
     s.add_component(compo.Collider(flag=vars.Collision.Flags.other, mask=vars.Collision.Flags.player,
                                    tag=vars.Collision.Tags.trap, shape=shapes.Rect(width=size[0],height=size[1]),debug=True))
     s.add_component(compo.Info(on_enter=desc.get('on_enter', None), on_leave=desc.get('on_leave', None)))
     return s
Пример #11
0
    def f(*args):
        pos = makePos(*args)
        # coords of the top left tile. if (x, y) is the top left
        # then (x+1, y) is the top right, and (x, y+1) and (x+1, y+1)
        # the left and right walls of the pipe.
        sheet = vars.tile_data['tile_sheets']['main']
        tl = kwargs.get('top_left')
        height = args[3]
        data = [tl[0], tl[1] + 1, tl[0] + 1, tl[1] + 1] * (height - 1)
        data.extend([tl[0], tl[1], tl[0] + 1, tl[1]])
        e = entity.Entity(pos=pos)
        e.add_component(
            comp.TiledGfx(tile_sheet=sheet['file'],
                          sheet_size=sheet['sheet_size'],
                          tile_data=data,
                          width=2,
                          height=height,
                          size=vars.tile_size))
        shape = sh.Rect(width=2 * vars.tile_size,
                        height=height * vars.tile_size)
        e.add_component(
            comp.Collider(flag=vars.flags.platform, mask=1, tag=1,
                          shape=shape))
        foe = kwargs.get('foe', None)
        exit = kwargs.get('exit', None)
        if foe:
            foe_tag = monkey.engine.get_next_tag()
            pct = 1
            if exit:
                if exit not in vars.disable_update_on_start:
                    vars.disable_update_on_start[exit] = []
                vars.disable_update_on_start[exit].append(foe_tag)
                pct = 0.5
            p = plant(model=foe, pct=pct)(1, height, -0.1)
            p.tag = foe_tag
            plant_id = e.add(p)
            sensor = entity.Entity(pos=(vars.tile_size,
                                        height * vars.tile_size))
            size = (8.0, 0.4, 0.0)
            sensor.add_component(
                comp.Collider(debug=True,
                              flag=vars.flags.foe,
                              mask=vars.flags.player,
                              tag=vars.tags.generic_hotspot,
                              shape=sh3d.AABB(size=size,
                                              offset=(-size[0] * 0.5, 0.0,
                                                      0.0))))
            sensor.add_component(
                comp.Info(on_enter=freeze_plant(p.tag, False),
                          on_leave=freeze_plant(p.tag, True)))
            e.add(sensor)
        warp_info = kwargs.get('warp', None)
        if warp_info:
            w = warp()(1, height, 0, warp_info[0], warp_info[1])
            e.add(w)

        return e
Пример #12
0
 def generate_background(self):
     self.shape = shapes.Rect((self.width / 2, self.height / 2), self.width,
                              self.height)
     self.num_points = len(self.shape.triangular_points) // 2
     self.background_vertices = ("v2f", self.shape.triangular_points)
     self.background_vertices_colors = (f"c4B",
                                        self.color * self.num_points)
     self.background = self.batch.add(self.num_points, GL_TRIANGLES, None,
                                      self.background_vertices,
                                      self.background_vertices_colors)
Пример #13
0
    def __init__(self, colors, programName):
        frames.Frame.__init__(self, colors)
        # plan: sqlite db with marking of last performed exercise, then fill
        # with current tbd exercises for the week, swipe down for done
        self.__programName = programName

        titleRect = shapes.Rect((0, 0), (frames.WIDTH, frames.HEIGHT // 8),
                                "red", 0, 0)
        titleText = shapes.Text("Big 6", titleRect.getCenter(), "red", 24, 255)
        table = shapes.Table((0, frames.HEIGHT // 8 + 1), (frames.WIDTH - 1, frames.HEIGHT - 1), \
                             "black", 255, 0, 5, 6)

        table.addShapes([shapes.Picture((0, 0), (39, 39), "black", 0, 0, \
                         "Training/squats_black", "Training/squats_red"), \
                         shapes.Picture((0, 0), (39, 39), "black", 0, 0, \
                         "Training/handstand_black", "Training/handstand_red"), \
                         shapes.Picture((0, 0), (39, 39), "black", 0, 0, \
                         "Training/legraise_black", "Training/legraise_red"), \
                         shapes.Picture((0, 0), (39, 39), "black", 0, 0, \
                         "Training/bridge_black", "Training/bridge_red"), \
                         shapes.Picture((0, 0), (39, 39), "black", 0, 0, \
                         "Training/pushups_black", "Training/pushups_red"), \
                         shapes.Picture((0, 0), (39, 39), "black", 0, 0, \
                         "Training/pullup_black", "Training/pullup_red") \
                        ])
        table.addShape(shapes.Text("1 floor", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("1 head ", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("1 tucks", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("1 short", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("1 wall ", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("0 dbell", (0, 0), "black", 14, 0))

        table.addShape(shapes.Text("25,25,25", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("30 sec.", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("12,12,7", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("12,12,12", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("15,10,0", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("12,12,0", (0, 0), "black", 14, 0))

        table.addShape(shapes.Text("30,30,30", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("40 sec.", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("14,14,10", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("14,14,14", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("15,15,0", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("14,14,0", (0, 0), "black", 14, 0))

        for i in range(0, 1):
            table.addShape(shapes.Text("50,50,50", (0, 0), "red", 14, 0))
            table.addShape(shapes.Text("2 min.", (0, 0), "red", 14, 0))
            table.addShape(shapes.Text("40,40,40", (0, 0), "red", 14, 0))
            table.addShape(shapes.Text("50,50,50", (0, 0), "red", 14, 0))
            table.addShape(shapes.Text("50,50,50", (0, 0), "red", 14, 0))
            table.addShape(shapes.Text("40,40,40", (0, 0), "red", 14, 0))

        self.addShapes([titleRect, titleText, table])
Пример #14
0
 def f(*args):
     pos = makePos2(*args)
     a = entity.Entity(pos=pos)
     print('DDD')
     a.add_component(
         comp.Collider(flag=vars.flags.platform,
                       mask=vars.flags.player,
                       tag=1,
                       shape=sh.Rect(width=1, height=16 * vars.tile_size)))
     print('DDE')
     return a
Пример #15
0
 def f(*args):
     color = kwargs.get('color')
     a = entity.Entity(pos=(args[0], args[1], args[2]))
     a.add_component(
         comp.ShapeGfxColor(shape=sh.Rect(256, 256), color=color)
     )  #fill=sh.SolidFill(r=color[0], g=color[1], b=color[2])))
     a.add_component(
         comp.Parallax(cam='maincam',
                       factor=[1, 1],
                       campos0=[128, 128],
                       pos0=[0, 0]))
     return a
Пример #16
0
 def __init__(self, pos, width, height, parent):
     self.pos = pos
     self.width = width
     self.height = height
     self.objects = set()
     self.border_color = [100, 100, 100, 0]
     self.shape = shapes.Rect(self.pos, self.width, self.height)
     self.num_points = len(self.shape.lines_points) // 2
     self.vertex_list = parent.batch.add(
         self.num_points, pyglet.gl.GL_LINES, None,
         ("v2f", self.shape.lines_points),
         ("c4B", self.border_color * self.num_points))
Пример #17
0
 def f(*args):
     pos = makePos(*args)
     w = args[3]
     h = args[4]
     a = entity.Entity(pos=pos)
     img = kwargs.get('image', None)
     if img:
         a.add_component(comp.Gfx(image=img, repeat=[w, h]))
     a.add_component(
         comp.Info(bounds=[0, 0, w * vars.tile_size, h * vars.tile_size]))
     a.add_component(
         comp.Collider(flag=vars.flags.platform,
                       mask=vars.flags.player,
                       tag=1,
                       shape=sh.Rect(width=w * vars.tile_size,
                                     height=h * vars.tile_size)))
     return a
Пример #18
0
    def __init__(self, colors):
        frames.Frame.__init__(self, colors)

        frameBackground = shapes.Rect((0, 0), (399, 299), "black", 0, 0)
        whiteEllipse = shapes.Ellipse((-200, -300), (600, 200), 30, 150,
                                      "black", 255, 255)
        name = shapes.Text("E-VI", (200, 75), "black", 35, 0)
        mainText = shapes.Text("E-Ink Visualizer of Information", (200, 120),
                               "black", 18, 0)
        usage = shapes.Text("Usage:      swipe left/right", (200, 230),
                            "black", 16, 255)
        usage2 = shapes.Text("            swipe   up/down", (200, 256),
                             "black", 16, 255)
        circle = shapes.Ellipse((300, -100), (500, 100), 0, 180, "red", 0, 0)
        version = shapes.Text(frames.VERSION, (360, 35), "red", 20, 255)

        self.addShapes([frameBackground, whiteEllipse, name, mainText, \
                                  usage, usage2, circle, version])
Пример #19
0
def _brick(x, y, model, hits, callback):
    pos = makePos2(x, y)
    a = entity.Sprite(model=model, pos=pos)
    a.add_component(
        comp.Collider(flag=vars.flags.platform,
                      mask=0,
                      tag=0,
                      shape=sh.Rect(width=vars.tile_size,
                                    height=vars.tile_size)))
    a.add_component(comp.Info(hitsLeft=hits, callback=callback))
    b = entity.Entity()
    b.pos = (2, -0.5, 0)
    b.add_component(
        comp.Collider(flag=vars.flags.foe,
                      mask=vars.flags.player,
                      tag=vars.tags.bonus_brick_sensor,
                      debug=True,
                      shape=sh3d.AABB(size=(vars.tile_size - 4, 1, 0))
                      #shape=sh.Rect(width=vars.tile_size - 4, height=1.0)
                      ))
    a.add(b)
    return a
Пример #20
0
 def f(*args):
     key = args[0]
     is_player = key == vars.current_player
     desc = args[1]
     model = desc.get('model', None)
     text_color = monkey.engine.read(desc.get('text_color', [255, 255, 255, 255]))
     #text_color =
     text_offset = desc.get('text_offset', [0, 60])
     pos = desc.get('pos')
     tag = desc.get('tag', key)
     s = None
     dir = desc.get('dir', 's')
     if model:
         s = entity.Sprite(model=model, pos=pos, tag='player' if is_player else tag)
         s.add_component(compo.Collider(debug=True, flag=vars.Collision.Flags.player, mask=vars.Collision.Flags.other,
                                    tag=vars.Collision.Tags.player, shape=shapes.Rect(width=8, height=2, offset=[-4, 0])))
         if is_player:
             s.add_component(compo.Follow())
     else:
         s = entity.Entity(pos=pos, tag='player' if is_player else tag)
     s.add_component(scumm.components.CharacterController(dir=dir, speed=vars.speed, text_color=text_color, text_offset=text_offset))
     return s
Пример #21
0
 def f(*args):
     model = kwargs.get('model')
     piece = kwargs.get('piece')
     pos = makePos2(*args)
     a = entity.Sprite(model=model, pos=pos)
     a.add_component(
         comp.Collider(flag=vars.flags.platform,
                       mask=0,
                       tag=0,
                       shape=sh.Rect(width=vars.tile_size,
                                     height=vars.tile_size)))
     a.add_component(comp.Info(piece=piece))
     b = entity.Entity()
     b.pos = (2, -0.5, 0)
     b.add_component(
         comp.Collider(flag=vars.flags.foe,
                       mask=vars.flags.player,
                       tag=vars.tags.brick_sensor,
                       shape=sh3d.AABB(size=(vars.tile_size - 4, 1, 1))
                       #shape=sh.Rect(width=vars.tile_size-4, height=1.0)
                       ))
     a.add(b)
     return a
Пример #22
0
    def __init__(self, colors):
        frames.Frame.__init__(self, colors)
        self.__data = getIC()

        titleRect = shapes.Rect((0, 0), (frames.WIDTH, frames.HEIGHT // 4),
                                "black", 0, 0)
        title = shapes.Text('Inner Climate', (frames.WIDTH // 2, 23), "black",
                            25, 255)
        mainTable = shapes.Table((0, frames.HEIGHT // 4), (frames.WIDTH, frames.HEIGHT), \
                             "black", 255, 0, 2, 2)

        #self.addShape(shapes.Text("TBD", (200, 150), "black", 0, 0))
        mainTable.addShapes([shapes.Picture((0, 0), (0, 0), \
                                 "black", 0, 0, "Icons/temp_black", "Icons/temp_red"), \
                        shapes.Picture((0, 0), (0, 0), "black", 0, 0, \
                                 "Icons/humidity_black", "Icons/humidity_red"), \
                        shapes.Text('temp', (0,0), "black", 16, 0), \
                        shapes.Text('press', (0,0), "black", 16, 0)])

        mainTable.addBackground("black", 255, 255)

        self.addShapes([titleRect, title, mainTable])

        self.updateInnerClimate()
Пример #23
0
import shapes

r = shapes.Rect(10, 20)
print(r)
print(r * 3)
print(r)

print(4 * r)