Wayward Walker Worms
How do I make an wayward walker worms?
Yet another random walk Pen.Constant step size. Directions: right, up, left, down. Each walker has a tail (history) which makes it a walker worm.. What is a wayward walker worms? How do you make a wayward walker worms? This script and codes were developed by Johan Karlsson on 12 August 2022, Friday.
Wayward Walker Worms - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Wayward Walker Worms</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <script src='https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.6/p5.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Wayward Walker Worms - Script Codes CSS Codes
html, body { margin: 0; background-color: black; overflow: hidden;
}
canvas { display: block;
}
Wayward Walker Worms - Script Codes JS Codes
"use strict";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Walker = function () { function Walker(stepSize) { _classCallCheck(this, Walker); this.x = floor(random(w / stepSize)) * stepSize; this.y = floor(random(h / stepSize)) * stepSize; this.stepSize = stepSize; this.hue = random(60) + 260; this.tail = []; this.tailLength = 20; } Walker.prototype.walk = function walk() { if (this.tail.length > this.tailLength) { this.tail.splice(0, 1); } var angle = random(angles); this.x += cos(angle) * this.stepSize; this.y += sin(angle) * this.stepSize; this.tail.push([this.x, this.y]); stroke(this.hue, 100, 55, 1); for (var i = 0; i < this.tail.length - 1; i++) { var p1 = this.tail[i]; var p2 = this.tail[i + 1]; line(p1[0], p1[1], p2[0], p2[1]); } this.bounce(); }; Walker.prototype.bounce = function bounce() { if (this.x < 0) this.x = 0; if (this.x > w) this.x = w; if (this.y < 0) this.y = 0; if (this.y > h) this.y = h; }; return Walker;
}();
var angles = undefined;
var nrOfWalkers = undefined;
var walkers = undefined;
var stepSize = undefined;
var w = undefined;
var h = undefined;
function setup() { nrOfWalkers = 50; angles = [0, PI / 2, PI, 3 * PI / 2]; stepSize = 8; setWidthAndHeigt(); walkers = []; for (var i = 0; i < nrOfWalkers; i++) { var walker = new Walker(stepSize); walkers.push(walker); } createCanvas(w, h); strokeWeight(2); colorMode(HSL);
}
function draw() { background("black"); walkers.forEach(function (w) { return w.walk(); });
}
function windowResized() { setWidthAndHeigt(); resizeCanvas(w, h);
}
function setWidthAndHeigt() { w = round(windowWidth / stepSize) * stepSize; h = round(windowHeight / stepSize) * stepSize;
}
Developer | Johan Karlsson |
Username | DonKarlssonSan |
Uploaded | August 12, 2022 |
Rating | 4.5 |
Size | 3,123 Kb |
Views | 54,648 |
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 |
Fireflies | 2,572 Kb |
SoundCloud Music Visualizer | 4,211 Kb |
Laser Writer | 6,065 Kb |
Random Fractal | 2,751 Kb |
Brownian Motion | 2,549 Kb |
Brownian Gnats | 2,822 Kb |
Circuit Board Warper | 4,057 Kb |
In Tribute to Simon Plouffe | 2,376 Kb |
Apply Filter Effects to Music | 4,027 Kb |
Moss by Brownian Motion | 2,792 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 |
IE flex collapse bug fix | Rowno | 2,678 Kb |
Testimonial Fancy tabs responsive | Amit-webdesigner | 3,056 Kb |
GLSL Hills | Ykob | 6,991 Kb |
Parallax scrolling scene | Iharosi | 2,485 Kb |
Preloader | Rikki_Sixx | 2,815 Kb |
Nice textured background | Hans | 2,659 Kb |
DevCamp 2014 - Denver Public Library | See8ch | 5,033 Kb |
A Pen by MurabitoB | MurabitoB | 4,421 Kb |
Material Design-Layout-Principles Practice | Fraina | 2,331 Kb |
A Pen by Jay | Jaycode | 3,784 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!