Platformer Engine | mobile friendly!

Instructions: ◈◈◈◈◈◈◈◈◈◈◈ Hello!!! ◈◈◈◈◈◈◈◈◈◈◈◈◈◈\n@imthebesttt here!! <3\n\nThis is a mobile friendly platformer engine! It's feature-packed and ready for you to use! Just remix! :D\n\nHere's an example!:\nhttps://scratch.mit.edu/projects/487937961/\nLook at other engines made by me here!:\nhttps://scratch.mit.edu/studios/28837169/projects/\n\n◈◈◈◈◈◈◈◈◈◈◈ Controls ◈◈◈◈◈◈◈◈◈◈◈◈◈\n\nmovement - ←↕→, WASD, or mobile\nreset - R\nsquish - S, ↓, or squish button\n\n◈◈◈◈◈◈ Problems? Ideas? Feedback? ◈◈◈◈◈◈◈\n\nThis game is new, so bugs are probably gonna be hidden some where—smash em' by commenting them below! (No need to restart the game if you come across a bug. Press R to reset then report it in the comments!)\n\nIf you have any questions, suggestions, bugs, or new feature ideas, comment below!\n\n◈◈◈◈◈◈◈◈◈◈ Current Features ◈◈◈◈◈◈◈◈◈◈\n\n• water - so you can add pools and maybe even levels under water!\n• danger - make perfect obstacles to challenge your player!\n• trampoline - Let the player jump to high places with the help of trampolines!\n• Wall jumping - A useful feature needed when jumping towards walls!\n• Enemies - challenge the player to a battle! You can jump on top of them to defeat them ;)\n• Saws - keep the player cautious as they attempt to pass the spinning saws!\n• Squish - made to let the player squeeze through tight spaces! On mobile you can press the button on the right!\n• Power ups & coins - Collect coins and power ups!\n• Timer + Highscore - Have the player try hard to beat the highscore!\n\n◈◈◈◈◈◈◈◈◈ Thanks for reading! ◈◈◈◈◈◈◈◈◈\nI hope you have fun! I can't wait to see what you make!\n\nBye! <3

