Breakout
How do I make an breakout?
What is a breakout? How do you make a breakout? This script and codes were developed by Tiffany Rayside on 13 June 2022, Monday.
Breakout - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>breakout</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <canvas id='canv' ></canvas> <script src="js/index.js"></script>
</body>
</html>
Breakout - Script Codes CSS Codes
body{ width:100%; margin:0; overflow:hidden;
}
Breakout - Script Codes JS Codes
var c = document.getElementById('canv');
var $ = c.getContext('2d');
var w = c.width = window.innerWidth;
var h = c.height = window.innerHeight;
var grav = 0.00095;
var s = [20, 15, 10, 5];
var gravX = w / 2;
var gravY = h / 2;
var nodes;
var num = 55;
var minDist = 155;
var spr = 0.0000009;
part();
run();
//random size function
function S() { var curr = s.length; var cur_ = Math.floor(Math.random() * curr); return s[cur_];
}
function part() { nodes = []; for (var i = 0; i < num; i++) { var node = { hue: Math.random()*360, rad: S(), x: Math.random() * w, y: Math.random() * h, vx: Math.random() * 8 - 4, vy: Math.random() * 8 - 4, upd: function() { this.x += this.vx; this.y += this.vy; if (this.x > w) this.x = 0; else if (this.x < 0) this.x = w; if (this.y > h) this.y = 0; else if (this.y < 0) this.y = h; }, draw: function() { //outer ring var g = $.createRadialGradient(this.x, this.y, this.rad * 2, this.x, this.y, this.rad); g.addColorStop(0,'hsla(242, 55%, 15%,.7)'); g.addColorStop(.5, 'hsla(242, 50%, 10%,.5)'); g.addColorStop(1,'hsla(242, 30%, 5%,.5)'); $.fillStyle = g; $.beginPath(); $.arc(this.x, this.y, this.rad * 2, 0, Math.PI * 2, true); $.fill(); $.closePath(); //inner particle var g2 = $.createRadialGradient(this.x, this.y, 0, this.x, this.y, this.rad); g2.addColorStop(0, 'hsla('+this.hue+', 85%, 40%, 1)'); g2.addColorStop(.5, 'hsla('+this.hue+',95%, 50%,1)'); g2.addColorStop(1,'hsla(0,0%,0%,0)'); $.fillStyle = g2; $.beginPath(); $.arc(this.x, this.y, this.rad, 0, Math.PI * 2, true); $.fill(); $.closePath(); } }; nodes.push(node); }
}
function run() { $.globalCompositeOperation = 'source-over'; $.fillStyle = 'hsla(242, 40%, 5%,.85)'; $.fillRect(0, 0, w, h); $.globalCompositeOperation = 'lighter'; for (i = 0; i < num; i++) { nodes[i].upd(); nodes[i].draw(); } for (i = 0; i < num - 1; i++) { var n1 = nodes[i]; for (var j = i + 1; j < num; j++) { var n2 = nodes[j]; Spr(n1, n2); } Grav(n1); } window.requestAnimationFrame(run);
}
function Spr(na, nb) { var dx = nb.x - na.x; var dy = nb.y - na.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist < minDist) { $.lineWidth = 1; $.beginPath(); $.strokeStyle = "hsla(217, 95%, 55%, .15)"; $.moveTo(na.x, na.y); $.lineTo(nb.x, nb.y); $.stroke(); $.closePath(); var ax = dx * spr; var ay = dy * spr; na.vx += ax; na.vy += ay; nb.vx -= ax; nb.vy -= ay; }
}
function Grav(n) { n.vx += (gravX - n.x) * grav; n.vy += (gravY - n.y) * grav;
};
window.addEventListener('resize', function() { c.width = w = window.innerWidth; c.height = h = window.innerHeight;
});
Developer | Tiffany Rayside |
Username | tmrDevelops |
Uploaded | June 13, 2022 |
Rating | 4.5 |
Size | 2,618 Kb |
Views | 34,408 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Curvature | 2,809 Kb |
Birds of a Feather | 6,076 Kb |
Enchanted | 2,861 Kb |
Life Of Tree | 3,644 Kb |
Whizzzer | 5,048 Kb |
Widgets | 13,771 Kb |
GOOey | 5,088 Kb |
Legions | 3,557 Kb |
Psychotomimetic | 2,314 Kb |
LED Marquee | 3,769 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
3d css cube | Semenchenko | 4,578 Kb |
Hard-Stop Gradients | Mackdoyle | 2,288 Kb |
A vuejs widget | Chrgl86 | 2,869 Kb |
Impress JS Algorhytmic Generator | Jeffscottward | 7,906 Kb |
Polo, the flying squirrel | Agbales | 2,445 Kb |
HTML5 Breakout | Jaysalvat | 4,873 Kb |
GrcJS | Vino6 | 2,047 Kb |
Spilled Paint | Darrylhuffman | 3,894 Kb |
CardMove | Thompsonemerson | 3,699 Kb |
React TODO | Enieste | 3,320 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!