p5实现粒子穿越星际穿越效果
代码语言:html
所属分类:粒子
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> body{ margin:0 auto; background: #333; display: flex; justify-content: center; } </style> </head> <body translate="no"> <script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/p5.js"></script> <script> //Coding Challenge #78 //Thanks Dan sensei! let particles = []; //particlesは配列 function setup() { createCanvas(windowWidth, windowHeight); } function draw() { background(10,10,20); for(let i = 0; i < 5; i++){ let p = new Particle(); particles.push(p); //オブジェクトを追加するpush関数 } for (let i = particles.length-1; i >= 0; i--) { particles[i].update(); particles[i].show(); if (particles[i].finished()){ //alphaが0になったらsplice関数は配列か.........完整代码请登录后点击上方下载按钮下载查看
网友评论0