Git Product home page Git Product logo

floppybird's Introduction

Mihail Szabolcs

Senior Software Engineer, Open Source Evangelist, Renaissance Man.

GitHub Contributions Snake

In order to play snake in the contributions matrix below, perform the following incantations:

  1. create a bookmark with the code below
  2. click on it while on this page
  3. scroll down to the contributions matrix
  4. use the arrow keys to control the snake
javascript:(function(){class t{constructor(){this.reset(),window.addEventListener("keydown",this._onKeyDown)}reset=()=>{this.left=!1,this.right=!1,this.up=!1,this.down=!1};_onKeyDown=t=>{switch(t.preventDefault(),t.stopPropagation(),t.keyCode){case 37:this.left=!0;break;case 38:this.up=!0;break;case 39:this.right=!0;break;case 40:this.down=!0}}}const e="GitHub Contributions Snake",l="You can only play "+e+" on your GitHub profile!";class s{constructor(){let s=[],i=0,r=0;const a=document.querySelectorAll(".js-calendar-graph-svg g .ContributionCalendar-day");if(0<a.length){a.forEach(t=>t.setAttribute("data-level",0)),i=Math.ceil(a.length/7),r=7,s=Array(i*r).fill(-1);for(let e=0;e<r;e++)for(let t=0;t<i;t++)s[t+e*i]=a[e+t*r]}else document.querySelectorAll(".js-calendar-graph-table tr").forEach(t=>{let e=t.querySelectorAll(".ContributionCalendar-day");if(0<e.length){e.length>i&&(i=e.length),e.forEach(t=>{t.removeAttribute("tabindex"),t.setAttribute("data-level",0),s.push(t)});for(let t=e.length;t<i;t++)s.push(-1);r++}});if(0==i||0==r)throw alert(l),l;console.log(e,i,r),this.tiles=s,this.w=i,this.h=r}set_tile_at=(t,e,s)=>{var{tiles:i,w:r}=this;let a=i[e+s*r];a&&-1!=a&&a.setAttribute("data-level",t)};get_tile_at=(t,e)=>{var{tiles:s,w:i}=this;let r=s[t+e*i];return r&&-1!=r?parseInt(r.getAttribute("data-level")):-1}}class i{constructor(t){this.grid=t,this.dx=1,this.dy=0,this.dt=0,this.tiles=[{x:2,y:3},{x:3,y:3},{x:4,y:3}],t.set_tile_at(2,5,5)}moveTo=(t,e)=>{this.dx=t,this.dy=e};draw=()=>{const{tiles:t,grid:e}=this;for(var s=0;s<t.length;s++){var i=t[s];e.set_tile_at(4,i.x,i.y)}};update=t=>{const{dx:e,dy:s,grid:i,tiles:r}=this;if(this.dt+=t,!(this.dt<.2)){this.dt=0;var a=(t=r[r.length-1]).x+e,l=t.y+s;if(!(a<0||a>i.w-1||l<0||l>i.h-1)&&-1!=(t=i.get_tile_at(a,l))&&4!=t)if(r.push({x:a,y:l}),t<=1){t=r.shift();i.set_tile_at(0,t.x,t.y)}else for(let t=0;t<7;t++){a=Math.floor(1+Math.random()*(i.w-1)),l=Math.floor(1+Math.random()*(i.h-1));if(0==i.get_tile_at(a,l)){i.set_tile_at(2,a,l);break}}}}}(new class{constructor(){this.keyboard=new t,this.grid=new s,this.snake=new i(this.grid)}run=()=>{this.last=0,this._tick(0)};_tick=t=>{const{keyboard:e,snake:s,last:i,_tick:r}=this;var a=.001*(t-i);this.last=t,e.left?s.moveTo(-1,0):e.right?s.moveTo(1,0):e.up?s.moveTo(0,-1):e.down&&s.moveTo(0,1),s.update(a),s.draw(),e.reset(),requestAnimationFrame(r)}}).run()})();

floppybird's People

Contributors

icebreaker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

floppybird's Issues

compile to .COM/.EXE file?

this is such a great work! a question: can you have Makefile to compile this to .COM (or .EXE) file, so it is possible to run the game under DosBox/DosEmu?

thanks.

Running Floppy Bird on BIOS

Hi Mihail,

I wanted to share with you something that I’ve been working on lately. It’s called Magnolia, and it’s a tool that lets you run arbitrary programs on the context of a PC BIOS. It works as an Option ROM that can be embedded in the BIOS or on a hardware device, and it executes during the POST. You can find it here: https://github.com/miraliumre/magnolia.

The reason I'm writing is because I have included Floppy Bird as a demo on Magnolia and, while searching if someone else had attempted to something similar before, I have found that there's a 2019 issue (#3) about a similar project. The key difference is that, as an Option ROM, Magnolia with Floppy Bird can be embedded in a much wider range of motherboards, not only those supported by coreboot.

Of course, Magnolia is still a work in progress and it has some bugs and limitations. For example, on one of the motherboards I have tested it in, I can exit Floppy Bird and boot normally, but if I try to enter the CMOS setup screen after playing, the PC crashes. But I’m working on fixing them and improving the functionality.

I hope you don’t mind me using your code for this project. I’ve given you full credit and linked to your GitHub page on the README file. I just wanted to show you what I’ve done with your amazing game and see what you think.

Cheers,
Rodrigo

Floppybird OS inside a BIOS chip - is working great ;-)

Even today the floppies are still being used, for example - as virtual floppies inside the coreboot open source BIOS. Just imagine: your wonderful OS could be a part of someone's BIOS build! (for coreboot supported motherboard, maybe you have or could get one - see https://www.coreboot.org/Supported_Motherboards )

If you already have a coreboot-supported motherboard, or a real chance to get one, - wouldn't it be cool to be able to launch your own OS straight from the BIOS chip? ;) With one simple command it is possible to add any floppy to coreboot BIOS build - and then you see it as a boot entry. Multiple floppies could be added this way (as long as you have enough space left inside the BIOS flash chip, luckily LZMA compression could be used for the stored floppies to reduce their occupied size) - although with the unofficial SeaBIOS multiple floppies patch found here - http://dangerousprototypes.com/docs/Lenovo_G505S_hacking#Unofficial_SeaBIOS_patches .

@icebreaker , my sincere congratulations: I added your FloppyBird compiled image (uploaded by my friend here - https://github.com/mikebdp2/floparchive/blob/master/floppies_extra/floppybird.img ) to the coreboot.rom BIOS build for my Lenovo G505S , and it's working perfectly 😉 Also, after LZMA compression your FloppyBird occupies just 2174 bytes inside the flash chip. Thank you very much for this beautiful game, Mihail, it made my BIOS better and funnier 👍

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.