Skip to content

Instantly share code, notes, and snippets.

@MortytKane
Created March 17, 2020 12:51
Show Gist options
  • Select an option

  • Save MortytKane/617940adec999d95c117ec3c72343be6 to your computer and use it in GitHub Desktop.

Select an option

Save MortytKane/617940adec999d95c117ec3c72343be6 to your computer and use it in GitHub Desktop.
int var1 = 20;
int num=20;
float[]AngleX=new float[num];
float[]AngleY=new float[num];
int unit = 60;
int count;
Module[] mods;
void setup(){
size(2000,1000,P3D);
noStroke();
for(int i=0; i<num; i++){
AngleX[i]=random(360);
AngleY[i]=random(360);
int wideCount = width / unit;
int highCount = height / unit;
count = wideCount * highCount;
mods = new Module[count];
int index = 0;
for (int y = 0; y < highCount; y++) {
for (int x = 0; x < wideCount; x++) {
mods[index++] = new Module(x*unit, y*unit, unit/2, unit/2, random(0.05, 0.8), unit);
}
}
}
}
void draw(){
background(#D32C0F);
translate(width/2,height/2);
int wideCount = width / unit;
int highCount = height / unit;
count = wideCount * highCount;
for(int i=0; i<num; i++){
AngleX[i]+=1;
AngleY[i]+=1;
noFill();
strokeWeight(35);
stroke(#FFDF74);
strokeWeight(10);
rotateX(radians(AngleX[i]));
rotateY(radians(AngleY[i]));
circle(1000,500,1500);
circle(1000,1000,15);
circle(var1,1000,150);
circle(1000,var1,200);
circle(1000,500,100);
circle(1000,1000,1000);
noStroke();
var1 +=5;
}
frameRate(500);
colorMode(HSB, 360, 100, 100);
fill(random(20,200), random(40,70), random(0,300));
println("mousex = " + mouseX);
println("mousey = " + mouseY);
background(0);
for (Module mod : mods) {
mod.update();
mod.display();
}
}
class Module {
int xOffset;
int yOffset;
float x, y;
int unit;
int xDirection = 1;
int yDirection = 1;
float speed;
// Contructor
Module(int xOffsetTemp, int yOffsetTemp, int xTemp, int yTemp, float speedTemp, int tempUnit) {
xOffset = xOffsetTemp;
yOffset = yOffsetTemp;
x = xTemp;
y = yTemp;
speed = speedTemp;
unit = tempUnit;
}
void update() {
x = x + (speed * xDirection);
if (x >= unit || x <= 0) {
xDirection *= 10;
x = x + (1 * xDirection);
y = y + (1 * yDirection);
}
if (y >= unit || y <= 0) {
yDirection *= 10;
y = y + (1 * yDirection);
}
}
// Custom method for drawing the object
void display() {
//make colors change with mouse click and motion
rect(xOffset + x, yOffset + y, 100, 40);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment