def f(*args): # the first argument is the callback function # the second, if present, is the model model = kwargs.get('model', None) callback = kwargs.get('func') info = kwargs.get('info', None) pos = makePos2(*args) if model is None: a = entity.Entity(pos=pos) size = [args[2] * vars.tile_size, args[3] * vars.tile_size, 0] a.add_component( comp.Collider(debug=True, flag=vars.flags.foe, mask=vars.flags.player, tag=vars.tags.key, shape=sh3d.AABB(size=size))) a.add_component( comp.Info(func=callback, info=info, args=args, bounds=[0, 0, size[0], size[1]])) else: a = entity.Sprite(model=model, pos=pos) a.add_component( comp.SmartCollider(debug=True, flag=vars.flags.foe, mask=vars.flags.player, tag=vars.tags.key)) a.add_component(comp.Info(func=callback, info=info, args=args)) return a
def f(*args): ym = kwargs.get('y_min') y0 = kwargs.get('y_min_goto') wa: WalkAreaInfo = vars.walk_areas[y0[0]] ymg = wa.transform(y0[1:]) print('y m goto = ' + str(ymg)) yM = kwargs.get('y_max') y1 = kwargs.get('y_max_goto') wa: WalkAreaInfo = vars.walk_areas[y1[0]] yMg = wa.transform(y1[1:]) print('y M goto = ' + str(yMg)) x0 = args[0] depth_y = args[2] * math.sqrt(2.0) y0 = args[1] - args[2] z0 = -depth_y pos = (x0, y0, z0) e = entity.Entity(pos=pos) e.add_component( comp.Collider(debug=True, shape=sh3d.AABB(size=(args[3], args[4], args[5])), flag=vars.flags.foe, mask=vars.flags.player, tag=vars.tags.ladder)) e.add_component( comp.Info(x=522, y_min=ym, y_max=yM, y_min_goto=ymg, y_max_goto=yMg)) return e
def f(*args): pos = (args[0], args[1], args[2]) width = args[3] height = args[4] depth = args[5] offset = (0, 0, 0) if len(args) > 6: offset = (args[6], args[7], args[8]) color = kwargs.get('color', [1, 1, 1, 1]) e = entity.Entity(pos=pos) shape = sh3d.AABB(size=(width, height, depth), offset=offset) e.add_component(comp.ShapeGfxColor(shape=shape, color=color)) e.add_component( comp.Collider(shape=shape, flag=vars.flags.platform, mask=0, tag=vars.tags.platform)) tx_top = kwargs.get('top', None) tx_front = kwargs.get('front', None) if tx_top: e.add( make_plat( glm.vec3(0, height, depth) + offset, (width, depth), tx_top)) if tx_front: e.add( make_wall( glm.vec3(0, 0, depth) + offset, (width, height), tx_front)) #e.add(make_wall(offset + glm.vec3(0, 0, depth), (width, height), '2')) #e.add(make_wall(offset + glm.vec3(width, 0, depth), (depth, height), '2', 90)) return e
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
def f(*args): pos = makePos(*args) pin = entity.Entity(pos=pos, tag=kwargs.get('tag', None)) pin.add_component( comp.Collider(debug=True, flag=vars.flags.foe, mask=vars.flags.player, tag=vars.tags.warp, shape=sh3d.AABB(size=(4, 2, 0), offset=(-2, 0, 0)))) pin.add_component( comp.Info(world=args[3], start=args[4], bounds=[0, 0, 4, 2])) return pin
def f(*args): x0 = args[0] depth_y = args[2] * math.sqrt(2.0) y0 = args[1] - args[2] z0 = -depth_y pos = (x0, y0, z0) e = entity.Entity(pos=pos) e.add_component( comp.Collider(debug=True, shape=sh3d.AABB(size=(args[3], args[4], args[5] * sqrt2)), flag=vars.flags.foe, mask=vars.flags.player, tag=vars.tags.spawn)) e.add_component(comp.Info(enemies=args[6])) return e
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
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