✦ You asked for this

Free pack · $0

Here is your Geometry Dash game. It is free.

A working Geometry Dash clone, built in p5.js. Spinning cube, spikes, platforms, particle explosions, neon glow and a progress bar. Paste the code into the free p5.js editor and you are playing in about 2 minutes. Then you change the colors, the physics and the level.

Take me to the game codefree · on this page
No sign-upNothing to installRuns in your browser

✦ Get it

The game code

One file of about 290 lines of p5.js. Physics, level design, particles and glow are all in it, and every setting you will want to change is labeled at the top. Copy it, open the free p5.js editor, select the starter code on the left and delete it, paste, then click Play (the triangle at the top).

Best on a computer. Make it yours below. Jump with the space bar, the up arrow, a click or a tap. No install and no account needed to play.

sketch.js · paste into editor.p5js.org
// ============================================================
// GEOMETRY DASH CLONE: Your Build
// Made with p5.js · Paste into editor.p5js.org to play!
// ============================================================

// =============================================
// CHANGE THESE TO CUSTOMIZE YOUR GAME
// =============================================

// How the game feels
const GRAVITY      = 0.70;   // higher = heavier (try 0.5 or 1.2)
const JUMP_FORCE   = -13.5;  // more negative = higher jump (try -18)
const PLAYER_SPEED = 6.5;    // starting speed (try 9 for speed run)
const MAX_FALL     = 15;     // how fast the cube falls

// Your cube
const CUBE_SIZE    = 38;
const GROUND_Y     = 400;    // where the ground is

// Colors: change any hex code to any color you want!
const CUBE_COLOR   = '#FFD700';  // your cube (gold)
const SPIKE_COLOR  = '#FF3300';  // spikes
const PLAT_COLOR   = '#2244DD';  // platforms
const BG_START     = '#0d0020';  // sky color at start (dark purple)
const BG_END       = '#001830';  // sky color at end (dark blue)

// =============================================
// LEVEL DESIGN: add your own obstacles here!
// =============================================
// spike:    { type: 'spike', x: 700 }
// double:   { type: 'double', x: 900 }
// platform: { type: 'platform', x: 1400, yOff: -115, w: 120 }
//   yOff = how high above ground (negative). w = width.

const LEVEL_DEFS = [
  { type: 'spike',    x: 650 },
  { type: 'spike',    x: 850 },
  { type: 'spike',    x: 1050 },
  { type: 'double',   x: 1250 },
  { type: 'platform', x: 1520, yOff: -115, w: 130 },
  { type: 'spike',    x: 1760 },
  { type: 'double',   x: 1950 },
  { type: 'spike',    x: 2150 },
  { type: 'spike',    x: 2230 },
  { type: 'spike',    x: 2310 },
  { type: 'double',   x: 2500 },
  { type: 'platform', x: 2750, yOff: -120, w: 110 },
  { type: 'double',   x: 2960 },
  { type: 'spike',    x: 3160 },
  { type: 'double',   x: 3310 },
  { type: 'spike',    x: 3470 },
  { type: 'double',   x: 3620 },
  { type: 'spike',    x: 3760 },
  { type: 'double',   x: 3900 },
];

const LEVEL_LENGTH = 4400;

// =============================================
// GAME ENGINE
// =============================================
let worldX = 0, player, particles = [], gameState = 'playing', attempts = 1, jumpHeld = false, obstacles;

function setup() {
  createCanvas(800, 480);
  frameRate(60);
  obstacles = buildObstacles();
  resetPlayer();
}

function resetPlayer() {
  player = { x: 150, y: GROUND_Y - CUBE_SIZE, vy: 0, onGround: true, rotation: 0 };
}

function draw() {
  drawBG();
  if (gameState === 'playing') {
    updatePlayer();
    checkCollisions();
    if (worldX >= LEVEL_LENGTH) gameState = 'win';
  }
  updateParticles();
  drawGround();
  drawAllObstacles();
  drawPlayer();
  drawParticles();
  drawHUD();
  if (gameState === 'dead') drawDeathScreen();
  if (gameState === 'win')  drawWinScreen();
}