@Stage\n\nwhen flag clicked\nforever\n    if <([sound v] of [sound v]) = [0]> then\n        set volume to (0) %\n        stop all sounds\n    else\n        set volume to (30) %\n        play sound [ v] until done\n    end\nend\n\n@player\n\nwhen flag clicked\nhide\nset [creator v] to [imthebesttt]\n\ndefine reset\nreset settings\ngo to x: (spawnX) y: (spawnY)\nset [xv v] to [0]\nset [yv v] to [0]\nset [jumping? v] to [0]\nset [squished? v] to [0]\nswitch costume to (normal v)\nset size to (100) %\nclear graphic effects\ngo to [front v] layer\nset rotation style [left-right v]\nbroadcast (reset v)\n\nwhen I receive [newlevel v]\nreset\n\nwhen [r v] key pressed\nreset\n\nwhen I receive [start v]\nset [pressingbutton? v] to [0]\nreset\nstart sound [connect v]\nforever\n    loop\nend\n\nwhen [t v] key pressed\nif <(username) = (creator)> then\n    if <not <(level) = [end]>> then\n        set [prevlevel v] to (level)\n        go to (end v)\n        repeat until <not <(prevLevel) = (level)>>\n            set [prevlevel v] to (level)\n        end\n    end\nend\n\ndefine key controls\nif <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n    jump\nend\nif <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n    point in direction (-90)\n    change [xv v] by ((speed) * (-1))\nend\nif <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n    point in direction (90)\n    change [xv v] by (speed)\nend\n\ndefine gravity\nchange [yv v] by ((gravity) * (-1))\nif <<<touching (water v)?> and <not <touching (level v)?>>> and <(jumping?) = [0]>> then\n    set [yv v] to [-1]\nend\nif <not <touching (enemy v)?>> then\n    change y by (yv)\n    if <touching (enemy v)?> then\n        set [killenemy? v] to [1]\n    end\nelse\n    change y by (yv)\nend\nif <(yv) < [1]> then\n    set [jumping? v] to [0]\nelse\n    if <touching (level v)?> then\n        set [yv v] to [0]\n        set [jumping? v] to [0]\n        repeat until <not <touching (level v)?>>\n            change y by (-1)\n        end\n    end\nend\n\ndefine switch costume\nswitch costume to (move v)\nif <(jumping?) = [1]> then\n    switch costume to (upmove v)\nend\nif <(round (xv)) = [0]> then\n    point in direction (90)\n    switch costume to (normal v)\n    if <(jumping?) = [1]> then\n        switch costume to (up v)\n    end\n    if <(yv) < ((gravity) * (-1))> then\n        switch costume to (down v)\n    end\nend\nif <(squished?) = [1]> then\n    point in direction (90)\n    switch costume to (squished v)\nend\n\ndefine jump\nif <touching (water v)?> then\n    set [yv v] to [3]\n    set [jumping? v] to [1]\nelse\n    change y by (-1)\n    if <<<touching (level v)?> or <touching (water v)?>> and <(jumping?) = [0]>> then\n        set [yv v] to (jumpHeight)\n        set [jumping? v] to [1]\n        start sound [jump v]\n    end\n    change y by (1)\nend\n\ndefine left & right movement\nif <<touching (water v)?> and <<(xv) < ((maxWaterSpeed) * (-1))> or <(xv) > (maxWaterSpeed)>>> then\n    set [xv v] to (((xv) / ([abs v] of (xv) )) * (maxWaterSpeed))\nend\nset [xv v] to ((xv) * (friction))\nset [touchingtrampoline v] to [0]\nif <touching (trampoline v)?> then\n    set [touchingtrampoline v] to [1]\nend\nchange x by (xv)\nif <<(touchingTrampoline) = [0]> and <touching (trampoline v)?>> then\n    repeat until <not <touching (trampoline v)?>>\n        change x by (((xv) / ([abs v] of (xv) )) * (-1))\n    end\n    change x by (((xv) / ([abs v] of (xv) )) * (-1))\nend\nif <touching (level v)?> then\n    change y by (8)\n    if <touching (level v)?> then\n        change y by (-8)\n        repeat until <not <touching (level v)?>>\n            change x by (((xv) / ([abs v] of (xv) )) * (-1))\n        end\n        if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<(mouse y) > [0]> and <mouse down?>>> then\n            set [xv v] to (((xv) / ([abs v] of (xv) )) * ((-1) * (jumpHeight)))\n            set [yv v] to (jumpHeight)\n            set [jumping? v] to [1]\n        end\n    else\n        repeat until <touching (level v)?>\n            change y by (-1)\n        end\n        repeat until <not <touching (level v)?>>\n            change y by (1)\n        end\n    end\nelse\n    if <(jumping?) = [0]> then\n        change y by (-8)\n        if <touching (level v)?> then\n            repeat until <not <touching (level v)?>>\n                change y by (1)\n            end\n        else\n            change y by (8)\n        end\n    end\nend\n\ndefine mobile controls\nif <<mouse down?> and <(pressingButton?) = [0]>> then\n    if <(mouse y) > [0]> then\n        jump\n    end\n    if <(mouse x) < [0]> then\n        point in direction (-90)\n        change [xv v] by ((speed) * (-1))\n    end\n    if <(mouse x) > [0]> then\n        point in direction (90)\n        change [xv v] by (speed)\n    end\nend\n\nwhen I start as a clone\nif <(squished?) = [1]> then\n    switch costume to (squishedclone v)\nelse\n    switch costume to (clone v)\nend\nset [ghost v] effect to (0)\nset size to (100) %\nrepeat (10)\n    change size by (-10)\n    change [ghost v] effect by (10)\nend\ndelete this clone\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine rise to ground\nrepeat until <not <touching (level v)?>>\n    change y by (1)\n    set [yv v] to [0]\nend\n\ndefine sprite interactions\nif <<<touching (danger v)?> or <touching (saw v)?>> or <<touching (enemy v)?> and <(killEnemy?) = [0]>>> then\n    start sound [die v]\n    reset\nend\nif <touching (trampoline v)?> then\n    set [yv v] to (((yv) / ([abs v] of (yv) )) * ((trampolineHeight) * (-1)))\n    if <(yv) > [0]> then\n        set [jumping? v] to [1]\n        start sound [jump v]\n    end\nend\n\ndefine loop\nchange y by (1)\nkey controls\nmobile controls\nleft & right movement\ngravity\nrise to ground\nsprite interactions\nswitch costume\nchange y by (-1)\ncreate clone of (_myself_ v)\nshow\n\nwhen flag clicked\nforever\n    if <([sound v] of [sound v]) = [0]> then\n        set volume to (0) %\n    else\n        set volume to (30) %\n    end\nend\n\nwhen I receive [powerups: speed v]\nchange [speed v] by (1)\n\ndefine reset settings\nset [gravity v] to [0.8]\nset [jumpheight v] to [12]\nset [trampolineheight v] to [15]\nset [friction v] to [0.85]\nset [maxwaterspeed v] to [1.5]\nset [speed v] to [1]\nset [spawnx v] to [-200]\nset [spawny v] to [35]\nset [camerax v] to [0]\nset [cameray v] to [0]\n\nwhen I receive [powerups: jump v]\nchange [jumpheight v] by (2)\n\n@level\n\nwhen flag clicked\nsetup\n\ndefine find last level (currlevel)\nset [last level v] to [0]\nrepeat until <(costume [number v]) = [1]>\n    set [last level v] to (costume [number v])\n    next costume\nend\nif <(last level) = [0]> then\n    next costume\n    if <(costume [number v]) = [1]> then\n        set [last level v] to [1]\n    else\n        repeat until <(costume [number v]) = [1]>\n            set [last level v] to (costume [number v])\n            next costume\n        end\n    end\nend\nswitch costume to (currlevel)\n\nwhen I receive [find last level v]\nfind last level (costume [name v])\n\ndefine setup\ngo to [back v] layer\ngo to x: (0) y: (0)\nrepeat until <(costume [number v]) = [1]>\n    next costume\nend\nfind last level (costume [name v])\nset [level v] to [1]\nbroadcast (start v)\nshow\n\nwhen I receive [newlevel v]\nnext costume\nshow\n\n@water\n\nwhen flag clicked\nhide\n\nwhen I receive [newlevel v]\nif <(level) = [end]> then\n    hide\nelse\n    next costume\nend\n\nwhen I receive [start v]\nrepeat until <(costume [number v]) = [1]>\n    next costume\nend\ngo to x: (0) y: (0)\nshow\n\n@danger\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\nrepeat until <(costume [number v]) = [1]>\n    next costume\nend\ngo to x: (0) y: (0)\nshow\n\nwhen I receive [newlevel v]\nif <(level) = [end]> then\n    hide\nelse\n    next costume\nend\n\n@saw\n\nwhen flag clicked\nforever\n    hide\nend\n\nwhen I receive [start v]\nreset\n\nwhen I receive [newlevel v]\nif <[0] = [0]> then\n    delete this clone\nend\nreset\n\ndefine reset\nif <(level) = [4]> then\n    spawn saw at x: [-100] y: [-70]\n    spawn saw at x: [10] y: [-65]\n    spawn saw at x: [120] y: [-65]\nend\nif <(level) = [9]> then\n    spawn saw at x: [90] y: [50]\nend\n\nwhen I start as a clone\nforever\n    if <touching (player v)?> then\n        switch costume to (jumppad2 v)\n    else\n        switch costume to (jumppad1 v)\n    end\n    show\nend\n\ndefine spawn saw at x: (x) y: (y)\ngo to x: (x) y: (y)\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\ngo to [back v] layer\npoint in direction (90)\nshow\nset [vel v] to [0]\nset [sawdirection v] to [-1]\nforever\n    repeat (20)\n        change [vel v] by (1)\n        turn right ((vel) * (sawDirection)) degrees\n    end\n    repeat (20)\n        change [vel v] by (-1)\n        turn right ((vel) * (sawDirection)) degrees\n    end\n    set [sawdirection v] to ((sawDirection) * (-1))\n    wait (0.1) seconds\nend\n\n@trampoline\n\nwhen I receive [newlevel v]\nif <[0] = [0]> then\n    delete this clone\nend\nreset\n\nwhen I receive [start v]\nreset\n\ndefine reset\nif <(level) = [3]> then\n    spawn trampoline at x: [0] y: [-55] direction: []\n    spawn trampoline at x: [0] y: [60] direction: [-90]\n    spawn trampoline at x: [0] y: [75] direction: []\nend\nif <(level) = [9]> then\n    spawn trampoline at x: [210] y: [180] direction: [-90]\nend\n\ndefine spawn trampoline at x: (x) y: (y) direction: (d)\nif <(d) = []> then\n    point in direction (90)\nelse\n    point in direction (d)\nend\ngo to x: (x) y: (y)\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nforever\n    if <<touching (player v)?> or <touching (enemy v)?>> then\n        switch costume to (jumppad2 v)\n    else\n        switch costume to (jumppad1 v)\n    end\n    show\nend\n\nwhen flag clicked\npoint in direction (90)\nforever\n    hide\nend\n\n@collectible\n\ndefine reset\nif <(level) = [8]> then\n    spawn coin - x: [-75] y: [-40]\n    spawn coin - x: [-30] y: [-40]\n    spawn coin - x: [15] y: [-40]\n    spawn coin - x: [60] y: [-40]\nend\nif <(level) = [9]> then\n    spawn coin - x: [0] y: [-10]\nend\nif <(coinsFloat?) = [1]> then\n    broadcast (hoverCoins v)\nend\n\ndefine spawn coin - x: (x) y: (y)\ngo to x: (x) y: (y)\ncreate clone of (_myself_ v)\n\nwhen flag clicked\nset [coinsfloat? v] to [1]\nset [playercoins v] to [0]\nswitch costume to (1 v)\nforever\n    hide\nend\n\nwhen I receive [newlevel v]\nif <[0] = [0]> then\n    delete this clone\nend\nreset\n\nwhen I receive [end v]\ndelete this clone\n\nwhen I start as a clone\nclear graphic effects\nswitch costume to (1 v)\nshow\nforever\n    wait (0.05) seconds\n    next costume\nend\n\nwhen I receive [hovercoins v]\nforever\n    repeat (20)\n        change y by (0.25)\n    end\n    repeat (20)\n        change y by (-0.25)\n    end\nend\n\nwhen I receive [start v]\nreset\n\nwhen I start as a clone\nforever\n    if <touching (player v)?> then\n        change [playercoins v] by (1)\n        if <not <([sound v] of [sound v]) = [0]>> then\n            set volume to (30) %\n            start sound [collect v]\n        end\n        repeat (10)\n            change [ghost v] effect by (10)\n        end\n        delete this clone\n    end\nend\n\n@directions\n\nwhen flag clicked\nhide\ngo to x: (0) y: (0)\ngo to first costume\n\nwhen I receive [newlevel v]\nnext costume\ngo to [front v] layer\n\nwhen this sprite clicked\nhide\n\nwhen I receive [done v]\nstop [other scripts in sprite v]\n\nwhen I receive [start v]\nshow\n\ndefine go to first costume\nrepeat until <(costume [number v]) = [1]>\n    next costume\nend\n\n@end\n\nwhen flag clicked\nhide\n\nwhen flag clicked\nforever\n    repeat (20)\n        change y by (0.3)\n    end\n    repeat (20)\n        change y by (-0.3)\n    end\nend\n\nwhen I receive [start v]\nreset\nforever\n    if <touching (player v)?> then\n        broadcast (find last level v) and wait\n        start sound [complete v]\n        if <(level) > (([last level v] of [level v]) - (2))> then\n            if <(level) = ([last level v] of [level v])> then\n                set [level v] to [end]\n            else\n                set [level v] to [end]\n                broadcast (newLevel v)\n            end\n            broadcast (end v)\n            stop [this script v]\n        end\n        change [level v] by (1)\n        broadcast (newLevel v) and wait\n    end\nend\n\nwhen I receive [end v]\nhide\n\ndefine reset\nif <(level) = [1]> then\n    go to x: (200) y: (-30)\nend\nif <(level) = [5]> then\n    go to x: (200) y: (150)\nend\nif <(level) = [6]> then\n    go to x: (200) y: (65)\nend\nif <(level) = [7]> then\n    go to x: (200) y: (-30)\nend\nif <(level) = [9]> then\n    go to x: (-105) y: (-30)\nend\nshow\n\nwhen I receive [newlevel v]\nreset\n\n@squish\n\nwhen flag clicked\nforever\n    go to x: (115) y: (-133)\n    go to [front v] layer\n    show\n    if <<key (s v) pressed?> or <key (down arrow v) pressed?>> then\n        set [squished? v] to [1]\n        wait until <not <<key (s v) pressed?> or <key (down arrow v) pressed?>>>\n        set [squished? v] to [0]\n    end\nend\n\nwhen this sprite clicked\nrepeat until <not <<mouse down?> and <touching (mouse-pointer v)?>>>\n    set [pressingbutton? v] to [1]\nend\nset [squished? v] to (<not <(squished?) = [1]>> + ())\nset [pressingbutton? v] to [0]\n\n@sound\n\nwhen flag clicked\nset [sound v] to [1]\nforever\n    switch costume to (sound)\n    go to x: (190) y: (-133)\n    go to [front v] layer\n    show\nend\n\nwhen this sprite clicked\nrepeat until <not <<mouse down?> and <touching (mouse-pointer v)?>>>\n    set [pressingbutton? v] to [1]\nend\nset [sound v] to (<not <(sound) = [1]>> + ())\nset [pressingbutton? v] to [0]\n\n@timer\n\nwhen flag clicked\nset [clear v] to [0]\nhide\n\ndefine write (word) (letter space) (size) (color) (brightness)\nset [brightness v] effect to (brightness)\nset [letter# v] to [0]\nif <(size) = []> then\n    set size to (100) %\nelse\n    set size to (size) %\nend\nrepeat (length of (word))\n    change [letter# v] by (1)\n    switch costume to (? v)\n    switch costume to (letter (letter#) of (word))\n    create clone of (_myself_ v)\n    if <(letter space) = []> then\n        change x by (15)\n    else\n        change x by (letter space)\n    end\nend\n\nwhen flag clicked\nhide\n\nwhen I start as a clone\ngo to [front v] layer\nshow\n\nwhen I receive [end v]\nstop [other scripts in sprite v]\nif <(playerTimer) < (☁ highscore)> then\n    set [☁ highscore v] to (playerTimer)\n    broadcast (beatHighscore v)\nend\nrefresh\n\ndefine refresh\nif <[0] = [0]> then\n    delete this clone\nend\nswitch costume to (0 v)\ngo to x: (-170) y: (145)\nwrite (playerTimer) [15] [100] [0] [-100]\nswitch costume to (0 v)\ngo to x: (-170) y: (100)\nwrite (☁ highscore) [15] [100] [0] [-100]\ngo to x: (0) y: (0)\nclear graphic effects\nswitch costume to (board v)\ngo to [front v] layer\nshow\n\nwhen I receive [refreshscores v]\nrefresh\n\nwhen I receive [start v]\nclear graphic effects\ngo to x: (0) y: (0)\nswitch costume to (board v)\ngo to [front v] layer\nshow\nset [playertimer v] to [0]\nforever\n    broadcast (refreshScores v) and wait\n    wait (1) seconds\n    change [playertimer v] by (1)\nend\n\n@beatHighscoreMessage\n\nwhen flag clicked\nhide\nclear graphic effects\n\nwhen I receive [beathighscore v]\ngo to x: (0) y: (-182)\nset [ghost v] effect to (90)\nshow\nrepeat (45)\n    change y by (2)\n    change [ghost v] effect by (-5)\nend\nwait (3) seconds\nrepeat (45)\n    change y by (-2)\n    change [ghost v] effect by (5)\nend\nhide\n\n@thumbnail\n\nwhen flag clicked\nset [ghost v] effect to (100)\ngo to x: (0) y: (0)\nforever\n    go to [front v] layer\n    show\nend\n\nwhen I receive [done v]\nset [vel v] to [-1]\ngo to x: (0) y: (500)\nclear graphic effects\nrepeat until <(y position) < [1]>\n    change y by (vel)\n    change [vel v] by (-1)\nend\nset [vel v] to [10]\nrepeat (10)\n    change y by (vel)\n    change [vel v] by (-1)\nend\nrepeat (10)\n    change y by (vel)\n    change [vel v] by (-1)\nend\nset [vel v] to [5]\nrepeat (5)\n    change y by (vel)\n    change [vel v] by (-1)\nend\nrepeat (5)\n    change y by (vel)\n    change [vel v] by (-1)\nend\ngo to x: (0) y: (0)\nwait (1) seconds\nbroadcast (comment v) and wait\nstop [other scripts in sprite v]\n\n@enemy\n\nwhen flag clicked\nset [gravity v] to [0.8]\nset [jumpheight v] to [12]\nset [trampolineheight v] to [15]\nset [friction v] to [0.7]\nset [maxwaterspeed v] to [1.5]\nforever\n    hide\n    if <([sound v] of [sound v]) = [0]> then\n        set volume to (0) %\n    else\n        set volume to (30) %\n    end\nend\n\ndefine reset\nset [killenemy? v] to [0]\nif <(level) = [7]> then\n    spawn enemy at x: [150] y: [130]\n    spawn enemy at x: [-90] y: [155]\nend\nif <(level) = [9]> then\n    spawn enemy at x: [100] y: [160]\nend\n\nwhen I receive [reset v]\nif <[0] = [0]> then\n    delete this clone\nend\nreset\n\ndefine controls\nif <(enemyJumping?) = [1]> then\n    jump\nend\nif <(x position) > ([x position v] of [player v])> then\n    point in direction (-90)\n    change [enemyxv v] by (-1)\nend\nif <(x position) < ([x position v] of [player v])> then\n    point in direction (90)\n    change [enemyxv v] by (1)\nend\n\ndefine gravity\nchange [enemyyv v] by ((gravity) * (-1))\nif <<<touching (water v)?> and <not <touching (level v)?>>> and <(enemyJumping?) = [0]>> then\n    set [enemyyv v] to [-1]\nend\nchange y by (enemyYv)\nif <(enemyYv) < [1]> then\n    set [enemyjumping? v] to [0]\nelse\n    if <touching (level v)?> then\n        set [enemyyv v] to [0]\n        set [enemyjumping? v] to [0]\n        repeat until <not <touching (level v)?>>\n            change y by (-1)\n        end\n    end\nend\n\ndefine switch costume\nswitch costume to (move v)\nif <(enemyJumping?) = [1]> then\n    switch costume to (upmove v)\nend\nif <(round (enemyXv)) = [0]> then\n    point in direction (90)\n    switch costume to (normal v)\n    if <(enemyJumping?) = [1]> then\n        switch costume to (up v)\n    end\n    if <(enemyYv) < ((gravity) * (-1))> then\n        switch costume to (down v)\n    end\nend\n\ndefine jump\nif <touching (water v)?> then\n    set [enemyyv v] to [3]\n    set [enemyjumping? v] to [1]\nelse\n    change y by (-1)\n    if <<<touching (level v)?> or <touching (water v)?>> and <(enemyJumping?) = [0]>> then\n        set [enemyyv v] to (jumpHeight)\n        set [enemyjumping? v] to [1]\n    end\n    change y by (1)\nend\n\ndefine left & right movement\nif <<touching (water v)?> and <<(enemyXv) < ((maxWaterSpeed) * (-1))> or <(enemyXv) > (maxWaterSpeed)>>> then\n    set [enemyxv v] to (((enemyXv) / ([abs v] of (enemyXv) )) * (maxWaterSpeed))\nend\nset [enemyxv v] to ((enemyXv) * (friction))\nset [touchingtrampoline v] to [0]\nif <touching (trampoline v)?> then\n    set [touchingtrampoline v] to [1]\nend\nchange x by (enemyXv)\nif <<(touchingTrampoline) = [0]> and <touching (trampoline v)?>> then\n    repeat until <not <touching (trampoline v)?>>\n        change x by (((enemyXv) / ([abs v] of (enemyXv) )) * (-1))\n    end\n    change x by (((enemyXv) / ([abs v] of (enemyXv) )) * (-1))\nend\nif <touching (level v)?> then\n    change y by (8)\n    if <touching (level v)?> then\n        change y by (-8)\n        repeat until <not <touching (level v)?>>\n            change x by (((enemyXv) / ([abs v] of (enemyXv) )) * (-1))\n        end\n        jump\n    else\n        repeat until <touching (level v)?>\n            change y by (-1)\n        end\n        repeat until <not <touching (level v)?>>\n            change y by (1)\n        end\n    end\nelse\n    if <(enemyJumping?) = [0]> then\n        change y by (-8)\n        if <touching (level v)?> then\n            repeat until <not <touching (level v)?>>\n                change y by (1)\n            end\n        else\n            change y by (8)\n        end\n    end\nend\n\nwhen I start as a clone\nset [enemyxv v] to [0]\nset [enemyyv v] to [0]\nset [enemyjumping? v] to [0]\nset size to (100) %\nclear graphic effects\ngo to [back v] layer\nset rotation style [left-right v]\nshow\nforever\n    loop\n    if <<touching (player v)?> and <(killEnemy?) = [1]>> then\n        start sound [Die v]\n        delete this clone\n    end\nend\n\ndefine rise to ground\nrepeat until <not <touching (level v)?>>\n    change y by (1)\n    set [enemyyv v] to [0]\nend\n\ndefine sprite interactions\nif <touching (trampoline v)?> then\n    set [enemyyv v] to (((enemyYv) / ([abs v] of (enemyYv) )) * ((trampolineHeight) * (-1)))\n    if <(enemyYv) > [0]> then\n        set [enemyjumping? v] to [1]\n    end\nend\n\ndefine loop\nchange y by (1)\ncontrols\nleft & right movement\ngravity\nrise to ground\nsprite interactions\nchange y by (-1)\nswitch costume\nshow\n\ndefine spawn enemy at x: (x) y: (y)\ngo to x: (x) y: (y)\nswitch costume to (normal v)\ncreate clone of (_myself_ v)\n\n@powerups\n\ndefine reset\nif <(level) = [8]> then\n    spawn powerup - x: [-130] y: [-40] costume: [jump]\n    spawn powerup - x: [0] y: [75] costume: [speed]\nend\nif <(powerupsFloat?) = [1]> then\n    broadcast (hoverPowerups v)\nend\n\ndefine spawn powerup - x: (x) y: (y) costume: (costume)\nswitch costume to (costume)\ngo to x: (x) y: (y)\ncreate clone of (_myself_ v)\n\nwhen flag clicked\nset [powerupsfloat? v] to [1]\nswitch costume to (1 v)\nforever\n    hide\nend\n\nwhen I receive [reset v]\nif <[0] = [0]> then\n    delete this clone\nend\nreset\n\nwhen I receive [end v]\ndelete this clone\n\nwhen I receive [hoverpowerups v]\nforever\n    repeat (20)\n        change y by (0.25)\n    end\n    repeat (20)\n        change y by (-0.25)\n    end\nend\n\nwhen I start as a clone\nshow\nforever\n    if <touching (player v)?> then\n        broadcast (join [Powerups: ] (costume [name v]))\n        if <not <([sound v] of [sound v]) = [0]>> then\n            set volume to (30) %\n            start sound [collect v]\n        end\n        repeat (10)\n            change [ghost v] effect by (10)\n        end\n        delete this clone\n    end\nend\n\n