css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

p A post-jam version is available at 
    | https://codepen.io/Mimarik/full/YRLBoJ
  | .
  max-width 432px
  margin 0 auto

  text-align center
  font-family Montserrat, "Open Sans", Calibri, sans-serif
              var w = 432;
var h = 768;
var canvas;
var platforms = [[1, w/6, h*7/8], [1, w/2, h*7/8], [1, w*5/6, h*7/8]];
const cols = [null, "#2ecc71", "#fff", "#9b59b6"];
var platw = 120;
var plath = 30;
var epoch = 0;
var known = [2];
var acc = .2;
var playx = w/2;
var playy = w*3/4;
var playv = 0;
var jumpv = -12;
var speed = 3;
var score = 0;
const ystep = plath*5.8;

function setup() {
  canvas = createCanvas(w,h);
  textAlign(CENTER, CENTER);
  genp(); genp(); genp();

function draw() {
  switch (epoch) {
    case 0:
      playv += acc;
      playy += playv;
      for (let i = 0; i < platforms.length; i += 1) {
        p = platforms[i];
        if (!known.includes(p[0])) {
          epoch = p[0];
        rect(p[1], p[2], platw, plath);
        if (Math.abs(p[1]-playx) < (platw+plath)/2 && Math.abs(p[2]-playy) < plath && playv > 0 && p[0] != 2) {
          playy = p[2]-plath;
          jumpv = Math.min(-12, jumpv+.5);
          if (p[0] == 3) {
            jumpv -= 3;
          playv = jumpv;
        if (p[2]-plath/2 > h) {
          platforms.splice(i, 1);
      if (keyIsPressed) {
        if (keyCode == RIGHT_ARROW) {
          playx += speed;
        if (keyCode == LEFT_ARROW) {
          playx -= speed;
      playx = Math.min(w, Math.max(0, playx));
      let diff = h*7/8-plath/2-jumph()-playy;
      if (diff > 0) {
        playy += diff;
        for (let i in platforms) {
          platforms[i][2] += diff;
        score += diff;
      rect(playx, playy, plath, plath);
      /*rect(w/2, h*7/8-plath/2-jumph(), w, 2);
      text(h*7/8-plath/2-jumph(), w/4, h/8);
      text(playy, w*3/4, h/8);*/
      text(Math.floor(score), w/2, h/8);
      if (playy-plath/2 > h) epoch = -1;
    case 1:
      text("This is a simple\nupwards platformer.\nYour aim is to get\nas high as possible.\nThere is no limit.\nJump on the green\nblocks to get higher.\nControl the game\nusing the arrow keys.\n\nPress any key to\ndismiss this message.\nYou might need to\nfocus the canvas first\nby clicking it.", w/2, h/2);
    case 3:
      text("Purple platforms\nprovide a boost to\njump height for\nthe next six jumps.", w/2, h/2);
    case -1:
      text("GAME OVER.\n\nRefresh to retry.", w/2, h/2);

function jumph() {
  return jumpv*jumpv/acc/2;

function genp(type) {
  let p = platforms[platforms.length-1];
  let y = p[2]-ystep;
  if (type == null) {
    type = Math.floor(1+Math.random()*Math.min(score/1000));
  if (type == 2 && p[0] == 2) {
  if (type >= cols.length) {
    type = 1;
  p = [type, Math.floor(Math.random()*w), y];

function keyPressed() {
  epoch = 0;
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................