function drawBG() {
  let t = constrain(worldX / LEVEL_LENGTH, 0, 1);
  let top = lerpColor(color(BG_START), color(BG_END), t);
  let bot = lerpColor(color('#000010'), color('#002244'), t);
  for (let y = 0; y < height; y++) {
    stroke(lerpColor(top, bot, map(y, 0, height, 0, 1)));
    line(0, y, width, y);
  }
  stroke(255, 255, 255, 14); strokeWeight(0.5);
  let gx = (-worldX % 60 + 60) % 60;
  for (let x = gx; x < width; x += 60) line(x, GROUND_Y, x, height);
  for (let y = GROUND_Y; y < height; y += 60) line(0, y, width, y);
  strokeWeight(1);
}

function drawGround() {
  noStroke(); fill(20, 20, 50);
  rect(0, GROUND_Y, width, height - GROUND_Y);
  drawingContext.shadowBlur = 14; drawingContext.shadowColor = '#5566FF';
  stroke('#5566FF'); strokeWeight(2);
  line(0, GROUND_Y, width, GROUND_Y);
  drawingContext.shadowBlur = 0; strokeWeight(1);
}

function updatePlayer() {
  player.vy += GRAVITY; player.vy = min(player.vy, MAX_FALL); player.y += player.vy;
  if (player.y >= GROUND_Y - CUBE_SIZE) {
    player.y = GROUND_Y - CUBE_SIZE; player.vy = 0; player.onGround = true;
    player.rotation = round(player.rotation / 90) * 90;
    if (jumpHeld) doJump();
  } else { player.onGround = false; }
  if (!player.onGround) player.rotation += 7;
  worldX += PLAYER_SPEED + map(worldX, 0, LEVEL_LENGTH, 0, 3.5);
}

function doJump() {
  if (player.onGround) { player.vy = JUMP_FORCE; player.onGround = false; }
}

function drawPlayer() {
  push();
  translate(player.x + CUBE_SIZE / 2, player.y + CUBE_SIZE / 2);
  rotate(radians(player.rotation));
  drawingContext.shadowBlur = 20; drawingContext.shadowColor = CUBE_COLOR;
  fill(CUBE_COLOR); noStroke(); rectMode(CENTER);
  rect(0, 0, CUBE_SIZE, CUBE_SIZE, 5);
  drawingContext.shadowBlur = 0; fill(255, 255, 255, 90);
  rect(0, 0, CUBE_SIZE * 0.52, CUBE_SIZE * 0.52, 2);
  fill(CUBE_COLOR); rotate(PI / 4);
  rect(0, 0, CUBE_SIZE * 0.2, CUBE_SIZE * 0.2);
  pop(); rectMode(CORNER); drawingContext.shadowBlur = 0;
}

function buildObstacles() {
  let list = [];
  for (let def of LEVEL_DEFS) {
    let sz = def.size || 55;
    if (def.type === 'spike')  list.push(makeSpike(def.x, sz, GROUND_Y));
    if (def.type === 'double') { list.push(makeSpike(def.x, sz, GROUND_Y)); list.push(makeSpike(def.x + sz + 2, sz, GROUND_Y)); }
    if (def.type === 'platform') {
      let w = def.w || 120, ph = 18, py = GROUND_Y + (def.yOff || -100) - ph;
      list.push({ type:'platform', wx:def.x, drawY:py, w, h:ph, hx:def.x, hy:py, hw:w, hh:ph });
    }
  }
  return list;
}

function makeSpike(wx, sz, baseY) {
  return { type:'spike', wx, drawY:baseY-sz, size:sz, hx:wx-sz/2+10, hy:baseY-sz+12, hw:sz-20, hh:sz-12 };
}

