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 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 ciao(player : example.Wrap1, other : example.Wrap1, x, y): f = 'collide_with_'+other.tag print ('check if exists func ' + f) if hasattr(engine.scripts.actions, f): print ('YES') a = getattr(engine.scripts.actions, f)() if a: a() else: print ('no') example.remove(other.id())
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 foeIsHit(player : example.Wrap1, foe : example.Wrap1, x, y): # decrease foe energy info = foe.getInfo() info['energy'] -= 1 if info['energy'] <= 0: example.remove(foe.id()) else: foe.setState ('ishit', {}) vx = 200 if player.x() < foe.x() else -200 if foe.flipx: vx *= -1 foe.vx = vx print ('ciao')
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)
def coinResponse(player:example.Wrap1, coin:example.Wrap1, x, y): example.remove(coin.id())
def mushroomResponse (player: example.Wrap1, mushroom: example.Wrap1, x, y): example.remove(mushroom.id()) upgradePlayer()
def g(player: example.Wrap1, hotspot: example.Wrap1): example.remove(hotspot.id()) m : example.Wrap1 = example.get('main') item = f(*args) m.add (item)