Readit News logoReadit News
rsiqueira · 6 years ago
The first ideas of this 3D road game was created in just 140 characters (or less) and posted here (Dwitter) by him (Frank Force's nickname is "KilledByAPixel"): https://www.dwitter.net/h/road And many other tiny 3D effects and engines in JavaScript were created by Dwitter's users, like these demos: https://www.dwitter.net/h/d3
tomxor · 6 years ago
Hi Rodrigo!

Just wanted to add... Dwitter is awesome for learning stuff like this, since everything is so absurdly small you know the ceiling of time required for understanding a dweet is pretty low - yet at the same time it's surprising how advanced techniques can get in this tiny space.

This makes them so tempting. I sometimes struggle to pick up or return to a technical book when work/life etc gets busy, but when someone posts an interesting new dweet I often can't stop myself from pulling it to pieces.

midgetjones · 6 years ago
Seems to be struggling a bit. Alternate link: https://web.archive.org/web/20200309074327/http://frankforce...
itronitron · 6 years ago
here is the codepen link from same article >> https://codepen.io/KilledByAPixel/pen/poJdLwB
TruthSHIFT · 6 years ago
FYI, there is no jump button. Also, those are rocks, not ramps. Jumping is not a gameplay mechanic in this game.
huskyr · 6 years ago
"Resource Limit Is Reached", seems a bit silly for a 2kb game ;)
techntoke · 6 years ago
Should call it "How I host my website for $2 a year."
sbr464 · 6 years ago
You could get the minified code size lower with a few tricks below. This allows the minifier to stop using the longer method names. It also has the benefit of eliminating an object property lookup which is significantly slower than accessing a variable (under a microscope of course, if called many times). Probably 5-10% savings by doing this for the Math methods.

1. Create variables for any global/builtins (setTimeout/clearTimeout, requestAnimationFrame, etc) at the top of the file.

2. Create variables for global object properties, especially if used multiple times or they have longer names (Object.assign, Object.hasOwnProperty, Math.cos, Math.sin , JSON.stringify).

3. For non globals, within functions, create variables for any object properties or methods that are called multiple times to be worth it; like in formulas where obj.width/height is called 4-5 times, the minifier can't optimize the property name.

4. For Class instance methods that don't allow creating variables for methods (You have to call the method with the class, since they operate on "this" context) but don't have anything unique about "this", you can create a variable once within a function, then just bind itself. If you are using it multiple times to be worth it.

  const classMethod = ClassInstance.classMethod.bind(ClassInstance)
would be minified to

  const Z = X.classMethod.bind(X)
and (in the minified code) used as Z() instead of X.classMethod()

5. In longer functions that use "this.whatever" many times, you can create a variable once for "this" (t or _this etc) and the minifier will be able to eliminate those bytes.

jsgamedev · 6 years ago
This is very impressive!

Lots of counterintuitive observations when you realize the objective is for compressed 2k size, which means that duplicate code is actually a good thing!

It reminds me of this 3d maze in 1k of javascript from many years ago: https://js1k.com/2010-first/demo/459

KilledByAPixel · 6 years ago
Thanks, I also referenced this jk1k racing game in the post...

https://js1k.com/2019-x/demo/4006

throwaway77384 · 6 years ago
I absolutely love projects like this. It's so interesting working within these constraints.

So, js1k is not continuing? On the js1k site I can't see anything stating this. Nothing on the subreddit either. Where is that information coming from?

It's a real shame that this great tradition may not continue, though, perhaps the js2k+ will be the next big thing ;)

woogley · 6 years ago
Only thing I can find is this tweet from the organizer. https://twitter.com/kuvos/status/1213546333707083778
pjmlp · 6 years ago
Love the WASM remark on his tweet.

Think WASM coding like the original Demoscene demos.

jfkebwjsbx · 6 years ago
I love these projects, but writing statements like "full HD" and "Realistic driving physics and collisions" is a bit too much unless it is tongue-in-cheek :)
KilledByAPixel · 6 years ago
HD because many tiny games like this do not stretch to fill the whole window. It requires extra code to do this and have everything scale properly.
buzzerbetrayed · 6 years ago
I've never heard "HD" be used to mean "full width"
nathell · 6 years ago
Also in the genre of tiny racing games, this 2004 entry from IOCCC comes to mind:

https://www.ioccc.org/2004/vik1.c

sccxy · 6 years ago
Controls:

Mouse = Steer

Click = Brake

Double Click = Jump

https://github.com/KilledByAPixel/HueJumper2k