function drawAllObstacles() {
  for (let obs of obstacles) {
    let sx = obs.wx - worldX;
    if (sx < -120 || sx > width + 120) continue;
    if (obs.type === 'spike')    drawSpike(sx, obs.drawY, obs.size);
    if (obs.type === 'platform') drawPlatform(sx, obs.drawY, obs.w, obs.h);
  }
}

function drawSpike(cx, y, sz) {
  drawingContext.shadowBlur = 14; drawingContext.shadowColor = '#FF4400';
  fill(SPIKE_COLOR); stroke('#FF7700'); strokeWeight(1.5);
  triangle(cx, y, cx - sz/2, y + sz, cx + sz/2, y + sz);
  stroke(255, 180, 50, 160); strokeWeight(1);
  line(cx, y, cx - sz/2, y + sz);
  strokeWeight(1); drawingContext.shadowBlur = 0;
}

function drawPlatform(sx, y, w, h) {
  drawingContext.shadowBlur = 10; drawingContext.shadowColor = '#4466FF';
  fill(PLAT_COLOR); stroke('#5577FF'); strokeWeight(1.5);
  rect(sx, y, w, h, 3);
  stroke('#88AAFF'); strokeWeight(2);
  line(sx + 3, y + 2, sx + w - 3, y + 2);
  strokeWeight(1); drawingContext.shadowBlur = 0;
}

function checkCollisions() {
  let px = player.x + 5, py = player.y + 5, pw = CUBE_SIZE - 10, ph = CUBE_SIZE - 10;
  for (let obs of obstacles) {
    let osx = obs.hx - worldX;
    if (osx + obs.hw < 0 || osx > width) continue;
    if (!aabb(px, py, pw, ph, osx, obs.hy, obs.hw, obs.hh)) continue;
    if (obs.type === 'spike') { triggerDeath(); return; }
    if (obs.type === 'platform') {
      let prevBot = py + ph - player.vy;
      if (player.vy > 0 && prevBot <= obs.hy + 3) {
        player.y = obs.hy - CUBE_SIZE; player.vy = 0; player.onGround = true;
        player.rotation = round(player.rotation / 90) * 90;
        if (jumpHeld) doJump();
      } else { triggerDeath(); return; }
    }
  }
}

function aabb(ax, ay, aw, ah, bx, by, bw, bh) {
  return ax < bx+bw && ax+aw > bx && ay < by+bh && ay+ah > by;
}

function triggerDeath() {
  gameState = 'dead';
  let cx = player.x + CUBE_SIZE/2, cy = player.y + CUBE_SIZE/2;
  for (let i = 0; i < 30; i++) {
    let a = random(TWO_PI), spd = random(2.5, 11);
    particles.push({ x:cx, y:cy, vx:cos(a)*spd, vy:sin(a)*spd-random(1,5),
      life:255, size:random(3,10), shape:random()>0.5?'rect':'tri',
      rot:random(TWO_PI), rs:random(-0.3,0.3), col:random([CUBE_COLOR,'#FFFFFF','#FFB300']) });
  }
}

function updateParticles() {
  for (let i = particles.length-1; i>=0; i--) {
    let p = particles[i];
    p.vy += 0.4; p.x += p.vx; p.y += p.vy; p.rot += p.rs; p.life -= 5;
    if (p.life <= 0) particles.splice(i,1);
  }
}

function drawParticles() {
  noStroke();
  for (let p of particles) {
    push(); translate(p.x, p.y); rotate(p.rot);
    let c = color(p.col); fill(red(c), green(c), blue(c), p.life);
    if (p.shape === 'rect') { rectMode(CENTER); rect(0,0,p.size,p.size); }
    else triangle(0,-p.size,-p.size/2,p.size/2,p.size/2,p.size/2);
    pop();
  }
  rectMode(CORNER);
}

