def fireHitsFoe(foe: example.Wrap1, fire: example.Wrap1, x, y): example.remove(fire.id) foe.setState ('dead2', {}) s = Script() s.addAction (MoveAccelerated(v0=[50 if fire.x < foe.x else -50, 150], a=[0,vars.gravity], yStop = -32, id=foe.id)) s.addAction (RemoveEntity (id=foe.id)) example.play(s)
def f(x, y, obj = None): dial = example.get('dialogue') dial.clearText() # check if there's any script to run a = Script() node = s node.said = True for cn in node.closeNodes: s.dialogue.nodes[cn].status = 2 for an in node.activateNodes: n = s.dialogue.nodes[an] if n.status != 2: n.status = 1 #for id, d in s.dialogue.nodes.items(): # print (str(d.id) + ' ' + str(d.active)) #if s.node.nextStatus != NodeStatus.SAME: # s.node.status = s.node.nextStatus #s.node.dialogue.openNode(s.node) # check if I have a script associated to this line func = s.dialogue.id + '_'+node.id print ('check if ' + func) addCustomScript (engine.scripts.dialogues, func, a) #ds = s.script() #if ds: # a.addAction(act.RunScript(s = ds)) if s.nextId == None: print ('ending') a.addAction(scact.EndDialogue(s.dialogue.id)) else: print ('next is ' + s.nextId) s.dialogue.current = s.nextId a.addAction(scact.ResumeDialogue(s.dialogue.id)) example.play(a)
def m3(x: float, y: float): a = spr('score100', x, y) main = example.get('main') id = main.add(a) s = Script() s.addAction(act.Move(speed=100, by=[0, 64], id=id)) s.addAction(act.RemoveEntity(id=id)) example.play(s)
def citi3(): s = Script() s.addAction( RunScript( d3(sl, ['player', ('a', 11)], ['citizen', 'a:talk_e', ('_', 33), 'a:idle_e'])())) s.addAction(RunScript(citi_01())) return s
def winSlide(p: example.Wrap1, k, x, y): example.remove(k.id) p.setState('slide', {}) s = Script() p.vy = 0 s.addAction(Move(speed=50, to=[p.x, 48], tag='player')) s.addAction(SetState(tag='player', state='demo', args={'left': 0})) example.play(s)
def pipe_out(p: example.Wrap1, k, x, y): p.setState('demo', {'left': 0}) addInfo = k.getInfo()['info'] s = Script() from smb_py.funcs import gotoWorld s.addAction(Delay(sec=0.5)) s.addAction(CallFunc(gotoWorld(addInfo['world'], addInfo['pos']))) example.play(s)
def enterPipe(a: example.Wrap1): if not vars.paused and vars.currentWarp != -1: a.setState('pipe', {}) info = example.getById(vars.currentWarp).getInfo() s = Script() s.addAction(Move(speed=100, by=[0, -64], tag='player')) s.addAction(CallFunc(f=func.gotoWorld(info['world'], info['start']))) example.play(s)
def run_background_script(actor, a, b, c, d): s = Script(loop = 0) s.addAction (DelayRandom(min=a, max=b)) s.addAction (Animate(tag=actor, anim='idle_2', fwd = True, sync = True)) s.addAction (DelayRandom(min=c, max=d)) s.addAction (Animate(tag=actor, anim='idle_2', fwd = False, sync = True)) s.addAction (Animate(tag=actor, anim='idle_1', fwd = True, sync = True)) example.play(s)
def makePiece(pos, vx, vy, model, parent : example.Wrap1): a = Sprite(model = model, pos = pos) id = parent.add(a) s = Script() s.addAction (act.MoveAccelerated (id = id, v0 = [vx, vy], a = [0, 0.5*vars.gravity], yStop=0)) s.addAction (act.RemoveEntity (id = id)) # type = action.remove_object, args = { id = id1} example.play(s)
def m1(x: float, y: float): a = mushroom(x, y) main = example.get('main') id = main.add(a) s = Script() s.addAction(Move(id=id, speed=10, by=[0, 16])) s.addAction(SetState(id=id, state='walk')) example.play(s)
def m3(x: float, y: float): a = Sprite('score100', pos=[x * vars.tileSize, (y + 1) * vars.tileSize, 0]) main = example.get('main') id = main.add(a) s = Script() s.addAction(Move(speed=100, by=[0, 64], id=id)) s.addAction(RemoveEntity(id=id)) example.play(s)
def f(): s = Script() for item in dialogue: print ('tag = ' + item[0]) ist = [dialogueId[a] for a in item[1:]] print ('tag = ' + str(ist)) s.addAction (Say(lines=ist, tag=item[0], font='monkey')) return s
def playerDead(): s = Script() vars.state=0 s.addAction (act.SetState(state='dead', tag='player')) s.addAction (act.Delay(sec=1)) s.addAction (act.MoveAccelerated(v0 = [0 , 200], a= [0, vars.gravity], yStop= 0, tag='player')) s.addAction (act.RemoveEntity(tag = 'player')) s.addAction (act.CallFunc(f=restart)) example.play(s)
def f(): s = Script() s.addAction( RunScript( d3(sl, ['player', ('a', n)], ['citizen', 'a:talk_e', ('_', 29, 30, 31, 32), 'a:idle_e'])())) s.addAction(RunScript(citi_01())) return s
def f(): vars.warp_func = None s = Script() s.addAction (act.SetState(tag='player', state='warp')) s.addAction (act.Move(speed=50, by =[0,-64], tag='player')) if newCamBounds: s.addAction (act.ChangeCamBounds('maincam', newCamBounds[0], newCamBounds[1], newCamBounds[2], newCamBounds[3])) s.addAction (act.Move(speed=0, to = [warpTo[0] * vars.tileSize, warpTo[1]*vars.tileSize], immediate= True, tag = 'player')) s.addAction (act.SetState(tag='player', state='walk')) example.play(s)
def f(): print('ciao' + itemId) s = Script() status = 'open' if open else 'closed' s.addAction(CallFunc(f=setvar(Data.items[itemId]['anim'], status))) # set corresponding variables #sv(Data.items[itemId]['anim'], status) print('set to ' + status) s.addAction(Animate(anim=status, tag=itemId)) return s
def gotoNext(p: example.Wrap1, k: example.Wrap1, x, y): #print (k.getInfo()) addInfo = k.getInfo()['info'] #print('world is ' + ['world']) example.remove(k.id) p.setActive(False) s = Script() from smb_py.funcs import gotoWorld s.addAction(Delay(sec=0.5)) s.addAction(CallFunc(gotoWorld(addInfo['world'], addInfo['pos']))) example.play(s)
def goombaResponse (player : example.Wrap1, goomba : example.Wrap1, x, y): if vars.invincibility: return print ('qui') if (player.getState() == 'jump' and y > 0 and abs(x) < 0.01): s = Script() player.vy = 300 s.addAction (act.SetState (state = 'dead', id = goomba.id() )) example.play(s) print ('ciao') else: playerHitByEnemy(player)
def m2(x: float, y: float): print ('x='+ str(x)) def score(): m3(x, y+1) a = Sprite ('flyingcoin', pos=[x * vars.tileSize, (y+1)*vars.tileSize, 0]) main = example.get('main') id = main.add(a) s = Script() s.addAction(MoveAccelerated(v0 = [0, 100], a = [0, -100], yStop = (y*vars.tileSize) +16, id = id)) s.addAction(RemoveEntity(id=id)) s.addAction(CallFunc(f = score)) example.play(s)
def downgradePlayer(): vars.state -= 1 if vars.state < 0: playerDead() else: vars.invincibility = True pl = example.get('player') pl.setModel(vars.stateInfo[vars.state]) s = Script() s.addAction (act.Blink (duration=5, blink_duration=0.2, id=pl.id)) s.addAction (act.CallFunc (f = resetInvincible)) example.play(s)
def g(): s = Script() color_player = Data.items[State.player]['text_color'] color_other = Data.items[other_id]['text_color'] for item in dialogue: tag = item[0] pos = pos_player if tag == 'player' else pos_other color = color_player if tag =='player' else color_other for line in item[1:]: print ('adding action msg ' + str(pos) + ' ' + dialogueLines[line]) s.addAction (Msg(text=dialogueLines[line], font='monkey', pos=pos, color = color)) return s
def f(x, y, obj): desc = Data.items[id] pos = desc.get('pos', [0, 0, 0]) goto = desc.get('goto') dir = goto.get('dir', None) gnode = goto.get('node', 'walkarea') Data.putItem(State.player, goto['room'], gv(goto['pos']), gnode) if dir is not None: Data.items[State.player]['dir'] = dir s = Script('_main') s.addAction(Walk(pos=pos, tag='player')) s.addAction(ChangeRoom(room=goto['room'])) example.play(s)
def f(): print ('CIAO +'+ worldId + ';;;' + str(startLocation)) vars.invincibility = False # Don't reset energy! This only should be done after player dies! #vars.energy = vars.init_energy # Important! Reset these or otherwise you will get runtime errors! vars.currentWarp = -1 vars.start_pos = startLocation s = Script() s.addAction (act.ChangeRoom (worldId)) example.play(s)
def brickResponse (player : example.Wrap1, brick : example.Wrap1, x, y): b = brick.parent() brick_id = b.id() if vars.state == 0: s = Script() ystop = b.y() s.addAction (act.MoveAccelerated (v0 = [0, 50], a = [0, 0.5 * vars.gravity], yStop = ystop, id = brick_id)) example.play(s) else: print ('removing ' + str(brick_id)) example.remove(brick_id) m = example.get('main') makePiece(pos = [b.x(), b.y(), 1], vx = 60, vy = 180, model ='brickpiece', parent=m) makePiece(pos = [b.x(), b.y(), 1], vx = -60, vy = 180, model ='brickpiece', parent=m) makePiece(pos = [b.x(), b.y(), 1], vx = 120, vy = 120, model ='brickpiece', parent=m) makePiece(pos = [b.x(), b.y(), 1], vx = -120, vy = 120, model ='brickpiece', parent=m)
def koopaResponse (player : example.Wrap1, koopa : example.Wrap1, x, y): if koopa.getState() == 'hide': if (player.getState() == 'jump' and y > 0 and abs(x) < 0.01): player.vy = 300 koopa.move(-10 * x, 0, 0) left = 0 if (player.x() <koopa.x()) else 1 s = Script() s.addAction (act.SetState(state='walk2', id=koopa.id(), args = {'left': left})) example.play(s) else: if (player.getState() == "jump" and y > 0 and abs(x) < 0.01): player.vy = 300 s = Script() s.addAction (act.SetState(state='hide', id=koopa.id())) example.play(s) else: playerHitByEnemy(player)
def flag(p, h): p.vx = 0 p.vy = 0 example.remove(h.id()) flag = example.get('flag') s = Script() s.addAction(act.SetState (state = 'warp', tag='player', args = {'anim': 'slide'}), id = 0) s.addAction (act.Move (speed = 80, by = [0, -(flag.y()-h.y())], tag='flag'), after= [0]) s.addAction (act.Move (speed = 80, to = [p.x(), h.y()], tag='player'), after= [0]) s.addAction (act.SetState(tag='player', state='demo', args = { 'left': 0 })), #s.addAction (act.SetState (state='walk', tag='player')) example.play(s)
def koopaResponse (player : example.Wrap1, koopa : example.Wrap1, x, y): if koopa.getState() == 'hide': koopa.killScripts() if (player.getState() == 'jump' and y > 0 and abs(x) < 0.01): player.vy = 300 koopa.move(-10 * x, 0, 0) left = 0 if (player.x <koopa.x) else 1 s = Script() s.addAction (act.SetState(state='walk2', id=koopa.id, args = {'left': left})) koopa.play(s) else: if (player.getState() == "jump" and y > 0 and abs(x) < 0.01): player.vy = 300 s = Script() s.addAction (act.SetState(state='hide', id=koopa.id)) s.addAction (act.Delay(sec=2)) s.addAction (act.Blink(duration=2,blink_duration=0.2,id=koopa.id)) s.addAction (act.SetState(state='walk', id = koopa.id)) koopa.play(s) else: playerHitByEnemy(player)
def playerIsHit(player: example.Wrap1, foe: example.Wrap1, x, y): # decrease foe energy #info = player.getInfo() #info['energy'] -= 1 vars.energy -= 1 func.updateEnergy() if vars.energy <= 0: x = player.x() y = player.y() vars.lives -= 1 func.updateLives() example.remove(player.id()) s = Script() s.addAction(act.Delay(sec=1)) s.addAction(act.CallFunc(f=createPlayer(x, y))) s.addAction(act.CallFunc(f=restart)) example.play(s) else: player.setState('ishit', {}) vx = 200 if foe.x() < player.x() else -200 if player.flipx: vx *= -1 player.vx = vx print('ciao')
def collide_with_kitchen_trap(): print('ciappo') s = Script() s.addAction(AddEntity(buildItem(id='seagull'), 'main')) s.addAction(Animate(anim='fly', tag='seagull', sync=True)) s.addAction(Animate(anim='eat', tag='seagull')) example.play(s)
def cippo(): print('ciappo') example.get('w1').setActive(False) s = Script() s.addAction(SetState(tag='player', state='pipe')) s.addAction(Move(tag='player', speed=50, by=[0, 64])) s.addAction(SetState(tag='player', state='walk')) example.play(s)