-
Notifications
You must be signed in to change notification settings - Fork 0
/
TheLibrary.pde
156 lines (124 loc) · 3.43 KB
/
TheLibrary.pde
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
//----- Processing Mapping Library
import deadpixel.keystone.*;
Keystone ks;
CornerPinSurface surface1;
CornerPinSurface surface2;
PGraphics p1;
PGraphics p2;
//----- Processing Video Library
import processing.video.*;
VideoFrames video;
float videoSpeed = 0.6;
String gameState = "Playing";
//"Playing" = Playing - Changes are allowed
//"Win" = Win - No changes allowed
//"Lose" = Lose - No changes allowed
//"Reverse" = Reverse playback - No changes allowed
//----- Writing Input System
int lines = 7;
int linesSplit = lines % 2 == 0 ? lines / 2 : lines / 2 + 1;
String[] lineStrings = new String[lines];
int charactersPerLine = 29;
int currentCharactersToWin = 120;
int charactersToWin;
int currentLine = 0;
boolean safety = true;
boolean safetyKey = false;
boolean pressingKeys = false;
boolean firstPressedKey = false;
boolean pressKeys;
float counter = 1;
float contadorMemoria = 2;
float timeWithoutPressingKeys = 0;
//----- Save Texts
boolean currentTextIsSaved = false;
String[] lineStringsToSave = new String[1];
int nameID = 1;
//----- Design
PFont font;
PImage logo;
void setup()
{
size(1920, 1080, P3D);
//----- Mapping
ks = new Keystone(this);
surface1 = ks.createCornerPinSurface(width/2, height, 20);
surface2 = ks.createCornerPinSurface(width/2, height, 20);
p1= createGraphics(width/2, height, P3D);
p2= createGraphics(width/2, height, P3D);
ks.load();
//----- Video
video = new VideoFrames(this, "Burn.mov");
video.SetSpeed(videoSpeed); //frameRate(30);
//----- Input System
for (int i = 0; i < lines; i++)
{
lineStrings[i] = "";
}
lineStringsToSave[0] = "";
charactersToWin = currentCharactersToWin; //se igualan las variables clon para su posterior uso
//----- Design
font = createFont("TheQueen.ttf", 50);
logo = loadImage("Logo_TheLibrary.png");
logo.resize(350, 350);
}
void draw()
{
video.Update();
if (video.initialize)
{
video.Play();
image(video.getFrame(), 0, 1);
if (gameState == "Lose") video.SetSpeed(0);
if (gameState == "Reverse") video.SetSpeed(-1);
if (gameState == "Playing") video.SetSpeed(videoSpeed);
if (gameState == "Win") video.SetSpeed(0);
if (pressingKeys)
{
if (!firstPressedKey)
{
videoSpeed = 1;
firstPressedKey = true;
}
}
if (firstPressedKey && video.currentFrame < 2 && currentCharactersToWin < 0)
{
gameState = "Win";
println("Win");
}
if (pressKeys)
{
counter -= 1.0 / frameRate;
videoSpeed = -0.5;
if (counter<=0) pressKeys = false;
} else if (firstPressedKey)
{
videoSpeed = 1;
}
//----- Mapping
p1.beginDraw();
//background(232, 223, 176);
p1.blend(video.getFrame(), 0, 0, width/2, height, 0, 0, width/2, height, BLEND);
drawText();
p1.endDraw();
p2.beginDraw();
//background(232, 223, 176);
p2.blend(video.getFrame(), 0, 0, width/2, height, 0, 0, width/2, height, DARKEST);
drawText();
if (gameState == "Win") p2.image (logo, p2.width/2, p2.height- p2.height/6);
p2.endDraw();
//----- Save Texts
if (timeWithoutPressingKeys/frameRate >= 60)
{
if (!currentTextIsSaved)
{
SaveText();
currentTextIsSaved = true;
println("Text has been saved correctly");
}
}
//background(0); //(232, 223, 176)
surface1.render(p1);
surface2.render(p2);
}
}