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(player, hotspot): s = Script() s.addAction (act.SetState(tag='player', state='demo', args = { 'left': 0 })), s.addAction (act.Delay (sec=1)) s.addAction (act.SetState(tag='player', state='warp')) 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.Move(speed=50, by =[0, 64], tag='player')) s.addAction (act.SetState(tag='player', state='walk')) example.play(s)
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': 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 m1(x: float, y: float): a = mushroom(x, y) main = example.get('main') id = main.add(a) s = Script() s.addAction(act.Move(id=id, speed=10, by=[0, 16])) s.addAction(act.SetState(id=id, state='walk')) example.play(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 goombaResponse (player : example.Wrap1, goomba : example.Wrap1, x, y): 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 )) s.addAction (act.Delay (sec = 2)) s.addAction (act.RemoveEntity (id=goomba.id)) example.play(s) else: playerHitByEnemy(player)
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 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 playerHitByEnemy(player : example.Wrap1): # if Mario is hit by enemy, what happens depends on whether mario is supermario or not #local marioInfo = player:getinfo() #local supermario = marioInfo.supermario if vars.state > 0: setPlayer(0) vars.invincibility = True # marioInfo.invincible = true # factory.mario.change_state(player, 1) # player.state = "walk" # local act = { # { type = action.blink, args = { id = player.id, duration=5, blink_duration= 0.2}}, # { type = action.callfunc, args = { func = function() marioInfo.invincible=false end }} # } # local s = script.make(act) # monkey.play(s) else: s = Script() s.addAction (act.SetState(state='warp', tag='player', args = {'anim': 'dead'})) 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(id = player.id())) s.addAction (act.RestartRoom()) example.play(s)