platformer 2d cube v5.1


@Stage\n\nwhen flag clicked\nbroadcast (game v)\nforever\n    play sound [ParagonX9 - Chaoz Fantasy v] until done\nend\n\nwhen flag clicked\nforever\n    if <(level) = [15]> then\n        switch backdrop to (sky v)\n    else\n        switch backdrop to (sky h v)\n    end\nend\n\n@Blank\n\n@player\n\nwhen I receive [game v]\nshow\nreset timer\nstart\ntick\nforever\n    gravity <(gravity) > [0]>\n    jump\n    set [time v] to (timer)\n    set [cy v] to (y position)\n    set [cx v] to (x position)\n    x control\n    if <(x position) > [224]> then\n        start\n        change [level v] by (1)\n        broadcast (next lavel v)\n        wait (0.2) seconds\n    end\n    if <(y position) < [-180]> then\n        start\n    end\n    if <touching (obstacles v)?> then\n        start\n    end\n    if <touching (bat v)?> then\n        start sound [Big Boing v]\n        change [gravity v] by (35)\n    end\n    if <(gravity) = [0]> then\n        if <touching (red cube v)?> then\n            start\n        end\n    end\n    if <touching (cul v)?> then\n        start\n    end\n    if <touching (cul2 v)?> then\n        start\n    end\n    if <touching (_2 v)?> then\n        start\n    end\n    if <touching (red cube3 v)?> then\n        start\n    end\n    if <touching (_3 v)?> then\n        start\n    end\nend\n\ndefine gravity <y>\nchange [gravity v] by (-1)\nchange y by (gravity)\nchange [back v] by (1)\nrepeat until <not <<touching (platforma v)?> or <touching (ground v)?>>>\n    if <y> then\n        change [gravity v] by (-1)\n        change y by (-2)\n    else\n        change y by (1)\n        set [gravity v] to [0]\n    end\n    set [back v] to [0]\nend\n\ndefine jump\nif <key (up arrow v) pressed?> then\n    if <<(jamp) = [0]> and <(back) < [3]>> then\n        set [gravity v] to [15]\n        set [jamp v] to [1]\n    end\nelse\n    set [jamp v] to [0]\nend\n\ndefine start\nbroadcast (start v)\nset [gravity v] to [0]\ngo to x: (-200) y: (-30)\n\nwhen I receive [game v]\nforever\n    if <key (right arrow v) pressed?> then\n        switch costume to (cube v)\n    end\n    if <key (left arrow v) pressed?> then\n        switch costume to (cube2 v)\n    end\nend\n\ndefine tick\nset [level v] to [1]\nset [jamp v] to [12]\nset [gravity v] to [0]\nset [back v] to [0]\nset [time v] to [0]\nset [sx v] to [5]\n\ndefine x control\nset rotation style [left-right v]\nif <key (left arrow v) pressed?> then\n    change x by ((0) - (sx))\n    if <<touching (ground v)?> or <touching (platforma v)?>> then\n        change x by (sx)\n    end\nend\nif <key (right arrow v) pressed?> then\n    change x by (sx)\n    if <<touching (ground v)?> or <touching (platforma v)?>> then\n        change x by ((0) - (sx))\n    end\nend\n\nwhen flag clicked\nhide\n\n@foto\n\nwhen flag clicked\nforever\n    go to [front v] layer\n    set [ghost v] effect to (100)\n    go to x: (0) y: (0)\nend\n\n@_3\n\nwhen I receive [game v]\nhide\nforever\n    if <(level) = [14]> then\n        wait (3) seconds\n        create clone of (_myself_ v)\n    end\nend\n\nwhen I start as a clone\nshow\ngo to x: (234) y: (pick random (-96) to (96))\nforever\n    change x by (-3)\n    if <(x position) < [-234]> then\n        delete this clone\n    end\nend\n\n@_2\n\nwhen I receive [boom3 v]\nshow\nif <(level) = [13]> then\n    go to (red cube3 v)\n    point in direction ([direction v] of [red cube3 v])\n    move (10) steps\n    repeat until <touching (_edge_ v)?>\n        move (10) steps\n    end\n    if <touching (player v)?> then\n        set size to (130) %\n        wait (0.2) seconds\n        hide\n    end\n    hide\n    delete this clone\nelse\n    if <(level) = [14]> then\n        go to (red cube3 v)\n        point in direction ([direction v] of [red cube3 v])\n        move (10) steps\n        repeat until <touching (_edge_ v)?>\n            move (10) steps\n        end\n        if <touching (player v)?> then\n            set size to (130) %\n            wait (0.2) seconds\n            hide\n        end\n        hide\n        delete this clone\n    else\n        delete this clone\n    end\nend\n\nwhen I receive [boom3 v]\nrepeat (15)\n    create clone of (_myself_ v)\nend\n\nwhen I receive [game v]\nhide\nhide\ndelete this clone\n\nwhen flag clicked\nhide\n\nwhen I start as a clone\nshow\n\n@red cube3\n\nwhen flag clicked\nhide\n\nwhen I receive [game v]\nhide\nforever\n    if <(level) = [13]> then\n        point towards (player v)\n    else\n        if <(level) = [14]> then\n            point towards (player v)\n        else\n            hide\n        end\n    end\nend\n\nwhen I receive [game v]\nhide\nforever\n    if <(level) = [13]> then\n        go to x: (130) y: (-100)\n        show\n        wait (4) seconds\n        broadcast (boom3 v)\n    else\n        if <(level) = [14]> then\n            go to x: (130) y: (-100)\n            show\n            wait (4) seconds\n            broadcast (boom3 v)\n        else\n            hide\n        end\n    end\nend\n\n@red cube2\n\nwhen flag clicked\nhide\n\nwhen I receive [game v]\nhide\nforever\n    if <(level) = [11]> then\n        point towards (player v)\n    else\n        if <(level) = [12]> then\n            point towards (player v)\n        else\n            if <(level) = [14]> then\n                point towards (player v)\n            else\n                hide\n            end\n        end\n    end\nend\n\nwhen I receive [game v]\nhide\nforever\n    if <(level) = [11]> then\n        go to x: (-205) y: (117)\n        show\n        set [b v] to (pick random (1) to (2))\n        wait (2) seconds\n        if <[1] = (b)> then\n            broadcast (boom v)\n        end\n        if <[2] = (b)> then\n            broadcast (boom2 v)\n        end\n    else\n        if <(level) = [12]> then\n            go to x: (197) y: (131)\n            show\n            set [b v] to (pick random (1) to (2))\n            wait (2) seconds\n            if <[1] = (b)> then\n                broadcast (boom v)\n            end\n            if <[2] = (b)> then\n                broadcast (boom2 v)\n            end\n        else\n            if <(level) = [14]> then\n                go to x: (-7) y: (144)\n                show\n                set [b v] to (pick random (1) to (2))\n                wait (2) seconds\n                if <[1] = (b)> then\n                    broadcast (boom v)\n                end\n                if <[2] = (b)> then\n                    broadcast (boom2 v)\n                end\n            else\n                hide\n            end\n        end\n    end\nend\n\n@cul2\n\nwhen flag clicked\nhide\ndelete this clone\n\nwhen I receive [boom v]\nrepeat (10)\n    create clone of (_myself_ v)\n    wait (0.1) seconds\nend\n\nwhen I start as a clone\nshow\ngo to (red cube2 v)\npoint in direction ([direction v] of [red cube2 v])\nmove (10) steps\nrepeat until <<touching (ground v)?> or <<touching (player v)?> or <touching (_edge_ v)?>>>\n    move (10) steps\nend\nif <<touching (ground v)?> or <touching (_edge_ v)?>> then\n    hide\nend\nif <touching (player v)?> then\n    set size to (130) %\n    wait (0.2) seconds\n    hide\nend\n\n@cul\n\nwhen flag clicked\nhide\ndelete this clone\n\nwhen I receive [next lavel v]\nif <(level) = [9]> then\n    hide\n    repeat (5)\n        create clone of (_myself_ v)\n        wait (0.3) seconds\n    end\n    stop [this script v]\nelse\n    if <(level) = [9]> then\n        hide\n        repeat (5)\n            create clone of (_myself_ v)\n            wait (0.3) seconds\n        end\n        stop [this script v]\n    else\n        hide\n    end\nend\n\nwhen I start as a clone\nshow\nset size to (100) %\ngo to x: (pick random (-240) to (240)) y: (180)\nforever\n    change y by (-3)\n    if <not <(level) = [14]>> then\n        if <<touching (obstacles v)?> or <touching (ground v)?>> then\n            set size to (120) %\n            wait (0.2) seconds\n            delete this clone\n        end\n    end\n    if <(level) = [14]> then\n        if <touching (ground v)?> then\n            set size to (120) %\n            wait (0.2) seconds\n            delete this clone\n        end\n    end\nend\n\nwhen I receive [start v]\nif <(level) = [9]> then\n    hide\n    repeat (5)\n        create clone of (_myself_ v)\n        wait (0.3) seconds\n    end\n    stop [this script v]\nelse\n    hide\nend\n\nwhen I receive [boom2 v]\nif <(level) = [11]> then\n    hide\n    repeat (5)\n        create clone of (_myself_ v)\n        wait (0.3) seconds\n    end\n    stop [this script v]\nelse\n    if <(level) = [12]> then\n        hide\n        repeat (5)\n            create clone of (_myself_ v)\n            wait (0.3) seconds\n        end\n        stop [this script v]\n    else\n        if <(level) = [14]> then\n            hide\n            repeat (5)\n                create clone of (_myself_ v)\n                wait (0.3) seconds\n            end\n            stop [this script v]\n        else\n            hide\n        end\n    end\nend\n\n@red cube\n\nwhen flag clicked\nhide\n\nwhen I receive [game v]\nhide\nforever\n    if <<(level) = [10]> or <<(level) = [8]> or <(level) = [12]>>> then\n        if <(show) = [0]> then\n            show\n        end\n    else\n        hide\n    end\nend\n\nwhen I receive [game v]\nhide\nforever\n    if <<(level) = [10]> or <<(level) = [8]> or <(level) = [12]>>> then\n        if <not <touching (ground v)?>> then\n            if <(cx) > (x position)> then\n                change x by (3)\n            end\n        end\n        if <not <touching (ground v)?>> then\n            if <(x position) > (cx)> then\n                change x by (-3)\n            end\n        end\n    else\n        hide\n    end\nend\n\nwhen I receive [game v]\nhide\nforever\n    if <<(level) = [10]> or <<(level) = [8]> or <(level) = [12]>>> then\n        if <[0] > (gravity)> then\n            if <touching (player v)?> then\n                set [show v] to [1]\n                hide\n            end\n        end\n        if <(y position) < [-180]> then\n            set [show v] to [1]\n            hide\n        end\n    else\n        hide\n    end\nend\n\nwhen I receive [next lavel v]\nif <(level) = [8]> then\n    go to x: (204) y: (94)\n    set [show v] to [0]\n    set [y v] to [0]\nend\n\nwhen I receive [game v]\nhide\nforever\n    if <<(level) = [10]> or <<(level) = [8]> or <(level) = [12]>>> then\n        change [y v] by (-1)\n        change y by (y)\n        repeat until <not <<touching (platforma v)?> or <touching (ground v)?>>>\n            change y by (1)\n            set [y v] to [0]\n        end\n    else\n        hide\n    end\nend\n\nwhen I receive [start v]\nif <(level) = [8]> then\n    go to x: (204) y: (94)\n    set [show v] to [0]\n    set [y v] to [0]\nend\n\nwhen I receive [next lavel v]\nif <(level) = [10]> then\n    go to x: (-178) y: (135)\n    set [show v] to [0]\n    set [y v] to [0]\nend\n\nwhen I receive [start v]\nif <(level) = [10]> then\n    go to x: (-178) y: (135)\n    set [show v] to [0]\n    set [y v] to [0]\nend\n\nwhen I receive [start v]\nif <(level) = [12]> then\n    go to x: (174) y: (-95)\n    set [show v] to [0]\n    set [y v] to [0]\nend\n\nwhen I receive [next lavel v]\nif <(level) = [12]> then\n    go to x: (174) y: (-95)\n    set [show v] to [0]\n    set [y v] to [0]\nend\n\n@platforma\n\nwhen flag clicked\nhide\n\nwhen I receive [game v]\nhide\n\nwhen I receive [next lavel v]\nforever\n    if <not <<(level) = [8]> or <(level) = [9]>>> then\n        hide\n        stop [this script v]\n    end\n    if <(level) = [8]> then\n        go to x: (120) y: (65)\n        show\n        glide (2) secs to x: (-120) y: (65)\n        glide (2) secs to x: (120) y: (65)\n    else\n        if <(level) = [9]> then\n            go to x: (85) y: (-51)\n            show\n            glide (2) secs to x: (-96) y: (-51)\n            glide (2) secs to x: (85) y: (-51)\n        else\n            hide\n        end\n    end\nend\n\n@bat\n\nwhen flag clicked\nhide\n\nwhen I receive [game v]\nforever\n    if <(level) = [5]> then\n        go to x: (116) y: (-110)\n        show\n    else\n        if <(level) = [6]> then\n            go to x: (-8) y: (-110)\n            show\n        else\n            if <(level) = [7]> then\n                go to x: (190) y: (-69)\n                show\n            else\n                if <(level) = [8]> then\n                    go to x: (-139) y: (-110)\n                    show\n                else\n                    if <(level) = [10]> then\n                        go to x: (61) y: (-110)\n                        show\n                    else\n                        hide\n                    end\n                end\n            end\n        end\n    end\nend\n\n@_\n\nwhen I receive [game v]\ngo to x: (0) y: (240)\nforever\n    wait (25) seconds\n    glide (0.5) secs to x: (0) y: (170)\n    wait (3) seconds\n    glide (0.5) secs to x: (0) y: (240)\nend\n\n@cloud2\n\nwhen I receive [game v]\nhide\nforever\n    if <(level) = [15]> then\nend\n\nwhen flag clicked\nhide\n\nwhen I start as a clone\ngo to [back v] layer\nshow\ngo [backward v] (pick random (1) to (2)) layers\ngo to x: (-271) y: (pick random (-100) to (100))\nset size to (pick random (10) to (100)) %\nset [ghost v] effect to (pick random (25) to (70))\nset [x v] to [3]\nset [y v] to (pick random (0) to (1))\nrepeat (10)\n    change x by (x)\n    if <(y) = [0]> then\n        change y by (-0.03)\n    end\n    if <(y) = [1]> then\n        change y by (0.03)\n    end\nend\nrepeat (200)\n    change x by (x)\n    if <(y) = [0]> then\n        change y by (-0.3)\n    end\n    if <(y) = [1]> then\n        change y by (0.3)\n    end\nend\ndelete this clone\n\n@cloud\n\nwhen I receive [game v]\nhide\nforever\n    if <(level) = [15]> then\nend\n\nwhen flag clicked\nhide\n\nwhen I start as a clone\nshow\ngo to [back v] layer\ngo [backward v] (pick random (1) to (2)) layers\ngo to x: (271) y: (pick random (-100) to (100))\nset size to (pick random (10) to (100)) %\nset [ghost v] effect to (pick random (25) to (70))\nset [x v] to [-3]\nset [y v] to (pick random (0) to (1))\nrepeat (10)\n    change x by (x)\n    if <(y) = [0]> then\n        change y by (-0.03)\n    end\n    if <(y) = [1]> then\n        change y by (0.03)\n    end\nend\nrepeat (200)\n    change x by (x)\n    if <(y) = [0]> then\n        change y by (-0.3)\n    end\n    if <(y) = [1]> then\n        change y by (0.3)\n    end\nend\ndelete this clone\n\n@obstacles\n\nwhen flag clicked\nhide\nswitch costume to (1 v)\nforever\n    go to x: (0) y: (0)\nend\n\nwhen I receive [next lavel v]\nnext costume\n\nwhen I receive [game v]\nshow\n\n@ground\n\nwhen flag clicked\nhide\nswitch costume to (1 v)\nforever\n    go to x: (0) y: (0)\nend\n\nwhen I receive [next lavel v]\nnext costume\n\nwhen I receive [game v]\nshow\n\n