Skip to content

Commit d5a6bfe

Browse files
authored
added new things
new render(opengl), new sparks effect and optimization
1 parent 6907d80 commit d5a6bfe

File tree

5 files changed

+104
-5
lines changed

5 files changed

+104
-5
lines changed

effects.pde

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,21 @@ void CircleNetwork() {
8080
}
8181
}
8282
}
83+
}
84+
void sparks(){
85+
86+
for (Spark spark : sparks) {
87+
spark.update();
88+
spark.display();
89+
}
90+
if(mousePressed){
91+
if(mouseFlag==false){
92+
sparks.add(new Spark());
93+
}
94+
mouseFlag=true;
95+
}
96+
if(!mousePressed){
97+
mouseFlag=false;
98+
}
99+
83100
}

etcEffects.pde

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,57 @@ class Circle {
102102
noStroke();
103103
ellipse(x, y, 20, 20);
104104
}
105-
}
105+
}
106+
class Spark {
107+
PVector loc;
108+
PVector vel;
109+
PVector acc;
110+
111+
float angle;
112+
113+
int baseColor;
114+
115+
Spark() {
116+
loc = new PVector(mouseX, mouseY);
117+
vel = new PVector(0, 0);
118+
acc = new PVector(0, 0);
119+
120+
baseColor = (int) random(0, 360);
121+
}
122+
123+
void update() {
124+
125+
angle += random(0, TWO_PI);
126+
127+
float magni = random(0, 3);
128+
129+
acc.x += cos(angle) * magni;
130+
acc.y += sin(angle) * magni;
131+
132+
acc.limit(3);
133+
134+
vel.add(acc);
135+
vel.limit(6);
136+
137+
loc.add(vel);
138+
139+
140+
if (loc.x > width)
141+
loc.x -= width;
142+
if (loc.x < 0)
143+
loc.x += width;
144+
if (loc.y > height)
145+
loc.y -= height;
146+
if (loc.y < 0)
147+
loc.y += height;
148+
}
149+
150+
void display() {
151+
152+
stroke((baseColor + millis() / 25.0)
153+
% 360, 80, 80, 204);
154+
strokeWeight(15);
155+
156+
point(loc.x, loc.y);
157+
}
158+
}

initEffects.pde

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,16 @@ void CircleNetworkEff(){
3333
if(back.IsPressed()){
3434
scenes=1;
3535
}
36-
}
36+
}
37+
void SparksEff(){
38+
sparks();
39+
40+
textSize(70);
41+
textAlign(CENTER);
42+
back.Display();
43+
fill(255);
44+
text("Back",width/4,height/1.1);
45+
if(back.IsPressed()){
46+
scenes=1;
47+
}
48+
}

list.pde

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ void lisT(){
44
fireworkEffect.Display();
55
back.Display();
66
circNetw.Display();
7+
spark.Display();
78
textSize(70);textAlign(CENTER);fill(255);text("Back",width/4,height/1.1);
89
fill(255);
910
textSize(53);
1011
text("Wave Effect",width/3,height/9.6);
1112
textSize(53);
1213
text("Firework Effect",width/3,height/5.8);
1314
text("Circle Network",width/3,height/4.2);
15+
text("Sparks",width/3,height/3.2);
1416
if(waveEffect.IsPressed()){
1517
scenes=2;
1618
}
@@ -23,4 +25,7 @@ void lisT(){
2325
if(circNetw.IsPressed()){
2426
scenes=5;
2527
}
28+
if(spark.IsPressed()){
29+
scenes=6;
30+
}
2631
}

main.pde

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import processing.sound.*;
2-
2+
import processing.opengl.*;
3+
import android.content.Context;
34
SoundFile sound;
45
SoundFile click;
56
Button menu;
@@ -8,34 +9,42 @@ Button back;
89
Button fireworkEffect;
910
Button devs;
1011
Button circNetw;
12+
Button spark;
13+
ArrayList<Spark> sparks;
14+
1115
PFont mfont;
1216
PImage Plogo;
1317
float angle = 0;
1418
int maxRings = 20;
1519
ArrayList<Ring> rings = new ArrayList<Ring>();
1620
boolean mousePressedFlag = false;
1721
boolean mouseReleasedFlag = true;
22+
boolean mouseFlag = false;
1823
int numCircles = 50;
1924
float maxDistance = 200;
2025
Circle[] circles = new Circle[numCircles];
2126

2227
ArrayList<Firework> fireworks;
2328
int scenes=0; //0menu1effectlist2,3...effects
2429
void setup() {
25-
size(displayWidth, displayHeight, P2D);
30+
size(displayWidth, displayHeight, OPENGL);
2631
menu = new Button(width/2, height/2, width/2, height/20, 0, 0);
2732
devs = new Button(width/2, height/1.7, width/2, height/20, 0, 0);
2833
waveEffect = new Button(width/3, height/10, width/2.5, height/20, 200, 150);
2934
fireworkEffect = new Button(width/3, height/6, width/2.2, height/20, 200, 150);
3035
circNetw= new Button(width/3, height/4.3, width/2.2, height/20, 200, 150);
36+
spark = new Button(width/3, height/3.3, width/2.6, height/20, 200, 150);
3137
back = new Button(width/4, height/1.11, width/3, height/20, 200, 150);
3238
sound = new SoundFile(this, "muzik.wav");
3339
click = new SoundFile(this, "click.wav");
3440
Plogo = loadImage("Plogo.png");
3541
mfont = createFont("KiwiSoda.ttf", 50);
3642
textFont(mfont);
43+
sparks = new ArrayList<Spark>();
3744
fireworks = new ArrayList<Firework>();
3845
sound.loop();
46+
47+
strokeCap(ROUND);
3948
for (int i = 0; i < numCircles; i++) {
4049
circles[i] = new Circle(random(width), random(height));
4150
}
@@ -83,7 +92,7 @@ void draw() {
8392
fill(255);
8493
text("Back", width/4, height/1.1);
8594
textSize(60);
86-
text("Main developer : elliktronic \n Music by : example \n", width/2, height/2);
95+
text("Main developer : elliktronic \n Music by : (downloaded on random site) \n Spark effect: by CalsignLabs", width/2, height/2);
8796
image(Plogo, width/1.5, height/1.2, width/5, height/10);
8897
if (back.IsPressed()) {
8998
scenes=0;
@@ -92,4 +101,7 @@ void draw() {
92101
if (scenes==5) {
93102
CircleNetworkEff();
94103
}
104+
if (scenes==6) {
105+
SparksEff();
106+
}
95107
}

0 commit comments

Comments
 (0)