def _brick(x, y, model, hits, callback): a = Sprite(model=model, pos=[x * vars.tileSize, y * vars.tileSize, 0]) a.addComponent( Collider(flag=vars.flags.platform, mask=0, tag=0, shape=sh.Rect(width=vars.tileSize, height=vars.tileSize))) a.addComponent(Info(hitsLeft=hits, callback=callback)) b = Entity() b.pos = [2, -0.5, 0] b.addComponent( Collider(flag=vars.flags.foe, mask=vars.flags.player, tag=vars.tags.bonus_brick_sensor, shape=sh.Rect(width=vars.tileSize - 4, height=1.0))) a.add(b) return a
def f(args): model = props[1] x = args[0] y = args[1] a = Sprite(model = model) a.addComponent (Collider (flag = vars.flags.platform, mask = 0, tag = 0, shape = sh.Rect(width=vars.tileSize, height=vars.tileSize))) a.pos = [x * vars.tileSize, y * vars.tileSize, 0] a.addComponent (Info(piece = props[2])) b = Entity() b.pos = [2, -0.5, 0] b.addComponent (Collider ( flag=vars.flags.foe, mask=vars.flags.player, tag = vars.tags.brick_sensor, shape = sh.Rect(width = vars.tileSize-4, height = 1.0) )) a.add(b) return a
def makeBrick(model: str, x: float, y: float): a = Sprite(model=model) a.addComponent( compo.Collider(flag=vars.flags.platform, mask=0, tag=0, shape=sh.Rect(width=vars.tileSize, height=vars.tileSize))) a.pos = [x * vars.tileSize, y * vars.tileSize] b = Entity() b.pos = [2, -0.5, 0] b.addComponent( compo.Collider(flag=vars.flags.foe, mask=vars.flags.player, tag=vars.tags.brick_sensor, shape=sh.Rect(width=vars.tileSize - 4, height=1.0))) a.add(b) return a
def makePlayer(model: str, x: float, y: float): player = Sprite(model=model, pos=[x, 0], tag='player') player.scale = 0.5 player.addComponent( compo.SmartCollider(flag=vars.flags.player, mask=vars.flags.foe | vars.flags.foe_attack, tag=vars.tags.player, castTag=vars.tags.player_attack, castMask=vars.flags.foe)) player.addComponent( compo.Controller25(mask=vars.flags.platform, depth=y, elevation=256)) player.addComponent(compo.Info(energy=5)) # maskDown = vars.flags.platform | vars.flags.platform_passthrough, # maxClimbAngle = 80, # maxDescendAngle = 80)) # speed = 75 player.addComponent(compo.Dynamics2D(gravity=vars.gravity)) stateMachine = compo.StateMachine(initialState='walk') # stateMachine.states.append (compo.SimpleState (id='warp', anim='idle')) stateMachine.states.append( compo.Walk25(id='walk', speed=200, acceleration=0.05, flipHorizontal=True, jumpvelocity=vars.jump_velocity)) stateMachine.states.append(compo.Hit25(id='attack', anim='attack')) stateMachine.states.append( compo.IsHit25(id='ishit', acceleration=0.5, anim='idle')) # stateMachine.states.append (pc.Jump(id='jump', speed=200, acceleration=0.10, flipHorizontal=True, animUp='jump', animDown='jump')) # stateMachine.states.append (pc.FoeWalk(id='demo', anim='walk', speed = 75, # acceleration=0.05, flipHorizontal=True, flipWhenPlatformEnds = False, left=1)) player.addComponent(stateMachine) player.addComponent(compo.KeyInput()) player.addComponent(compo.Follow()) baa = Entity(tag='pane') baa.addComponent( compo.ShapeGfxColor(shape=sh.Ellipse(20, 10), color=[0, 0, 0, 64])) player.add(baa) return player
def bonusBrick(model: str, x: float, y: float, callback: callable, hits: int = 1): a = Sprite(model=model, pos=[x * vars.tileSize, y * vars.tileSize, 0]) a.addComponent( compo.Collider(flag=vars.flags.platform, mask=0, tag=0, shape=sh.Rect(width=vars.tileSize, height=vars.tileSize))) a.addComponent(compo.Info(hitsLeft=hits, callback=callback)) b = Entity() b.pos = [2, -0.5, 0] b.addComponent( compo.Collider(flag=vars.flags.foe, mask=vars.flags.player, tag=vars.tags.bonus_brick_sensor, shape=sh.Rect(width=vars.tileSize - 4, height=1.0))) a.add(b) return a