cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

	Use left and right keys to move,
	space bar to jump.
<canvas id="c"></canvas>
	var a = document.getElementsByTagName('canvas')[0];
	var b = document.body;
	var d = function(e) {
		return function() {
	// unprefix some popular vendor prefixed things (but stick to their original name)
	var AudioContext =
			window.AudioContext ||
	var requestAnimationFrame =
			window.requestAnimationFrame ||
			window.mozRequestAnimationFrame ||
			window.webkitRequestAnimationFrame ||
			window.msRequestAnimationFrame ||
			function(f) {
				setTimeout(f, 1000 / 30);
	// fix bug in safari: http://qfox.nl/weblog/218
	// auto resize (original) canvas. call `onresize(w,h) to limit the size of the canvas
	(window.onorientationchange = window.onresize = function(a) {
		var mw = Infinity;
		var mh = Infinity;
		var min = Math.min;
		return function(w, h) {
			if (arguments.length === 2) {
				mw = w;
				mh = h;
			a.style.width = (a.width = min(mw, innerWidth)) + 'px';
			a.style.height = (a.height = min(mh, innerHeight)) + 'px';
	var c = a.getContext('2d');
              html, body {
	margin: 0; 
	padding: 0; 
	border: 0; 

#c {
	display: block; 
 * An entry for JS1K, a competition to create 
 * a JavaScript demo within 1kb.
 * Unminified code is up on Github:
 * https://github.com/rvmook/js1k-just-a-happy-robot

function d(f,g,h){i=0;while(j=f.match(/\w\d*/g)[i++]){c.fillStyle=k[j[0]]||'#000';c.f(4*(+j[1]*l+((l-1)*-5)+g),4*(+j[2]+h),4*l*((j[3]|0)+1),4*((j[4]|0)+1))}return d}m=n=o=p=q=r=0;k={37:-1,39:s=t=1,32:'if(!n)n=o=-4;0',w:'#fff',1:u='057w',2:'1702w26w354w542w63b64',3:'6702w56w054',4:u+'022w1104b12w432w5202b53w34',5:u+'1004w012b11'};b.onkeyup=b.onkeydown=function(f){t=(p=f.type[6]?eval(k[f.keyCode])||p:f.keyCode>36?0:p)||t};c.f=c.fillRect;v='w18w7';w='00245300241115430000254300243';setInterval("x=a.width/4;y=(Math.max(232,x+32)/8)|0;c.f(z=0,0,x*4,A=a.height);B=m+p;C=Math.floor(1+(D+B)/8)%y;while(C<0)C=y+C;E=!+w[C];F=(A/8|0)-9;if(E&&r==F||r<F){m=B;q=E?F:F-9}r+=r>F?-r:o++;if(r>q&&o>0){n=o=0;r=q}G=s%18<9;l=t;d('w1063b4101b6101'+['w29w69',v+7,v+8,v+9][H=n?2:p?s%4:0],I=D-4,J=+'6645'[H]+r+(E&&G))('w106w2142b51b421',I=D-4,+'5455'[H]+J)('w00w80',I=D-4,+'7676'[H]+J);l=1;while(z<y){K=z++*8-m;while(K<-16)K+=y*8;while(K>x+8)K-=y*8;d('b0777w'+(k[w[z]]||['081w271w481w671b069','291w081w691w481'][+G])+'b',K,F+3)}s++",D=82)
🕑 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 ..................