function drawHUD() {
  let prog = constrain(worldX / LEVEL_LENGTH, 0, 1);
  noStroke(); fill(0,0,0,100); rect(40,10,width-80,15,7);
  fill(lerpColor(color('#00FFCC'), color('#FFDD00'), prog));
  drawingContext.shadowBlur = 8; drawingContext.shadowColor = '#00FFCC';
  rect(40,10,(width-80)*prog,15,7);
  drawingContext.shadowBlur = 0;
  fill(255,255,255,200); noStroke(); textSize(11); textAlign(CENTER,CENTER);
  text(floor(prog*100)+'%', width/2, 17);
  textAlign(LEFT,TOP); fill(255,255,255,100); textSize(11);
  text('Attempt '+attempts, 8, 30);
}

function drawDeathScreen() {
  if (particles.length > 8) return;
  fill(0,0,0,165); noStroke(); rect(0,0,width,height);
  fill('#FF5555'); textSize(52); textAlign(CENTER,CENTER);
  text(floor(constrain(worldX/LEVEL_LENGTH,0,1)*100)+'%', width/2, height/2-45);
  fill(255,255,255,210); textSize(16);
  text('Click or press SPACE to try again', width/2, height/2+12);
  fill(255,255,255,70); textSize(11);
  text('Attempt '+attempts, width/2, height/2+42);
}

function drawWinScreen() {
  fill(0,0,0,170); noStroke(); rect(0,0,width,height);
  fill('#FFD700'); textSize(56); textAlign(CENTER,CENTER);
  text('100%', width/2, height/2-55);
  fill('#FFFFFF'); textSize(24); text('LEVEL COMPLETE', width/2, height/2+5);
  fill(255,255,255,140); textSize(14);
  text('Click or press SPACE to play again', width/2, height/2+48);
}

function keyPressed()  { if (key===' '||keyCode===UP_ARROW) { jumpHeld=true;  handleAction(); } }
function keyReleased() { if (key===' '||keyCode===UP_ARROW)   jumpHeld=false; }
function mousePressed()  { jumpHeld=true;  handleAction(); }
function mouseReleased() { jumpHeld=false; }
function touchStarted()  { jumpHeld=true;  handleAction(); return false; }
function touchEnded()    { jumpHeld=false; return false; }

function handleAction() {
  if (gameState==='playing') { doJump(); return; }
  if (gameState==='dead' && particles.length<=8) { restart(); return; }
  if (gameState==='win') { restart(); return; }
}

function restart() {
  attempts++; worldX=0; particles=[]; gameState='playing'; resetPlayer();
}

It is a real game. It is all yours.

It does not

  • Need an install, an account or any other tool
  • Hide anything: every line of the game is on this page
  • Break for good: paste the code again and you are back to the start

It does

  • Run in any modern browser
  • Come with 19 obstacles in the first level
  • Count your attempts and show a progress bar
  • Let you change every color, the physics and the level

✦ Vibe code guide

Change one thing, press Play, see what it does

That is the best way to learn. These five steps take you from copy and paste to your own level. Hit Stop, then Play, after every change.

Step 1: Open the editor and paste the code

Controls: space bar, up arrow, a click or a tap to jump. Hold it to keep jumping when you land.

  1. Go to editor.p5js.org.
  2. Select all the starter code in the left panel and delete it.
  3. Paste the game code you copied.
  4. Click the Play button, the triangle at the top. The cube starts running.

Step 2: Change your cube color

Near the top of the code, find the CUBE_COLOR line and replace the color code. The cube glows whatever color you pick. Change SPIKE_COLOR and BG_START the same way.

  • const CUBE_COLOR = '#00FFFF'; for a cyan cube
  • const CUBE_COLOR = '#FF00FF'; for a magenta cube
  • const CUBE_COLOR = '#FF4444'; for a red cube
  • const CUBE_COLOR = '#00FF88'; for a neon green cube

Step 3: Change how the game feels

Try these one at a time. That is how you learn what each setting does.

Try thisChange these lines
Moon physics: floaty and slowGRAVITY = 0.4 and JUMP_FORCE = -10
Tank mode: heavy, fast fallGRAVITY = 1.3 and JUMP_FORCE = -15
Speed run: same physics, fasterPLAYER_SPEED = 9
Super jump: almost off the screenJUMP_FORCE = -20

Step 4: Add your own obstacles

