Trial of the Great Ninja - A platformer
@Stage\n\n@Rooms\n\nwhen I receive [room change v]\nswitch costume to (ROOM)\n\nwhen I receive [new game v]\nset [room v] to [1]\ngo to [back v] layer\ngo to x: (0) y: (0)\nswitch costume to (room 1 v)\nshow\n\nwhen I receive [animate v]\nshow\n\nwhen I receive [input v]\nhide\n\ngo to x: (0) y: (0)\n\n@Over Layer\n\nwhen I receive [room change v]\nshow\ngo to [front v] layer\nswitch costume to (ROOM)\n\nwhen I receive [new game v]\nset [room v] to [1]\ngo to x: (0) y: (0)\nswitch costume to (room 1 v)\nshow\ngo to [front v] layer\n\nwhen I receive [input v]\nhide\n\nwhen I receive [animate v]\nshow\n\n@Walls\n\nwhen I receive [room change v]\nswitch costume to (ROOM)\n\nwhen flag clicked\nswitch costume to (room 1 v)\n\nwhen I receive [new game v]\ngo to x: (0) y: (0)\nhide\n\nwhen I receive [input v]\nshow\n\nwhen I receive [animate v]\nhide\n\n@Game\n\nwhen flag clicked\nInit List\nset [boss defeated v] to [0]\nhide variable [health v]\nset [game state v] to [Title]\nset [music v] to [Title]\nforever\n    broadcast (Input v)\n    if <(Game State) = [Title]> then\n        if <([spacepressed v] of [input v]) = [1]> then\n            set [game state v] to [Intro]\n            set [room v] to [1]\n            set [gamepaused v] to [1]\n            broadcast (New Game v)\n            set [music v] to [Silence]\n            stop all sounds\n        end\n    end\n    if <(Game State) = [Intro]> then\n        broadcast (Intro v)\n    end\n    if <(Game State) = [Play]> then\n        broadcast (step v)\n    end\n    if <(Game State) = [Boss Intro]> then\n        broadcast (Boss Intro v)\n    end\n    if <(Game State) = [Redo]> then\n        set [game state v] to [Title]\n    end\n    broadcast (Animate v)\nend\n\ndefine Init List\nset [counter v] to [1]\nrepeat (length of (item (1) of [init list v]))\n    replace item (Counter) of [type v] with (letter (Counter) of (item (1) of [init list v]))\n    change [counter v] by (1)\nend\nset [counter v] to [1]\nrepeat (length of (item (2) of [init list v]))\n    replace item (Counter) of [itemtype v] with (letter (Counter) of (item (2) of [init list v]))\n    change [counter v] by (1)\nend\nset [counter v] to [1]\nrepeat (length of (item (3) of [init list v]))\n    replace item (Counter) of [doors v] with (letter (Counter) of (item (3) of [init list v]))\n    change [counter v] by (1)\nend\n\nwhen I receive [game complete v]\nInit List\nset [boss defeated v] to [0]\nhide variable [health v]\nset [game state v] to [Redo]\nstop all sounds\nset [music v] to [Title]\n\n@Player\n\ndefine Check Collision (y)\nif <touching color (#31a2f2)?> then\n    change y by ((-1) * (yspd))\n    repeat until <touching color (#31a2f2)?>\n        if <(yspd) < [0]> then\n            change y by (-1)\n        else\n            change y by (1)\n        end\n    end\n    if <(yspd) < [0]> then\n        change y by (1)\n        set [grounded v] to [1]\n        set [bounce v] to [0]\n        set [jumpcounter v] to [0]\n    else\n        change y by (-1)\n    end\n    set [yspd v] to [0]\nelse\n    set [grounded v] to [0]\n    if <(jumpCounter) = [0]> then\n        set [jumpcounter v] to [1]\n    end\nend\n\nwhen I receive [step v]\nCheck input\nif <(state) = [Normal]> then\n    Movement\n    Attack\n    sword hit\n    Check for room change\nelse\n    if <(state) = [Climb]> then\n        Climbing\n        Attack\n        Check for room change\n    else\n        if <(state) = [Talking]> then\n            Talking\n        end\n    end\nend\nCheck for death\nif <(ROOM) > [15]> then\n    if <([spacepressed v] of [input v]) = [1]> then\n        broadcast (Game Complete v)\n    end\nend\n\ndefine Check input\nif <not <(state) = [Talking]>> then\n    set [xdir v] to (([right1 v] of [input v]) - ([left1 v] of [input v]))\n    if <(xdir) = [1]> then\n        set [currentdir v] to [1]\n    end\n    if <(xdir) = [-1]> then\n        set [currentdir v] to [-1]\n    end\nend\n\ndefine Movement\nswitch costume to (mask v)\nset [xspd v] to ((speed) * (xdir))\nchange x by (xspd)\nCheck collision (x)\nif <([up1pressed v] of [input v]) = [1]> then\n    if <(jumpCounter) < (maxJump)> then\n        set [yspd v] to (JumpSpeed)\n        change [jumpcounter v] by (1)\n    end\nend\nif <<(yspd) > [0]> and <(bounce) = [0]>> then\n    if <([up1 v] of [input v]) = [0]> then\n        set [yspd v] to [0]\n    end\nend\nif <(yspd) > (MaxYSpeed)> then\n    change [yspd v] by (Grav)\nelse\n    set [yspd v] to (MaxYSpeed)\nend\nchange y by (yspd)\nCheck Collision (y)\nif <<<touching (enemy v)?> or <touching (boss v)?>> and <(InviCounter) < [1]>> then\n    set [invicounter v] to [30]\n    change [health v] by (-1)\n    broadcast (Update Health v)\n    set [yspd v] to [6]\n    set [bounce v] to [1]\n    start sound [Muted Conga v]\nend\nif <(InviCounter) > [0]> then\n    change [invicounter v] by (-1)\nend\nif <([up1pressed v] of [input v]) = [1]> then\n    if <touching color (#e06f8b)?> then\n        set [yspd v] to [0]\n        set [state v] to [Climb]\n        set [jumpcounter v] to [0]\n        set x to ((([floor v] of (((x position) + (235)) / (20)) ) * (20)) - (230))\n    end\nend\nif <([spacepressed v] of [input v]) = [1]> then\n    if <touching (npc v)?> then\n        set [state v] to [Talking]\n        set [gamepaused v] to [1]\n        broadcast (Talk to NPC v)\n    end\nend\nif <touching (items v)?> then\n    broadcast (Get Item v)\nend\nif <touching color (#f7e26b)?> then\n    set [invicounter v] to [30]\n    change [health v] by (-1)\n    broadcast (Update Health v)\n    go to x: (startX) y: (startY)\nend\n\ndefine Check collision (x)\nif <touching color (#31a2f2)?> then\n    change x by ((-1) * (xspd))\n    repeat until <touching color (#31a2f2)?>\n        if <(xspd) < [0]> then\n            change x by (-1)\n        else\n            change x by (1)\n        end\n    end\n    if <(xspd) < [0]> then\n        change x by (1)\n    else\n        change x by (-1)\n    end\nend\n\ndefine Animation\nif <(CurrentDir) > [0]> then\n    if <(Attack) = [0]> then\n        switch costume to (playerright v)\n    else\n        if <(Attack) = [Right]> then\n            switch costume to (attackright v)\n        end\n        if <(Attack) = [Left]> then\n            switch costume to (attackbleft v)\n        end\n        if <(Attack) = [Up]> then\n            switch costume to (attackupr v)\n        end\n        if <(Attack) = [Down]> then\n            switch costume to (attackdownr v)\n        end\n    end\nelse\n    if <(Attack) = [0]> then\n        switch costume to (playerleft v)\n    else\n        if <(Attack) = [Right]> then\n            switch costume to (attackbright v)\n        end\n        if <(Attack) = [Left]> then\n            switch costume to (attackleft v)\n        end\n        if <(Attack) = [Up]> then\n            switch costume to (attackupl v)\n        end\n        if <(Attack) = [Down]> then\n            switch costume to (attackdownl v)\n        end\n    end\nend\nif <(InviCounter) > [0]> then\n    if <((InviCounter) mod (2)) = [0]> then\n        if <((InviCounter) mod (4)) = [0]> then\n            set [ghost v] effect to (50)\n        else\n            set [ghost v] effect to (0)\n        end\n    end\nend\n\ndefine Attack\nif <(Attack) = [0]> then\n    if <([right2pressed v] of [input v]) = [1]> then\n        set [attack v] to [Right]\n        set [attacktimer v] to [5]\n        start sound [High Whoosh v]\n    end\n    if <([left2pressed v] of [input v]) = [1]> then\n        set [attack v] to [Left]\n        set [attacktimer v] to [5]\n        start sound [High Whoosh v]\n    end\n    if <([up2pressed v] of [input v]) = [1]> then\n        set [attack v] to [Up]\n        set [attacktimer v] to [5]\n        start sound [High Whoosh v]\n    end\n    if <([down2pressed v] of [input v]) = [1]> then\n        if <(grounded) = [0]> then\n            set [attack v] to [Down]\n            set [attacktimer v] to [5]\n            start sound [High Whoosh v]\n        end\n    end\nend\nif <not <(Attack) = [0]>> then\n    change [attacktimer v] by (-1)\n    if <(AttackTimer) < [1]> then\n        set [attacktimer v] to [0]\n        set [attack v] to [0]\n    end\nend\n\ndefine sword hit\nif <not <(Attack) = [0]>> then\n    if <(Attack) = [Right]> then\n        switch costume to (attackrmask v)\n    end\n    if <(Attack) = [Left]> then\n        switch costume to (attacklmask v)\n    end\n    if <(Attack) = [Up]> then\n        switch costume to (attackupmask v)\n    end\n    if <(Attack) = [Down]> then\n        switch costume to (attackdmask v)\n    end\n    if <<touching (enemy v)?> or <touching (boss v)?>> then\n        if <(Attack) = [Down]> then\n            set [yspd v] to [10]\n            set [bounce v] to [1]\n        end\n        broadcast (Enemy HIT v)\n    end\nelse\n    switch costume to (empty v)\nend\n\ndefine Check for room change\nif <<(x position) > [239]> and <(item (ROOM) of [right v]) > [0]>> then\n    set x to (-238)\n    set [room v] to (item (ROOM) of [right v])\n    broadcast (Room change v)\nend\nif <<(x position) < [-239]> and <(item (ROOM) of [left v]) > [0]>> then\n    set x to (238)\n    set [room v] to (item (ROOM) of [left v])\n    broadcast (Room change v)\nend\nif <<(y position) < [-179]> and <(item (ROOM) of [down v]) > [0]>> then\n    set y to (178)\n    set [room v] to (item (ROOM) of [down v])\n    broadcast (Room change v)\nend\nif <<(y position) > [179]> and <(item (ROOM) of [up v]) > [0]>> then\n    set y to (-178)\n    set [room v] to (item (ROOM) of [up v])\n    broadcast (Room change v)\nend\n\ndefine Climbing\nswitch costume to (mask v)\nif <<([right1pressed v] of [input v]) = [1]> or <([left1pressed v] of [input v]) = [1]>> then\n    set [jumpcounter v] to [1]\n    set [state v] to [Normal]\n    set [yspd v] to (JumpSpeed)\n    set [bounce v] to [1]\nend\nif <([up1 v] of [input v]) = [1]> then\n    change y by (speed)\n    if <touching color (#31a2f2)?> then\n        set [state v] to [Normal]\n        change y by (-5)\n    end\nend\nif <([down1 v] of [input v]) = [1]> then\n    change y by ((-1) * (speed))\n    if <touching color (#31a2f2)?> then\n        set [state v] to [Normal]\n        change y by (5)\n    end\nend\nif <not <touching color (#e06f8b)?>> then\n    set [jumpcounter v] to [1]\n    set [yspd v] to (JumpSpeed)\n    set [state v] to [Normal]\nend\n\ndefine Check for death\nif <(Health) < [1]> then\n    set [health v] to (Max Health)\n    set [room v] to [1]\n    set [game state v] to [Intro]\n    go to x: (-13) y: (-104)\n    broadcast (Room change v)\nend\n\nwhen I receive [new game v]\nset [max health v] to [4]\nset [invicounter v] to [0]\nset [bounce v] to [0]\nset [attack v] to [0]\nset [speed v] to [5]\nset [grounded v] to [0]\nset [grav v] to [-1]\nset [jumpspeed v] to [12]\nset [maxyspeed v] to [-14]\nset [health v] to [4]\nset [state v] to [Normal]\nset [maxjump v] to [1]\nset [jumpcounter v] to [0]\nset [number of crystals v] to [0]\nset [xdir v] to [0]\ngo to x: (-13) y: (-104)\nshow\ngo to [front v] layer\n\nwhen I receive [animate v]\nAnimation\n\ndefine Talking\nif <([spacepressed v] of [input v]) = [1]> then\n    broadcast (Erase text v)\n    set [gamepaused v] to [0]\n    set [state v] to [Normal]\nend\n\nwhen I receive [maxjump addon v]\nset [maxjump v] to [2]\n\nwhen I receive [room change v]\nset [startx v] to (x position)\nset [starty v] to (y position)\nif <(ROOM) = [16]> then\n    set [state v] to [finished]\n    hide\nend\n\n@Input\n\nwhen I receive [input v]\nLeft Input\nRight Input\n\ndefine Left Input\nset [left1pressed v] to [0]\nset [down1pressed v] to [0]\nset [up1pressed v] to [0]\nset [right1pressed v] to [0]\nset [spacepressed v] to [0]\nset [down1 v] to [0]\nset [right1 v] to [0]\nset [left1 v] to [0]\nset [up1 v] to [0]\nset [space v] to [0]\nif <not <key (space v) pressed?>> then\n    set [spacereleased v] to [1]\nend\nif <<not <key (a v) pressed?>> and <not <key (q v) pressed?>>> then\n    set [left1released v] to [1]\nend\nif <not <key (s v) pressed?>> then\n    set [down1released v] to [1]\nend\nif <not <key (d v) pressed?>> then\n    set [right1released v] to [1]\nend\nif <<not <key (w v) pressed?>> and <not <key (z v) pressed?>>> then\n    set [up1released v] to [1]\nend\nif <<key (a v) pressed?> or <key (q v) pressed?>> then\n    set [left1 v] to [1]\n    if <(Left1Released) = [1]> then\n        set [left1pressed v] to [1]\n    end\n    set [left1released v] to [0]\nend\nif <key (s v) pressed?> then\n    set [down1 v] to [1]\n    if <(Down1Released) = [1]> then\n        set [down1pressed v] to [1]\n    end\n    set [down1released v] to [0]\nend\nif <key (d v) pressed?> then\n    set [right1 v] to [1]\n    if <(Right1Released) = [1]> then\n        set [right1pressed v] to [1]\n    end\n    set [right1released v] to [0]\nend\nif <<key (w v) pressed?> or <key (z v) pressed?>> then\n    set [up1 v] to [1]\n    if <(Up1Released) = [1]> then\n        set [up1pressed v] to [1]\n    end\n    set [up1released v] to [0]\nend\nif <key (space v) pressed?> then\n    set [space v] to [1]\n    if <(SpaceReleased) = [1]> then\n        set [spacepressed v] to [1]\n    end\n    set [spacereleased v] to [0]\nend\n\ndefine Right Input\nset [down2pressed v] to [0]\nset [left2pressed v] to [0]\nset [up2pressed v] to [0]\nset [right2pressed v] to [0]\nset [down2 v] to [0]\nset [right2 v] to [0]\nset [left2 v] to [0]\nset [up2 v] to [0]\nif <not <key (left arrow v) pressed?>> then\n    set [left2released v] to [1]\nend\nif <not <key (down arrow v) pressed?>> then\n    set [down2released v] to [1]\nend\nif <not <key (right arrow v) pressed?>> then\n    set [right2released v] to [1]\nend\nif <not <key (up arrow v) pressed?>> then\n    set [up2released v] to [1]\nend\nif <key (left arrow v) pressed?> then\n    set [left2 v] to [1]\n    if <(Left2Released) = [1]> then\n        set [left2pressed v] to [1]\n    end\n    set [left2released v] to [0]\nend\nif <key (down arrow v) pressed?> then\n    set [down2 v] to [1]\n    if <(Down2Released) = [1]> then\n        set [down2pressed v] to [1]\n    end\n    set [down2released v] to [0]\nend\nif <key (right arrow v) pressed?> then\n    set [right2 v] to [1]\n    if <(Right2Released) = [1]> then\n        set [right2pressed v] to [1]\n    end\n    set [right2released v] to [0]\nend\nif <key (up arrow v) pressed?> then\n    set [up2 v] to [1]\n    if <(Up2Released) = [1]> then\n        set [up2pressed v] to [1]\n    end\n    set [up2released v] to [0]\nend\n\n@Enemy\n\nwhen I receive [room change v]\nif <(creator) = [1]> then\n    broadcast (Delete enemy v)\n    if <(ROOM) = [1]> then\n        set [first v] to [0]\n        set [last v] to (item (1) of [id v])\n    else\n        set [first v] to (item ((ROOM) - (1)) of [id v])\n        set [last v] to (item (ROOM) of [id v])\n    end\n    if <not <(first) = (last)>> then\n        repeat ((last) - (first))\n            change [first v] by (1)\n            create enemy (item (first) of [type v]) at (item (first) of [x v]) (item (first) of [y v])\n        end\n    end\nend\n\nwhen I receive [delete enemy v]\ndelete this clone\n\nwhen I start as a clone\nset [creator v] to [0]\nshow\nif <(myType) = [1]> then\n    set [jumpspeed v] to [10]\n    set [jumptimer v] to (pick random (1) to (10))\n    set [yspd v] to [0]\n    switch costume to (jumping v)\nend\nif <(myType) = [2]> then\n    switch costume to (moving v)\n    set [myhealth v] to [1]\n    set [speed v] to [3]\n    Random Neg/Pos [1]\n    set [xdir v] to (neg)\nend\nif <(myType) = [3]> then\n    set [mystate v] to [Walk]\n    set [speed v] to [1]\n    set [xdir v] to [-1]\n    set [myhealth v] to [4]\n    set [jumpspeed v] to [7]\n    switch costume to (bull_idle_left v)\nend\nif <(myType) = [4]> then\n    Random Neg/Pos [1]\n    set [yspd v] to (neg)\n    switch costume to (fly1 v)\n    set [myhealth v] to [1]\nend\nif <(myType) = [5]> then\n    set [xdir v] to [1]\n    set [myhealth v] to [10]\n    switch costume to (ogre v)\nend\n\ndefine create enemy (type) at (x) (y)\nif <(item (first) of [type v]) > [0]> then\n    set [id v] to (first)\n    set [mytype v] to (type)\n    go to x: (((x) * (20)) - (250)) y: (((y) * (20)) - (200))\n    create clone of (_myself_ v)\nend\n\nwhen I receive [step v]\nif <(GAMEPAUSED) = [0]> then\n    if <(creator) = [0]> then\n        if <(myType) = [1]> then\n            Jumping enemy\n        end\n        if <(myType) = [2]> then\n            BasicMovement\n        end\n        if <(myType) = [3]> then\n            Bull Enemy\n        end\n        if <(myType) = [4]> then\n            Flying Up/Down\n        end\n        if <(myType) = [5]> then\n            Ogre\n        end\n        Check for death\n    end\nend\n\ndefine Jumping enemy\nif <(myState) = [Idle]> then\n    BasicMovement\n    change [jumptimer v] by (1)\n    if <(jumpTimer) = [60]> then\n        set [mystate v] to [Jump]\n    end\nend\nif <(myState) = [Jump]> then\n    set [yspd v] to (jumpSpeed)\n    set [jumptimer v] to (pick random (1) to (10))\n    set [mystate v] to [Idle]\nend\n\ndefine BasicMovement\nset [xspd v] to ((speed) * (xdir))\nchange x by (xspd)\nCheck collision X\nif <(yspd) > (MaxYSpeed)> then\n    change [yspd v] by (grav)\nelse\n    set [yspd v] to (MaxYSpeed)\nend\nchange y by (yspd)\nCheck Collision Y\n\ndefine Check Collision Y\nif <touching color (#31a2f2)?> then\n    change y by ((-1) * (yspd))\n    repeat until <touching color (#31a2f2)?>\n        if <(yspd) < [0]> then\n            change y by (-1)\n        else\n            change y by (1)\n        end\n    end\n    if <(yspd) < [0]> then\n        change y by (1)\n    else\n        change y by (-1)\n    end\n    set [yspd v] to [0]\n    set [grounded v] to [1]\nelse\n    set [grounded v] to [0]\nend\n\nwhen I receive [enemy hit v]\nif <(creator) = [0]> then\n    Touch enemy\nend\n\ndefine Check collision X\nif <touching color (#31a2f2)?> then\n    change x by ((-1) * (xspd))\n    repeat until <touching color (#31a2f2)?>\n        if <(xspd) < [0]> then\n            change x by (-1)\n        else\n            change x by (1)\n        end\n    end\n    if <(xspd) < [0]> then\n        change x by (1)\n    else\n        change x by (-1)\n    end\n    set [xdir v] to ((-1) * (xdir))\nend\nif <<(x position) > [238]> or <(x position) < [-237]>> then\n    set [xdir v] to ((-1) * (xdir))\n    change x by (xdir)\nend\n\nwhen I receive [new game v]\nhide\nset [mytype v] to [0]\nset [creator v] to [1]\nset [grav v] to [-1]\nset [maxyspeed v] to [-16]\nset [jumpspeed v] to [0]\nset [mystate v] to [Idle]\nset [yspd v] to [0]\nset [xspd v] to [0]\nset [xdir v] to [0]\nset [speed v] to [0]\nset [grounded v] to [0]\nset [myhealth v] to [1]\nset [flycounter v] to [0]\nset [invitime v] to [0]\nset [animation counter v] to [0]\nset [state counter v] to [0]\nset [costume number v] to [0]\nbroadcast (Room change v)\n\ndefine Check for death\nif <(myHealth) < [1]> then\n    if <(myType) = [5]> then\n        replace item (id) of [type v] with [-1]\n        if <(ROOM) = [6]> then\n            replace item (1) of [doors v] with [0]\n            broadcast (Delete Doors v)\n        end\n    end\n    delete this clone\nend\nchange [invitime v] by (-1)\n\ndefine Flying Up/Down\nchange y by (yspd)\nchange [flycounter v] by (1)\nif <(flyCounter) > [10]> then\n    set [flycounter v] to [0]\n    set [yspd v] to ((-1) * (yspd))\nend\n\ndefine Random Neg/Pos (var)\nset [neg v] to (pick random (0) to (1))\nif <(neg) = [0]> then\n    set [neg v] to (var)\nelse\n    set [neg v] to ((-1) * (var))\nend\n\ndefine Bull Enemy\nswitch costume to (bull_mask v)\nBasicMovement\nDetect\nif <(myState) = [Idle]> then\n    change [state counter v] by (1)\n    if <(State Counter) > [30]> then\n        Random Neg/Pos [1]\n        if <(neg) = [1]> then\n            set [mystate v] to [Walk]\n            set [speed v] to [1]\n            set [costume number v] to [0]\n        end\n        set [state counter v] to [1]\n    end\n    if <(Detect) = [1]> then\n        set [mystate v] to [Alert]\n        set [speed v] to [0]\n        set [yspd v] to (jumpSpeed)\n    end\nend\nif <(myState) = [Walk]> then\n    change [state counter v] by (1)\n    if <((State Counter) mod (60)) = [0]> then\n        Random Neg/Pos [1]\n        if <(neg) = [1]> then\n            set [xdir v] to ((-1) * (xdir))\n        end\n        change [state counter v] by (1)\n    end\n    if <(State Counter) > [100]> then\n        Random Neg/Pos [1]\n        if <(neg) = [1]> then\n            set [mystate v] to [Idle]\n            set [speed v] to [0]\n        end\n        set [state counter v] to [1]\n    end\n    if <(Detect) = [1]> then\n        set [mystate v] to [Alert]\n        set [speed v] to [0]\n        set [yspd v] to (jumpSpeed)\n    end\nend\nif <(myState) = [Alert]> then\n    if <<(grounded) = [1]> and <(yspd) = [0]>> then\n        set [mystate v] to [Charge]\n        set [speed v] to [.25]\n        set [state counter v] to [1]\n        start sound [Horse Gallop v]\n    end\nend\nif <(myState) = [Charge]> then\n    change [state counter v] by (1)\n    if <(State Counter) > [20]> then\n        set [speed v] to [10]\n        set [state counter v] to [1]\n        set [mystate v] to [Charging]\n    end\nend\nif <(myState) = [Charging]> then\n    if <(Detect) = [0]> then\n        change [state counter v] by (1)\n    else\n        set [state counter v] to [1]\n    end\n    if <(State Counter) > [50]> then\n        set [state counter v] to [1]\n        set [mystate v] to [Walk]\n        set [speed v] to [1]\n    end\nend\n\ndefine Ogre\nswitch costume to (ogre_mask v)\nBasicMovement\nif <(myState) = [Idle]> then\n    Ogre Idle State\nend\nif <(myState) = [Walk]> then\n    change [state counter v] by (1)\n    if <((State Counter) mod (30)) = [0]> then\n        Random Neg/Pos [1]\n        if <(neg) = [1]> then\n            set [xdir v] to ((-1) * (xdir))\n        end\n        change [state counter v] by (1)\n    end\n    if <(State Counter) > [100]> then\n        Random Neg/Pos [1]\n        if <(neg) = [1]> then\n            set [mystate v] to [Throw]\n            set [speed v] to [0]\n            set [flycounter v] to (pick random (3) to (6))\n        end\n        set [state counter v] to [1]\n    end\nend\nif <(myState) = [Throw]> then\n    change [state counter v] by (1)\n    if <((State Counter) mod (30)) = [0]> then\n        Throw\n        change [flycounter v] by (-1)\n    end\n    if <(flyCounter) < [1]> then\n        set [mystate v] to [Idle]\n        set [state counter v] to [1]\n    end\nend\n\ndefine Ogre Idle State\nchange [state counter v] by (1)\nif <(State Counter) > [30]> then\n    Random Neg/Pos [1]\n    if <(neg) = [1]> then\n        set [mystate v] to [Walk]\n        set [speed v] to [1]\n        set [costume number v] to [0]\n    end\n    set [state counter v] to [1]\nend\n\nwhen I receive [animate v]\nif <(myType) = [4]> then\n    change [animation counter v] by (1)\n    if <(Animation Counter) > [5]> then\n        if <(costume [name v]) = [Fly1]> then\n            switch costume to (fly2 v)\n        else\n            switch costume to (fly1 v)\n        end\n        set [animation counter v] to [0]\n    end\nend\nif <(myType) = [3]> then\n    if <(myState) = [Idle]> then\n        if <(xdir) = [-1]> then\n            switch costume to (bull_idle_left v)\n        else\n            switch costume to (bull_idle_right v)\n        end\n    end\n    if <(myState) = [Walk]> then\n        if <(xdir) = [-1]> then\n            switch costume to ((5) + (Costume Number))\n        else\n            switch costume to ((9) + (Costume Number))\n        end\n        change [animation counter v] by (1)\n        if <(Animation Counter) > [5]> then\n            change [costume number v] by (1)\n            set [animation counter v] to [0]\n            if <(Costume Number) > [3]> then\n                set [costume number v] to [0]\n            end\n        end\n    end\n    if <(myState) = [Alert]> then\n        if <(xdir) = [-1]> then\n            switch costume to (bull_alert_left v)\n        else\n            switch costume to (bull_alert_right v)\n        end\n    end\n    if <(myState) = [Charge]> then\n        if <(xdir) = [-1]> then\n            switch costume to ((5) + (Costume Number))\n        else\n            switch costume to ((9) + (Costume Number))\n        end\n        change [animation counter v] by (1)\n        if <(Animation Counter) > [1]> then\n            change [costume number v] by (1)\n            set [animation counter v] to [0]\n            if <(Costume Number) > [3]> then\n                set [costume number v] to [0]\n            end\n        end\n    end\n    if <(myState) = [Charging]> then\n        if <(xdir) = [-1]> then\n            switch costume to ((5) + (Costume Number))\n        else\n            switch costume to ((9) + (Costume Number))\n        end\n        change [animation counter v] by (1)\n        if <(Animation Counter) > [1]> then\n            change [costume number v] by (1)\n            set [animation counter v] to [0]\n            if <(Costume Number) > [3]> then\n                set [costume number v] to [0]\n            end\n        end\n    end\nend\nif <(myType) = [5]> then\n    if <(myState) = [Idle]> then\n        switch costume to (ogre v)\n    end\n    if <(myState) = [Walk]> then\n        switch costume to ((17) + (Costume Number))\n        change [animation counter v] by (1)\n        if <(Animation Counter) > [4]> then\n            change [costume number v] by (1)\n            set [animation counter v] to [0]\n            if <(Costume Number) > [7]> then\n                set [costume number v] to [0]\n            end\n        end\n    end\n    if <(myState) = [Throw]> then\n        switch costume to (ogre10 v)\n    end\nend\nif <(InviTime) > [0]> then\n    if <((InviTime) mod (2)) = [0]> then\n        if <((InviTime) mod (4)) = [0]> then\n            set [ghost v] effect to (50)\n        else\n            set [ghost v] effect to (0)\n        end\n    end\nend\n\ndefine Detect\nset [detect test v] to [0]\nif <(xdir) = [-1]> then\n    if <([x position v] of [player v]) < (x position)> then\n        if <([y position v] of [player v]) < ((y position) + (50))> then\n            if <([y position v] of [player v]) > (y position)> then\n                set [detect test v] to [1]\n            end\n        end\n    end\nelse\n    if <([x position v] of [player v]) > (x position)> then\n        if <([y position v] of [player v]) < ((y position) + (50))> then\n            if <([y position v] of [player v]) > (y position)> then\n                set [detect test v] to [1]\n            end\n        end\n    end\nend\nif <(Detect Test) = [1]> then\n    set [detect v] to [1]\nelse\n    set [detect v] to [0]\nend\n\ndefine Throw\nswitch costume to (moving v)\nset [mytype v] to [2]\nstart sound [Throw v]\ncreate clone of (_myself_ v)\nswitch costume to (ogre v)\nset [mytype v] to [5]\n\ndefine Touch enemy\nif <(myType) = [4]> then\n    switch costume to (fly mask v)\n    if <<touching (player v)?> and <(InviTime) < [1]>> then\n        start sound [Bite v]\n        change [myhealth v] by (-1)\n        set [invitime v] to [20]\n    end\n    switch costume to (fly1 v)\nend\nif <<touching (player v)?> and <(InviTime) < [1]>> then\n    start sound [Bite v]\n    change [myhealth v] by (-1)\n    set [invitime v] to [20]\nend\n\n@Grid\n\nwhen I receive [room change v]\n\n@NPC\n\nwhen I start as a clone\nset [creator v] to [0]\nshow\n\ndefine create NPC (type) at (x) (y)\nif <(item (first) of [npctype v]) > [0]> then\n    set [id v] to (first)\n    set [mytype v] to (type)\n    go to x: (((x) * (20)) - (250)) y: (((y) * (20)) - (200))\n    create clone of (_myself_ v)\nend\n\nwhen I receive [new game v]\nhide variable [last player to complete this game v]\nset [new game v] to [1]\nset [counter v] to [0]\nset [mytype v] to [0]\nset [creator v] to [1]\nhide\n\nwhen I receive [room change v]\nif <(creator) = [1]> then\n    broadcast (Delete NPC v)\n    if <(ROOM) = [1]> then\n        set [first v] to [0]\n        set [last v] to (item (1) of [id v])\n    else\n        set [first v] to (item ((ROOM) - (1)) of [id v])\n        set [last v] to (item (ROOM) of [id v])\n    end\n    if <not <(first) = (last)>> then\n        repeat ((last) - (first))\n            change [first v] by (1)\n            create NPC (item (first) of [npctype v]) at (item (first) of [x v]) (item (first) of [y v])\n        end\n    end\nend\nif <(ROOM) = [16]> then\n    Register Name\n    set size to (300) %\n    go to x: (-5) y: (-28)\n    if <(Number of Crystals) > [2]> then\n        set [room v] to [17]\n        broadcast (Room change v)\n        set [☁ achievements v] to [1]\n    else\n        set [☁ achievements v] to [0]\n    end\n    show\nend\n\nwhen I receive [delete npc v]\ndelete this clone\n\nwhen I receive [talk to npc v]\nif <(creator) = [0]> then\n    if <touching (player v)?> then\n        say (item (id) of [text v])\n    end\nend\n\nwhen I receive [erase text v]\nsay []\n\nwhen I receive [intro v]\nchange [counter v] by (1)\nif <(counter) = [50]> then\n    if <(New game) = [1]> then\n        if <(☁ Achievements) = [0]> then\n            say (join [Hey! Welcome to the Trial of the Great Ninja! I am ] (join (Last player to complete this game) [. I am the last one to have survived this challenge. \(Talk to me by pressing Space\)]))\n            change [counter v] by (1)\n            set [new game v] to [0]\n        else\n            say (join [Hey! Welcome to the Trial of the Great Ninja! I am ] (join (Last player to complete this game) [. I am the last one to have survived this challenge. I even found all the secret crystals! I am so great! \(Talk to me by pressing Space\)]))\n            change [counter v] by (1)\n            set [new game v] to [0]\n        end\n    else\n        say [Hey! Be careful! You fainted out. You should be glad I found you.]\n        change [counter v] by (1)\n    end\nend\nif <(counter) > [50]> then\n    if <([spacepressed v] of [input v]) = [1]> then\n        say []\n        set [game state v] to [Play]\n        set [gamepaused v] to [0]\n        set [music v] to [Overworld]\n        set [counter v] to [0]\n        stop all sounds\n    end\nend\n\ndefine Register Name\nset [☁ name v] to []\nset [let count v] to [1]\nif <not <(username) = []>> then\n    repeat (length of (username))\n        Is it lowercase? (letter (let count) of (username))\n        Find letter (letter (let count) of (username))\n        change [let count v] by (1)\n    end\n    set [☁ name v] to (join (☁ NAME) [00])\nend\n\ndefine Char list\ndelete all of [characters v]\nset [let count v] to [0]\nset [char v] to [ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-_]\nrepeat ((length of (char)) + (1))\n    add (letter (let count) of (char)) to [characters v]\n    change [let count v] by (1)\nend\n\ndefine Find letter (letter)\nset [let count 2 v] to [1]\nrepeat until <(item (let count 2) of [characters v]) = (letter)>\n    change [let count 2 v] by (1)\nend\nif <(isLowercase) = [true]> then\n    change [let count 2 v] by (26)\nend\nif <(let count 2) < [10]> then\n    set [☁ name v] to (join (☁ NAME) (join [0] (let count 2)))\nelse\n    set [☁ name v] to (join (☁ NAME) (let count 2))\nend\n\nwhen flag clicked\nset size to (100) %\nshow variable [last player to complete this game v]\nChar list\nGenerate Name\n\ndefine Generate Name\nset [idlettre v] to [01]\nset [let count v] to [1]\nset [let count 2 v] to [2]\nset [last player to complete this game v] to []\nif <(☁ NAME) = []> then\n    stop [this script v]\nend\nrepeat until <(IDLettre) = [00]>\n    set [joinid v] to (join (letter (let count) of (☁ NAME)) (letter (let count 2) of (☁ NAME)))\n    set [idlettre v] to (item (JoinID) of [characters v])\n    set [last player to complete this game v] to (join (Last player to complete this game) (IDLettre))\n    change [let count v] by (2)\n    change [let count 2 v] by (2)\n    if <(join (letter (let count) of (☁ NAME)) (letter (let count 2) of (☁ NAME))) = []> then\n        stop [this script v]\n    end\nend\n\ndefine Is it lowercase? (letter)\nset [joinid v] to [ABCDEFGHIJKLMNOPQRSTUVWXYZ]\nset [counter v] to [1]\nset [idlettre v] to []\nrepeat (length of (JoinID))\n    if <(letter (counter) of (JoinID)) = (letter)> then\n        set [idlettre v] to (join (IDLettre) (letter))\n    else\n        set [idlettre v] to (join (IDLettre) (letter (counter) of (JoinID)))\n    end\n    change [counter v] by (1)\nend\nswitch costume to (npc v)\nswitch costume to (IDLettre)\nif <(costume [number v]) = [1]> then\n    set [islowercase v] to [false]\nelse\n    set [islowercase v] to [true]\nend\n\nwhen I receive [game complete v]\nset size to (100) %\nshow variable [last player to complete this game v]\nChar list\nGenerate Name\n\n@Items\n\nwhen I start as a clone\nset [creator v] to [0]\nshow\nif <(myType) = [1]> then\n    switch costume to (costume1 v)\nend\nif <(myType) = [2]> then\n    switch costume to (costume2 v)\nend\nif <(myType) = [3]> then\n    switch costume to (costume3 v)\nend\n\ndefine create item (type) at (x) (y)\nif <(item (first) of [itemtype v]) > [0]> then\n    set [id v] to (first)\n    set [mytype v] to (type)\n    go to x: (((x) * (20)) - (250)) y: (((y) * (20)) - (200))\n    create clone of (_myself_ v)\nend\n\nwhen I receive [new game v]\nset [mytype v] to [0]\nset [creator v] to [1]\nhide\n\nwhen I receive [room change v]\nif <(creator) = [1]> then\n    broadcast (Delete Items v)\n    if <(ROOM) = [1]> then\n        set [first v] to [0]\n        set [last v] to (item (1) of [id v])\n    else\n        set [first v] to (item ((ROOM) - (1)) of [id v])\n        set [last v] to (item (ROOM) of [id v])\n    end\n    if <not <(first) = (last)>> then\n        repeat ((last) - (first))\n            change [first v] by (1)\n            create item (item (first) of [itemtype v]) at (item (first) of [x v]) (item (first) of [y v])\n        end\n    end\nend\n\nwhen I receive [delete items v]\ndelete this clone\n\nwhen I receive [get item v]\nif <(creator) = [0]> then\n    if <touching (player v)?> then\n        if <(myType) = [1]> then\n            change [max health v] by (2)\n            set [gamepaused v] to [1]\n            set [textbox v] to [Health]\n            broadcast (Get Health v)\n        end\n        if <(myType) = [2]> then\n            broadcast (maxJump addon v)\n            set [gamepaused v] to [1]\n            set [textbox v] to [Boots]\n        end\n        if <(myType) = [3]> then\n            change [number of crystals v] by (1)\n            set [gamepaused v] to [1]\n            set [textbox v] to [Crystal]\n        end\n        replace item (id) of [itemtype v] with [-1]\n        delete this clone\n    end\nend\n\nwhen I receive [step v]\n\n@Music\n\nwhen flag clicked\nset [music v] to [0]\nforever\n    if <(MUSIC) = [Title]> then\n        play sound [Final Fantasy Adventure \(GB\) Music - Title Theme v] until done\n    end\n    if <(MUSIC) = [Overworld]> then\n        play sound [Endless Battlefield - Final Fantasy Adventure v] until done\n    end\n    if <(MUSIC) = [Boss]> then\n        play sound [Final Fantasy Adventure Soundtrack Fight 2 \(1080p\) v] until done\n    end\n    if <(MUSIC) = [End]> then\n        play sound [Legend Forever - Final Fantasy Adventure v] until done\n    end\nend\n\n@Title Screen\n\nwhen flag clicked\ngo to x: (0) y: (0)\nswitch costume to (download v)\ngo to [front v] layer\nshow\n\nwhen I receive [new game v]\nswitch costume to (costume1 v)\nhide\n\nwhen I receive [game complete v]\ngo to x: (0) y: (0)\nswitch costume to (download v)\ngo to [front v] layer\nshow\n\n@Text Box\n\nwhen flag clicked\nhide\n\nwhen I receive [step v]\nif <not <(TEXTBOX) = [0]>> then\n    if <not <(TEXTBOX) = [Display]>> then\n        set [game state v] to [TextBox]\n        set [music v] to [Silence]\n        stop all sounds\n        start sound [Win v]\n        show\n        if <(TEXTBOX) = [Health]> then\n            switch costume to (health v)\n            set [textbox v] to [Display]\n        end\n        if <(TEXTBOX) = [Boots]> then\n            switch costume to (boots v)\n            set [textbox v] to [Display]\n        end\n        if <(TEXTBOX) = [Crystal]> then\n            switch costume to (crystal v)\n            set [textbox v] to [Display]\n        end\n    end\nend\n\nwhen I receive [input v]\nif <not <(TEXTBOX) = [0]>> then\n    if <([spacepressed v] of [input v]) = [1]> then\n        stop all sounds\n        set [music v] to [Overworld]\n        set [gamepaused v] to [0]\n        set [game state v] to [Play]\n        set [textbox v] to [0]\n        hide\n    end\nend\n\n@Door\n\ndefine Create door at (x) (y) (door type)\ngo to x: (((x) * (20)) - (250)) y: (((y) * (20)) - (200))\nset [door type v] to (door type)\ncreate clone of (_myself_ v)\n\nwhen I receive [delete doors v]\ndelete this clone\n\nwhen flag clicked\nset [creator v] to [1]\nhide\n\nwhen I start as a clone\nset [creator v] to [0]\nshow\n\nwhen I receive [input v]\nif <(Door Type) = [1]> then\n    switch costume to (mask v)\nend\nif <(Door Type) = [2]> then\n    switch costume to (mask2 v)\nend\n\nwhen I receive [animate v]\nif <(Door Type) = [1]> then\n    switch costume to (door2 v)\nend\nif <(Door Type) = [2]> then\n    switch costume to (door3 v)\nend\n\nwhen I receive [room change v]\nif <(creator) = [1]> then\n    broadcast (Delete Doors v)\n    if <<(ROOM) = [6]> and <(item (1) of [doors v]) = [6]>> then\n        Create door at [1] [4] [1]\n    end\nend\n\nwhen I receive [boss door v]\nif <(Boss defeated) = [0]> then\n    Create door at [24] [2] [2]\n    Create door at [1] [2] [2]\nend\n\n@Health\n\nwhen flag clicked\nset [creator v] to [1]\nhide\nswitch costume to (4 v)\nset [heart number v] to [1]\ngo to x: (-220) y: (-179)\ncreate clone of (_myself_ v)\ngo to x: (-195) y: (-179)\nset [heart number v] to [2]\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nset size to (150) %\nset [creator v] to [0]\n\nwhen I receive [animate v]\nif <(Creator) = [0]> then\n    show\nend\n\nwhen I receive [input v]\nhide\n\nwhen I receive [get health v]\nif <(Creator) = [1]> then\n    if <(Max Health) = [6]> then\n        set [health v] to (Max Health)\n        set [heart number v] to [3]\n        go to x: (-170) y: (-179)\n        create clone of (_myself_ v)\n    end\n    if <(Max Health) = [8]> then\n        set [health v] to (Max Health)\n        set [heart number v] to [4]\n        go to x: (-145) y: (-179)\n        create clone of (_myself_ v)\n    end\n    broadcast (Update Health v)\nend\n\nwhen I receive [update health v]\nif <(Creator) = [0]> then\n    if <(Health) < ((heart number) * (2))> then\n        if <(Health) > (((heart number) - (1)) * (2))> then\n            switch costume to (((Health) mod (2)) + (1))\n        else\n            switch costume to (0 v)\n        end\n    else\n        switch costume to (4 v)\n    end\nend\n\nwhen I receive [game complete v]\nset [creator v] to [1]\nhide\nswitch costume to (4 v)\nset [heart number v] to [1]\ngo to x: (-220) y: (-179)\ncreate clone of (_myself_ v)\ngo to x: (-195) y: (-179)\nset [heart number v] to [2]\ncreate clone of (_myself_ v)\n\n@Boss\n\nwhen flag clicked\nset [creator v] to [1]\nset [imbullet v] to [0]\nhide\n\nwhen I start as a clone\nset [creator v] to [0]\nif <(imBullet) = [0]> then\n    set [speed v] to [10]\n    set [mystate v] to [Intro]\n    set [boss health v] to [10]\nend\nif <(imBullet) = [1]> then\n    switch costume to (costume1 v)\nend\nif <(imBullet) = [2]> then\n    set [i v] to [0]\nend\nshow\n\nwhen I receive [step v]\nif <(creator) = [0]> then\n    if <(imBullet) = [0]> then\n        BOSS\n    end\n    if <(imBullet) = [1]> then\n        Bullet movement\n    end\n    if <(imBullet) = [2]> then\n        change [i v] by (20)\n        set [ghost v] effect to (i)\n        if <(i) > [90]> then\n            delete this clone\n        end\n    end\nend\n\nwhen I receive [room change v]\nif <(creator) = [1]> then\n    broadcast (Delete Boss v)\n    if <(ROOM) = [15]> then\n        if <(Boss defeated) = [0]> then\n            Create boss at [15] [2]\n        end\n    end\nend\n\nwhen I receive [delete boss v]\ndelete this clone\n\ndefine Create boss at (x) (y)\nswitch costume to (boss_left v)\ngo to x: (((x) * (20)) - (250)) y: (((y) * (20)) - (200))\ncreate clone of (_myself_ v)\n\nwhen I receive [boss intro v]\nif <(creator) = [0]> then\n    if <(myState) = [Intro]> then\n        change [i v] by (1)\n        if <(i) = [40]> then\n            set [music v] to [Silence]\n            stop all sounds\n            say [Congratulation! You have reached the end of this trial.]\n            set [mystate v] to [talking]\n            set [i v] to [1]\n        end\n    end\n    if <(myState) = [talking]> then\n        if <([spacepressed v] of [input v]) = [1]> then\n            change [i v] by (1)\n        end\n        if <(i) = [1]> then\n            say [Congratulation! You have reached the end of this trial.]\n        end\n        if <(i) = [2]> then\n            say (join [You're last challenge is to defeat me, the great ] (Last player to complete this game))\n        end\n        if <(i) = [3]> then\n            say [If you succeed, I will give you my blue ninja suit...]\n        end\n        if <(i) = [4]> then\n            say [which mean you will be considered the strongest ninja in this world!]\n        end\n        if <(i) = [5]> then\n            say []\n            broadcast (Boss door v)\n            hide\n            set [music v] to [Boss]\n            set [mystate v] to [Dissapear]\n            set [game state v] to [Play]\n        end\n    end\nend\n\nwhen I receive [animate v]\nif <(imBullet) = [0]> then\n    if <([x position v] of [player v]) > (x position)> then\n        if <(myState) = [Appear]> then\n            switch costume to (boss_right v)\n        end\n    else\n        if <(myState) = [Appear]> then\n            switch costume to (boss_left v)\n        end\n    end\n    if <(myState) = [Shoot]> then\n        if <(Shot Ani) = [0]> then\n            switch costume to (boss_shoot_1 v)\n        else\n            switch costume to (boss_shoot_2 v)\n        end\n    end\n    if <(myState) = [Dash]> then\n        if <(targetX) > [0]> then\n            switch costume to (boss_right_dash v)\n        else\n            switch costume to (boss_left_dash v)\n        end\n    end\nend\nif <(imBullet) = [1]> then\n    if <(costume [number v]) = [8]> then\n        switch costume to (costume1 v)\n    else\n        next costume\n    end\nend\nif <(InviTime) > [0]> then\n    if <((InviTime) mod (2)) = [0]> then\n        if <((InviTime) mod (4)) = [0]> then\n            set [ghost v] effect to (50)\n        else\n            set [ghost v] effect to (0)\n        end\n    end\nend\n\ndefine Shoot\nset [imbullet v] to [1]\nset [mydir v] to [right]\ncreate clone of (_myself_ v)\nset [mydir v] to [down]\ncreate clone of (_myself_ v)\nset [mydir v] to [left]\ncreate clone of (_myself_ v)\nset [mydir v] to [up]\ncreate clone of (_myself_ v)\nset [imbullet v] to [0]\n\ndefine BOSS\nif <(myState) = [Intro]> then\n    if <([x position v] of [player v]) > [-100]> then\n        set [game state v] to [Boss Intro]\n        set [i v] to [1]\n    end\nend\nif <(myState) = [Dissapear]> then\n    change [i v] by (1)\n    if <(i) = [50]> then\n        set [mystate v] to [Appear]\n        set [i v] to (pick random (1) to (5))\n        if <(i) = [1]> then\n            go to x: (-109) y: (-60)\n        end\n        if <(i) = [2]> then\n            go to x: (107) y: (-60)\n        end\n        if <(i) = [3]> then\n            go to x: (0) y: (18)\n        end\n        if <(i) = [4]> then\n            go to x: (110) y: (99)\n        end\n        if <(i) = [5]> then\n            go to x: (-107) y: (99)\n        end\n        show\n    end\nend\nif <(myState) = [Appear]> then\n    change [i v] by (1)\n    if <(i) = [50]> then\n        set [i v] to (pick random (1) to (2))\n        if <(i) = [1]> then\n            set [shootcounter v] to [0]\n            set [numberofshoot v] to (pick random (3) to (5))\n            set [mystate v] to [Shoot]\n        end\n        if <(i) = [2]> then\n            Calculate target\n            set [mystate v] to [Dash]\n        end\n    end\nend\nif <(myState) = [Shoot]> then\n    if <(shootCounter) = [0]> then\n        set [diag v] to (pick random (0) to (1))\n        Shoot\n        set [shot ani v] to [1]\n        change [shootcounter v] by (1)\n    end\n    if <(i) > [50]> then\n        if <(shootCounter) = (numberOfShoot)> then\n            set [i v] to [1]\n            hide\n            set [mystate v] to [Dissapear]\n        else\n            set [diag v] to (pick random (0) to (1))\n            Shoot\n            set [shot ani v] to [1]\n            change [shootcounter v] by (1)\n            set [i v] to [1]\n        end\n    end\n    if <(i) = [20]> then\n        set [shot ani v] to [0]\n    end\n    change [i v] by (1)\nend\nif <(myState) = [Dash]> then\n    change [i v] by (1)\n    if <(i) > [3]> then\n        set [i v] to [0]\n        create shadow\n    end\n    change x by (targetX)\n    change y by (targetY)\n    if <<(x position) > [230]> or <<(y position) > [150]> or <<(x position) < [-230]> or <(y position) < [-170]>>>> then\n        set [i v] to [1]\n        hide\n        set [mystate v] to [Dissapear]\n    end\nend\nif <(InviTime) > [0]> then\n    change [invitime v] by (-1)\nend\nif <(Boss defeated) = [0]> then\n    Check for death\nend\n\ndefine Bullet movement\nif <(Diag) = [0]> then\n    if <(myDir) = [right]> then\n        change x by (5)\n    end\n    if <(myDir) = [down]> then\n        change y by (5)\n    end\n    if <(myDir) = [left]> then\n        change x by (-5)\n    end\n    if <(myDir) = [up]> then\n        change y by (-5)\n    end\nend\nif <(Diag) = [1]> then\n    if <(myDir) = [right]> then\n        change x by (3.5)\n        change y by (-3.5)\n    end\n    if <(myDir) = [down]> then\n        change x by (-3.5)\n        change y by (-3.5)\n    end\n    if <(myDir) = [left]> then\n        change x by (-3.5)\n        change y by (3.5)\n    end\n    if <(myDir) = [up]> then\n        change x by (3.5)\n        change y by (3.5)\n    end\nend\nif <<(x position) > [239]> or <<(y position) > [179]> or <<(x position) < [-239]> or <(y position) < [-179]>>>> then\n    delete this clone\nend\n\nwhen I receive [enemy hit v]\nif <(creator) = [0]> then\n    if <touching (player v)?> then\n        if <(imBullet) = [0]> then\n            if <not <(myState) = [Dash]>> then\n                if <(InviTime) < [1]> then\n                    change [boss health v] by (-1)\n                    set [i v] to [1]\n                    start sound [hit v]\n                    set [invitime v] to [60]\n                end\n            end\n        end\n    end\nend\n\ndefine Calculate target\nset [targetx v] to ([x position v] of [player v])\nset [targety v] to ([y position v] of [player v])\nset [diffx v] to ((targetX) - (x position))\nset [diffy v] to ((targetY) - (y position))\nset [angle v] to ([atan v] of ((diffY) / (diffX)) )\nset [targetx v] to ((speed) * ([cos v] of (angle) ))\nset [targety v] to ((speed) * ([sin v] of (angle) ))\nif <(diffY) > [0]> then\n    if <(targetY) < [0]> then\n        set [targety v] to ((-1) * (targetY))\n    end\nelse\n    if <(targetY) > [0]> then\n        set [targety v] to ((-1) * (targetY))\n    end\nend\nif <(diffX) > [0]> then\n    if <(targetX) < [0]> then\n        set [targetx v] to ((-1) * (targetX))\n    end\nelse\n    if <(targetX) > [0]> then\n        set [targetx v] to ((-1) * (targetX))\n    end\nend\n\ndefine create shadow\nset [imbullet v] to [2]\ncreate clone of (_myself_ v)\nset [imbullet v] to [0]\n\ndefine Check for death\nif <(Boss Health) < [1]> then\n    set [boss defeated v] to [1]\n    set [mystate v] to [Defeat]\n    broadcast (Delete Doors v)\n    set [music v] to [End]\n    stop all sounds\n    hide\nend\n\nwhen I receive [game complete v]\nset [creator v] to [1]\nset [imbullet v] to [0]\nhide\n\n
Controls\n--------------------\nAWSD ---> Move your ninja\nArrow keys ----> use your sword in any direction\nSpace ----> Talk to people\n\nTry to complete the trial of the great ninja to become the new strongest ninja on earth.\n\n