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.

  max-width 1536px
  margin 0 auto
              var w = 1536;
var h = 864;
var canvas;
var epoch = 0;
var level = 0;
const inst = ["",
             "There's only one way, press a key",
             "If it's wrong, try the other way around",
             "Dark pink, yellow, soft green, navy",
             "Brightness descending",
             "Red to magenta",
             "Make them alternate",
             "Autumn forest: stones, soil, grass, fallen leaves, the last dandelion, needles on trees, the sky, clouds",
             "The invisible amid the visible",
             "First four levels in one",
             "Level nine... vice versa"];
const lvcs = [[],
var heis = [];
var cols = [];
var tc;
var xc;
var taken;
var done = null;
const delay = 2000;

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

function draw() {
  switch (epoch) {
    case 0:
      text("Taken", w/2, h/2);
      text("Press any key to continue...", w/2, h*2/3);
    case 1:
      text("This is a recreation of one of my past games.\nThe original was made using pygame,\nwhich made the implementation slow and painful.\n\nYou are a horizontal line.\nIn this game, white means neutral, colourless.\nUse the right and left arrows to traverse the landscape\nmade of colourful (not white) columns. You can only step up one block at a time.\nPress the up arrow to pick up the colour beneath you.\nThe colour is now taken, as represented by you carrying a square of that colour.\nThen, move to another column and press the down arrow\nto paint the column the taken colour.\nYou turn white again and the original colour of the column\nbelow you is used to fill the white column.\nHowever, it's not just the colour that's being transferred.\nWhen you pick up a column's colour, you pick up one of its blocks as well,\nwhen you put it back down, you increase the height of the column under you.\nOrder the colours according to the instructions at the top of the screen\nand stand on the rightmost column in order to proceed, press R to reset.", w/2, h/2);
    case 2:
      for (let i in cols) {
        rect(i*w/level, h, w/level, -heis[i]*h/12);
      text(inst[level], w/2, h/24);
      if (taken)  {
      if (done && done+delay < millis()) nextl();
    case 3:
      text("Congratulations!", w/2 , h/2);

function nextl() {
  done = null;
  if (level > 11) {
  cols = Array(level).fill("#000");
  heis = Array(level).fill(0);
  for (let i in cols) {
    cols[i] = lvcs[level][i];
    heis[i] = Math.min(Math.floor(2+Math.random()*(int(i)+1)), 11);
  cols.sort((a, b) => Math.random()-.5);
  xc = 0;
  taken = null;

function keyPressed() {
  switch (epoch) {
    case 1:
    case 0:
    case 2:
      if (done) return;
      if (key == 'R') {
      switch (keyCode) {
        case RIGHT_ARROW:
          if (xc < level-1 && heis[xc+1] <= heis[xc]+1) xc++;
        case LEFT_ARROW:
          if (xc && heis[xc-1] <= heis[xc]+1) xc--;
        case UP_ARROW:
        case DOWN_ARROW:
          if (taken) {
            cols[tc] = cols[xc];
            cols[xc] = taken;
            taken = null;
          } else {
            tc = xc;
            taken = cols[xc];
            cols[xc] = "#fff";
      if (xc == level-1) {
        for (let i in cols) {
          if (cols[i] != lvcs[level][i]) return;
        done = millis();
🕑 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 ..................