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


Babel includes JSX processing.

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


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <canvas height="200" width="200">


                canvas {
  border: 2px solid gray;


                function radnomIntInRange(min, max) {
  return Math.floor(Math.random() * (max - min) + min);

function drawStaticShape(staticImage) {
  const width = 50;
  const height = 50;
  const x = (WIDTH - width) / 2;
  const y = (HEIGHT - height) / 2;
  ctx.drawImage(staticImage, x, y, width, height);
  return {x, y, width, height};

function drawJumpingShape(jumpingImage) {
  const width = 51;
  const height = 33;
  const x = radnomIntInRange(width, WIDTH - width);
  const y = radnomIntInRange(height, HEIGHT - height);
  ctx.drawImage(jumpingImage, x, y, width, height);
  return {x, y, width, height};

function createAnImage(imgSrc) {
  const img = new Image();
  img.src = imgSrc; 
  return new Promise(res => img.onload = res(img));

function jump([pizzaImage, developerImage]) {
  const pizza = drawStaticShape(pizzaImage);
  const dev = drawJumpingShape(developerImage);
  const devXRight = dev.x + dev.width;
  const pizzaXRight = pizza.x + pizza.width;
  const devYBottom = dev.y + dev.height;
  const pizzaYBottom = pizza.y + pizza.height;
  const overlapX = (dev.x <= pizzaXRight && dev.x >= pizza.x) || 
    (devXRight <= pizzaXRight && devXRight >= pizza.x);
  const overlapY = (dev.y <= pizzaYBottom && dev.y >= pizza.y) || 
     (devYBottom <= pizzaYBottom && devYBottom >= pizza.y);
  const isColliding = overlapX && overlapY;
  if (isColliding) {
    console.log("A Happy Developer is a Pizza-fed Developer!");

const canvas = document.querySelector('canvas');
const HEIGHT = canvas.height;
const WIDTH = canvas.width;
const ctx = canvas.getContext('2d');

const pizzaImage = createAnImage("");

const developerImage = createAnImage("");

Promise.all([pizzaImage, developerImage]).then((images) => {
  let interval = setInterval(() => {
  }, 1000);