Ride the Downcoin roller coaster, but watch out for price spikes. How low can you go? Click/touch jumps.
for(H='&&~~(Zl.YYdX=YW)/VinU*r =(=0);c.y-x-);3399),(p) 0,Math.absX?(o=(Ya)*sU*cos=m+n,=m-n,1,m=-Xa.height random()strokePI/2Style="#sqrt(x/rVbegUPath(filla.widthx=;g=P=T=t=w=v=y=0;r=/;onmousedown=a.onclick)=>{T=t};s=[{x:y:i:v:a:0}];(HF,u)=>{requestAnimationFrame(Hf=F-(t||FI=v*f;Rw+=f /1)*f;S=/4;b= /2;t=FRect(, for(l=s[0];Yx<=S+;s.unshift(l))qWx+2 ,kWy+2 ,j=x>?9*v/r+4*(Yv-yV:-.1,0>):<(g?(.2-)*g:X)*~0<=-/2-g,g:(m=g++,o=mU(max(X?0:Ya+(-.5V3,-j/3*(1-j))pYa+oV2-,l={x:q,y:k,i:q+cos,v:k+(0<m?0:sUa:o,d:m}f"for(j=0;!u||u.x>S;u=l)l=s[j++],c.lUeTo(YS,YbOWa-,Q=(O-atan2(R,I)u~Q>~Q<3*ZM=tan,G=R/I,hWv-M*Yi,v?qG*hV(M-G):q=x,q<u.i~q>WiZk=M*q+h,e=q,N=k,e*e+N*N<I*I+R*RZm=v+w,n=.*(v-wvwo=x+I-q,p=y+R-k,m=o+p,n=-1,x=q,y=k,IRP=F,XZx=,y)))(x+=I;y+=R;T~2>(T-P)Zw=-r/,P=Tc.arc(S,b,r,7)f"()Text("$"+(9-(y/r|0)S-r,b-2 )0"})(0';G=/[^!-T[-}]/.exec(H);)with(H.split(G))H=join(shift());eval(H)
Zm9yKEg9JyYmfn4oWmwuWVlkWD1ZVykvVmluVSpyID0oHz0wKR47Yy4deS0ceC0bKTsaMzMZOTkYKSwXKHApIBYwLBVNYXRoLhQUYWJzE1g/KG89EihZYSkRKhRzVREQKhRjb3MRDz1tECtuDywOPW0PLW4QLAwxLG09LVgLYS5oZWlnaHQJFHJhbmRvbSgpCB1zdHJva2UHFFBJLzIGU3R5bGU9IiMFFHNxcnQo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GgoSC5zcGxpdChHKSlIPWpvaW4oc2hpZnQoKSk7ZXZhbChIKQ==
// saves about 24 bytes
var COIN_SYMBOL = null;
var DRAW_SCORE = true;
// saves 19 bytes
var CENTER_SCORE = false;
var ALLOW_JUMPING = true;
var FLATTEN_AT_ZERO = false;
var ZERO = 999;
var FIX_VIEWPORT_WIDTH = 0; // 799
var FIX_VIEWPORT_HEIGHT = 0;
var FIX_COIN_SCALE = 0; // 9
var LINE_SCALE = 0; //0.2
var FONT_SCALE = 0; // 1.5
var DEADLY_SPIKES = true;
var FLATTEN_SPIKES = true;
var DEBUG_COLLISIONS = false;
var SLIGHTLY_SAFER_COLLISIONS = false;
var SLIGHTLY_SAFER_DEATHS = false;
var REGENERATE_ON_DEATH = false;
// #99* saves a byte due to compression
var GROUND_COLOR = '#99f'; //99f
// #*99 saves a byte due to compression
var COIN_COLOR = '#f99';
// #*33 saves a byte due to compression
var BACKGROUND_COLOR = '#330';
// saves 5 bytes
var MAX_MILLISECONDS_PER_FRAME = 0; //99 compresses well
var GOOD_TOUCH = false;
// true saves 5 bytes on GOOD_TOUCH, both false saves 17
var OK_TOUCH = true;
var RESTITUTION = .33;
var DISABLE_GRADIENT_EQUALITY_CHECK = true;
var LEVEL_GENERATION_SCALE_FACTOR = 2;
// TODO draw a spinning $ in the coin
// TODO glowing ground
// TODO collectible coins
// TODO buy/sell mode
//M = Math.abs;
//S = Math.sin;
//C = Math.cos;
//P = Math.PI;
if (FIX_VIEWPORT_HEIGHT && FIX_VIEWPORT_WIDTH) {
a.width = FIX_VIEWPORT_WIDTH;
a.height = FIX_VIEWPORT_HEIGHT;
}
else if (FIX_VIEWPORT_WIDTH) {
a.height = FIX_VIEWPORT_WIDTH * a.height / a.width;
a.width = FIX_VIEWPORT_WIDTH;
}
//let scale = canvasWidth / 50;
x = a.width;
y = 0;
v = 0;
w = 0;
t = 0;
T = 0;
L = 0;
g = 0;
if (FIX_COIN_SCALE) {
r = FIX_COIN_SCALE;
}
else {
r = a.width / 99;
}
if (ALLOW_JUMPING) {
// have to add to canvas, otherwise it doesn't work on mobile
if (GOOD_TOUCH) {
onmousedown = a.ontouchstart = function () {
T = t;
};
}
else if (OK_TOUCH) {
onmousedown = a.onclick = function () {
T = t;
};
}
else {
a.onclick = function () {
T = t;
};
}
}
s = [
{
x: 0,
y: 0,
u: 0,
v: 0,
a: 0
}
];
if (LINE_SCALE) {
c.lineWidth = Math.max(1, LINE_SCALE * r);
}
if (FONT_SCALE) {
c.font = '' + Math.max(12, r * FONT_SCALE) + 'px serif';
}
(_ = function (now, nextPoint) {
requestAnimationFrame(_);
if (MAX_MILLISECONDS_PER_FRAME) {
f = Math.min(now - (t || now), MAX_MILLISECONDS_PER_FRAME);
}
else {
f = now - (t || now);
}
// gravity
/*
if( FIX_COIN_SCALE ) {
w += f / 999;
} else {
w += (f * r) / 9999;
}
*/
// distance traveled
D = v * f;
U = (FIX_COIN_SCALE ? w += f / 6999 : w += (f * r) / 13399) * f;
// camera bounds
X = x - a.width / 4;
Y = y - a.height / 2;
t = now;
// clear screen
c.fillRect(0, 0, a.width, a.height);
// fill in the surfaces
for (l = s[0]; l.x <= X + a.width; s.unshift(l)) {
q = l.x + Math.cos(l.a) * (LEVEL_GENERATION_SCALE_FACTOR ? r * LEVEL_GENERATION_SCALE_FACTOR : r);
// add in more lines
k = l.y + Math.sin(l.a) * (LEVEL_GENERATION_SCALE_FACTOR ? r * LEVEL_GENERATION_SCALE_FACTOR : r);
if (!FIX_COIN_SCALE) {
j = x > a.width ? v * 9 / r + (l.v - y) * 4 / a.width : -.1;
}
else {
// TODO not sure this forumla is right
j = x > a.width ? v + (l.v - y - 20) / 33 : 0;
}
if (DEADLY_SPIKES && l.d < 0) {
o = 1; // PI/3
m = -l.d;
}
else if (DEADLY_SPIKES && Math.random() < (g ? (.2 - Math.abs(l.a)) * g : l.d) * Math.sqrt(x / r) / 3399 && l.d >= 0) {
o = -1; //-PI/3
m = -l.d / 2 - g;
g = 0;
}
else {
if (DEADLY_SPIKES) {
m = 0;
g++;
}
if (FLATTEN_AT_ZERO && k > ZERO / r) {
o = 0;
}
else {
o = Math.min(Math.max(l.d ? 0 : l.a + (Math.random() - .5) / 3, -j / 3), (Math.sqrt(x / r) / 33) * (1 - j));
}
}
p = (l.a + o) / 2 - Math.PI / 2;
if (DEADLY_SPIKES) {
l = {
x: q,
y: k,
u: q + Math.cos(p) * r,
v: k + (m > 0 && FLATTEN_SPIKES ? 0 : Math.sin(p) * r),
a: o,
d: m
};
}
else {
l = {
x: q,
y: k,
u: q + Math.cos(p) * r,
v: k + Math.sin(p) * r,
a: o
};
}
}
// draw in the surface and collide as neccessary
//F = Math.atan2(U, D);
c.strokeStyle = GROUND_COLOR;
c.beginPath();
for (j = 0; !nextPoint || nextPoint.x > X; nextPoint = l) {
l = s[j++];
c.lineTo(l.x - X, l.y - Y);
O = l.a - Math.PI / 2;
Q = Math.abs(O - Math.atan2(U, D));
if (nextPoint && Q > Math.PI / 2 && Q < Math.PI * 3 / 2) {
// check for collision
K = Math.tan(l.a);
G = U / D;
if (DISABLE_GRADIENT_EQUALITY_CHECK || K != G) {
Z = l.v - K * l.u;
if (v) {
q = ((y - G * x) - Z) / (K - G);
}
else {
q = x;
}
// is it in bounds of the line?
if (
// x always goes from right to left
q < nextPoint.u && q >= l.u) {
k = K * q + Z;
e = x - q;
z = y - k;
if ((e * e) + (z * z) < (D * D) + (U * U)) {
// bounce off
//h = Math.sin(l.a);
//g = Math.cos(l.a);
m = v * Math.cos(l.a) + w * Math.sin(l.a);
if (RESTITUTION) {
n = (v * Math.sin(l.a) - w * Math.cos(l.a)) * RESTITUTION;
}
else {
n = 0;
}
v = m * Math.cos(l.a) - n * Math.sin(l.a);
w = m * Math.sin(l.a) + n * Math.cos(l.a);
o = x + D - q;
p = y + U - k;
m = o * Math.cos(l.a) + p * Math.sin(l.a);
// elevate slightly to avoid falling through ground
if (SLIGHTLY_SAFER_COLLISIONS) {
n = -Math.sqrt(Math.abs(m)) - .1;
}
else {
n = -1;
}
x = q;
y = k;
D = m * Math.cos(l.a) - n * Math.sin(l.a);
U = m * Math.sin(l.a) + n * Math.cos(l.a);
L = now;
if (DEADLY_SPIKES && l.d) {
x = a.width;
y = 0;
if (SLIGHTLY_SAFER_DEATHS) {
if (REGENERATE_ON_DEATH) {
w = 0;
v = 0;
s.splice(0, s.length - 1);
}
break;
}
}
}
}
}
}
}
c.stroke();
x += D;
y += U;
if (ALLOW_JUMPING && T && Math.abs(T - L) < 233) {
if (FIX_COIN_SCALE) {
w = -FIX_COIN_SCALE / 99;
}
else {
w = -r / 33;
//w -= 0.5;
}
T = 0;
L = 0;
}
// debug collision bounds
if (DEBUG_COLLISIONS) {
c.strokeStyle = '#F00';
c.beginPath();
j = 0;
do {
l = s[j];
j++;
c.lineTo(l.u - X, l.v - Y);
nextPoint = l;
} while (nextPoint.x > X);
c.stroke();
}
// draw player
c.beginPath();
c.arc(x - X, y - Y, r, 0, 7);
if (COIN_COLOR) {
c.fillStyle = COIN_COLOR;
c.fill();
if (DRAW_SCORE) {
if (CENTER_SCORE) {
c.textAlign = 'center';
c.fillText('$' + (ZERO - (y / r | 0)), x - X, y - Y - r * 2);
}
else {
c.fillText('$' + (ZERO - (y / r | 0)), x - X - r, y - Y - r * 2);
}
}
c.fillStyle = BACKGROUND_COLOR;
if (COIN_SYMBOL) {
c.fillText(COIN_SYMBOL, x - X - r / 2, y - Y + r / 2);
}
}
else {
if (BACKGROUND_COLOR) {
c.fillStyle = BACKGROUND_COLOR;
}
c.stroke();
}
})(0);