Find LEVEL_DEFS near the top and add new lines in these formats. The x number is how far from the start, so a higher x comes later in the level.

  • { type: 'spike', x: 400 }, a single spike, the easiest to jump
  • { type: 'double', x: 500 }, two spikes side by side, harder
  • { type: 'platform', x: 700, yOff: -110, w: 130 }, a floating platform you can land on. yOff is the height, w is the width
  • { type: 'spike', x: 600, size: 80 }, a big spike. size sets how big

Step 5: Take it further with AI

Once the basics work, copy this prompt into ChatGPT, Claude, Claude Code or Codex. Replace [paste your code here] with your code. You get back a new version with the features added.

Add features with AI
I built a Geometry Dash clone in p5.js. Here is the full code:

[paste your code here]

Please add these features:
1. Stars in the background that scroll at half speed
   (parallax effect)
2. The cube changes color gradually as the level
   progresses (use lerpColor)
3. A screen shake effect when the player dies
4. A coin floating at x=1800, collect it for +1 score
Keep all existing physics and level design the same.

What is inside the code: physics and feel

SettingWhat it does
GRAVITYHow fast the cube falls. Default 0.70. Try 0.5 for floaty moon physics, 1.2 for heavy tank mode.
JUMP_FORCEHow high the cube jumps. Default -13.5. More negative jumps higher. Try -18.
PLAYER_SPEEDHow fast the level scrolls at the start. Default 6.5. Try 9 for a speed run, 4 to learn the level.
MAX_FALLThe fastest the cube can fall. Raise it for snappier falls, lower it for a floatier feel.

What is inside the code: colors and style

SettingWhat it does
CUBE_COLORYour cube. Default '#FFD700', gold.
SPIKE_COLORThe spikes. Default '#FF3300', orange red. Try '#00FF88' for alien spikes or '#FFFFFF' for ice.
PLAT_COLORThe platforms. Default '#2244DD', blue. Platforms glow whatever color you set.
BG_STARTThe sky at the start of the level. Default '#0d0020', deep purple.
BG_ENDThe sky at the end. Default '#001830', dark blue. The sky shifts from BG_START to BG_END as you play.

✦ Get unstuck

Stuck? Find your line.

I have never written code

You do not need to. This build started as a demo for Parker, a 12-year-old learning to code. If a kid can paste it, change the colors and add his own spikes in 20 minutes, so can you. The hardest part is the first copy and paste.

I pressed Play and nothing happens

Make sure you deleted all the starter code before you pasted, so only the game is in the left panel. Then click Play again. Click once on the game area so it hears the space bar.

I changed something and now it is broken

Check you only changed the number or the color code, and kept the quote marks and the semicolon. If you are lost, copy the code from this page again and start over.

My new spike does not show up

Each line inside LEVEL_DEFS needs a comma at the end, and the x number must be less than 4400, the length of the level.

I want to save my version

Make a free p5.js account and use File, then Save. Without an account the game still runs, it just is not saved.

None of these fixed it

Email joe@mastermindshq.business. Say which step you were on and paste what you saw.

✦ What next · free

Want the next step? Watch beginners build a website.

5minute video, free to watch
1real website, built by talking to AI
0tech skills needed
Nowplays the moment you sign up
Joe Che

You just pasted code and made a game your own, without being a coder. Building your own website works the same way: you describe it, AI writes it, you change what you want.

It is a short video from my Website Workshop. You watch real beginners build a website just by telling AI what they want, in plain English. No code, no tech words.

  • Made for people who are not technical. Most people in the workshop had only used ChatGPT.
  • You also see real websites my students built and put live.
  • Add your name, email and WhatsApp, and the video plays right there on the page.
FreeNo card needed. If you like what you see, at the end I show you how to build your own.
Watch the free demoFree · 5 minute video · next page

Not for you? Close this page. Everything above stays free.

Created by Joe Che.

ChatGPT is a trademark of OpenAI. Claude is a trademark of Anthropic. This page is not affiliated with either.