-
Notifications
You must be signed in to change notification settings - Fork 0
/
main
98 lines (78 loc) · 2.02 KB
/
main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import twitter4j.conf.*;
import twitter4j.*;
import twitter4j.auth.*;
import twitter4j.api.*;
import java.util.*;
Twitter twitter;
String searchString = "#brokendreams";
List<Status> tweets;
int currentTweet;
PFont f;
int amount1 = 300;
Star[] meteors = new Star[24]; // define array of meteors
StarDust[] sprinkle = {};
String chatter;
void setup() {
size(800,600);
f = createFont("Tahoma", 13, true);
textFont(f, 13);
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey("");
cb.setOAuthConsumerSecret("");
cb.setOAuthAccessToken("");
cb.setOAuthAccessTokenSecret("");
TwitterFactory tf = new TwitterFactory(cb.build());
twitter = tf.getInstance();
getNewTweets();
currentTweet = 0;
dustField();
Status status = tweets.get(currentTweet);
for (int j = 0; j < meteors.length; j++) {
meteors[j] = new Star(chatterText());
}
} // END setup function
void draw() {
background(0);
for (int i = 0; i < sprinkle.length; i++) {
StarDust dust = sprinkle[i];
dust.move();
}
for (int j = 0; j < meteors.length; j++) {
meteors[j].appear();
meteors[j].randomOrbit();
}
chatterText();
} // END draw function
void dustField() {
for (int i = 0; i < amount1; i++) {
StarDust dust = new StarDust(); // instance of StarDust
dust.swish();
sprinkle = (StarDust[])append(sprinkle, dust); // add new instance to array
}
}
String chatterText() {
currentTweet += 1;
if (currentTweet >= tweets.size()) {
currentTweet = 0;
}
Status status = tweets.get(currentTweet);
chatter = status.getText();
return chatter;
}
void getNewTweets() {
try {
Query query = new Query(searchString);
QueryResult result = twitter.search(query);
tweets = result.getTweets();
} catch (TwitterException te) {
System.out.println("Failed to search tweets: " + te.getMessage());
System.exit(-1);
}
}
void refreshTweets() {
while (true) {
getNewTweets();
println("Updated Tweets");
delay(30000);
}
}