Skip to content

Commit 1318836

Browse files
committed
Changed animation speed, refactored code
1 parent 781c47a commit 1318836

File tree

3 files changed

+70
-35
lines changed

3 files changed

+70
-35
lines changed

console.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,13 @@ void printcmdstr(const char* fmt, ...)
325325
int agetchar(const char *allowed)
326326
{
327327
char input = 0;
328+
int y = getcury(MAINWINDOW);
329+
int x = getcurx(MAINWINDOW);
328330

329331
wattron(MAINWINDOW, ATTR_BOLD);
330332
do
331333
{
334+
wmove(MAINWINDOW, y, x);
332335

333336
if (ascanf(MAINWINDOW, 0, 1, allowed, "%c", &input) == L_ESC)
334337
input = L_ESC;

intro.cpp

Lines changed: 61 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -93,63 +93,58 @@ const char* digits[BLOCK_ROW_COUNT] = {
9393

9494
#define DIGITS_WIDTH 22
9595

96-
void RunIntro()
96+
void LowerSpider(int spiderx)
9797
{
98-
int dropindex, flowindex, spiderindex;
99-
int screenbottomy, screenrightx;
100-
int spiderx, spiderbottomy, spiderrightx;
101-
bool screenwidthisodd;
102-
103-
getfssize(screenbottomy, screenrightx);
104-
screenrightx--;
105-
106-
clrfs(COLORS_INVERSE);
107-
108-
screenwidthisodd = (screenrightx % 2 == 1);
109-
spiderx = (screenrightx - SPIDER_WIDTH) / 2;
98+
int spiderbottomy, spiderrightx, dropindex, spiderswitch;
11099

111100
spiderbottomy = BLOCK_ROW_COUNT - 1;
112101
spiderrightx = SPIDER_WIDTH - 1;
113102

103+
// Introduce the spider from the top of the screen
114104
for (dropindex = BLOCK_ROW_COUNT; dropindex > 0; dropindex--)
115105
{
116-
for (spiderindex = 0; spiderindex < 2; spiderindex++)
106+
for (spiderswitch = 0; spiderswitch < 2; spiderswitch++)
117107
{
118-
printfsblocksectionat(0, spiderx, COLORS_INVERSE, spider[spiderindex], dropindex - 1, 0, spiderbottomy, spiderrightx);
108+
printfsblocksectionat(0, spiderx, COLORS_INVERSE, spider[spiderswitch], dropindex - 1, 0, spiderbottomy, spiderrightx);
119109

120110
updatefs();
121111
mssleep(50);
122112
}
123113
}
124114

115+
// Lower it to its final place, leaving a silk thread
125116
for (dropindex = 0; dropindex < SPIDER_DROPHEIGHT; dropindex++)
126117
{
127118
printfsat(dropindex, spiderx, COLORS_INVERSE, linesection);
128119

129-
for (spiderindex = 0; spiderindex < 2; spiderindex++)
120+
for (spiderswitch = 0; spiderswitch < 2; spiderswitch++)
130121
{
131-
printfsblockat(dropindex + 1, spiderx, COLORS_INVERSE, spider[spiderindex], BLOCK_ROW_COUNT);
122+
printfsblockat(dropindex + 1, spiderx, COLORS_INVERSE, spider[spiderswitch], BLOCK_ROW_COUNT);
132123

133124
updatefs();
134125
mssleep(50);
135126
}
136127
}
128+
}
137129

130+
void SwoopInLetters(int screenrightx, int screenmiddlex, int leftletterfinalx)
131+
{
132+
int flowindex, rightletterfirstx;
138133
int letterbottomy = BLOCK_ROW_COUNT - 1;
139134
int letterrightx = LETTER_WIDTH - 1;
140135

136+
// Introduce letters from either side of the screen
141137
for (flowindex = 0; flowindex < LETTER_WIDTH; flowindex++)
142138
{
143139
printfsblocksectionat(2, 0, COLORS_INVERSE, letters[LETTER_R], 0, letterrightx - flowindex, letterbottomy, letterrightx);
144140
printfsblocksectionat(2, screenrightx - flowindex, COLORS_INVERSE, letters[LETTER_P], 0, 0, letterbottomy, flowindex);
145141

146142
updatefs();
147-
mssleep(10);
148143
}
149144

150-
int leftletterfinalx = screenrightx / 2 - LETTER_WIDTH - LETTER_SPACEWIDTH;
151-
int rightletterfirstx = screenrightx - LETTER_WIDTH;
145+
rightletterfirstx = screenrightx - LETTER_WIDTH;
152146

147+
// Bring the letters to the center
153148
for (flowindex = 0; flowindex < leftletterfinalx; flowindex++)
154149
{
155150
printfsblockat(2, flowindex, COLORS_INVERSE, verticalspace, BLOCK_ROW_COUNT);
@@ -159,31 +154,33 @@ void RunIntro()
159154
printfsblockat(2, screenrightx - flowindex, COLORS_INVERSE, verticalspace, BLOCK_ROW_COUNT);
160155

161156
updatefs();
162-
mssleep(10);
163157
}
164158

165-
if (!screenwidthisodd)
159+
// If the silk thread is just left of center due to screen width, bump the P one more place to the left
160+
if ((screenrightx % 2) == 0)
166161
{
167162
printfsblockat(2, rightletterfirstx - flowindex, COLORS_INVERSE, letters[LETTER_P], BLOCK_ROW_COUNT);
168163
printfsblockat(2, screenrightx - flowindex, COLORS_INVERSE, verticalspace, BLOCK_ROW_COUNT);
169164

170165
updatefs();
171-
mssleep(10);
172166
}
173167

174-
int screenmiddlex = screenrightx / 2;
175-
if (!screenwidthisodd)
176-
screenmiddlex--;
168+
// Cut the silk thread to create the letter I
177169
printfsat(1, screenmiddlex, COLORS_INVERSE, u8"");
178170
printfsat(1 + BLOCK_ROW_COUNT, screenmiddlex, COLORS_INVERSE, u8"");
179171

180172
updatefs();
181-
mssleep(2000);
173+
}
174+
175+
void SwoopInDigits(int screenbottomy, int screenrightx, int screenmiddlex, int spiderx, int leftletterfinalx)
176+
{
177+
int flowindex, digitsfinalx, digitsbottomy;
182178

183179
int letterstopy = (screenbottomy - BLOCK_ROW_COUNT) / 2;
184180
if (letterstopy < 2)
185181
letterstopy = 2;
186182

183+
// clear everything except for the R
187184
printfsat(0, screenmiddlex, COLORS_INVERSE, u8" ");
188185
printfsat(1, screenmiddlex, COLORS_INVERSE, u8" ");
189186
for (int i = 2; i < 2 + BLOCK_ROW_COUNT; i++)
@@ -201,41 +198,70 @@ void RunIntro()
201198
printfsat(i, spiderx, COLORS_INVERSE, clearspiderspaces);
202199
}
203200

201+
// Lower the R to the vertical middle of the screen
204202
for (int i = 2; i < letterstopy; i++)
205203
{
206204
printfsblockat(i, leftletterfinalx, COLORS_INVERSE, letters[LETTER_R_LOW], BLOCK_ROW_COUNT);
207205

208206
updatefs();
209-
mssleep(10);
207+
mssleep(5);
210208

211209
printfsat(i, leftletterfinalx, COLORS_INVERSE, clearleftletterspaces);
212210
printfsblockat(i + 1, leftletterfinalx, COLORS_INVERSE, letters[LETTER_R], BLOCK_ROW_COUNT);
213-
211+
214212
updatefs();
215-
mssleep(10);
213+
mssleep(5);
216214
}
217215

218-
int digitsfinalx = leftletterfinalx + LETTER_WIDTH + 3;
219-
int digitsbottomy = BLOCK_ROW_COUNT - 1;
216+
digitsfinalx = leftletterfinalx + LETTER_WIDTH + 3;
217+
digitsbottomy = BLOCK_ROW_COUNT - 1;
220218

219+
// Bring the letters to the center
221220
for (flowindex = 0; flowindex < DIGITS_WIDTH; flowindex++)
222221
{
223222
printfsblocksectionat(letterstopy, screenrightx - flowindex, COLORS_INVERSERED, digits, 0, 0, digitsbottomy, flowindex);
224223

225224
updatefs();
226-
mssleep(10);
227225
}
228226

227+
// Introduce the digits from the right-hand side of the screen
229228
for (flowindex = screenrightx - DIGITS_WIDTH; flowindex >= digitsfinalx; flowindex--)
230229
{
231230
printfsblockat(letterstopy, flowindex, COLORS_INVERSERED, digits, BLOCK_ROW_COUNT);
232231
printfsblockat(letterstopy, flowindex + DIGITS_WIDTH, COLORS_INVERSERED, verticalspace, BLOCK_ROW_COUNT);
233232

234233
updatefs();
235-
mssleep(10);
236234
}
235+
}
236+
237+
void RunIntro()
238+
{
239+
int screenbottomy, screenrightx, screenmiddlex;
240+
int spiderx, leftletterfinalx;
241+
242+
getfssize(screenbottomy, screenrightx);
243+
screenrightx--;
244+
245+
clrfs(COLORS_INVERSE);
246+
247+
spiderx = (screenrightx - SPIDER_WIDTH) / 2;
248+
249+
LowerSpider(spiderx);
250+
251+
leftletterfinalx = screenrightx / 2 - LETTER_WIDTH - LETTER_SPACEWIDTH;
252+
253+
screenmiddlex = screenrightx / 2;
254+
if ((screenrightx % 2) == 0)
255+
screenmiddlex--;
256+
257+
SwoopInLetters(screenrightx, screenmiddlex, leftletterfinalx);
258+
259+
mssleep(2000);
260+
261+
SwoopInDigits(screenbottomy, screenrightx, screenmiddlex, spiderx, leftletterfinalx);
237262

238263
mssleep(2500);
239264

240265
clrfs(COLORS_NORMAL);
241-
}
266+
}
267+

r136.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,12 @@ int strinp (WINDOW *win, const char *allowed, char *input, int inpx, int inpy, i
291291

292292
void RunIntro();
293293

294+
void SwoopInDigits(int screenbottomy, int screenmiddlex, int spiderx, int leftletterfinalx, int screenrightx);
295+
296+
void SwoopInLetters(int& flowindex, int screenrightx, int leftletterfinalx, bool screenwidthisodd);
297+
298+
void LowerSpider(int& spiderbottomy, int& spiderrightx, int& dropindex, int& spiderswitch, int spiderx);
299+
294300
void SaveStatus(Progdata &progdata);
295301
bool LoadStatus(Progdata &progdata);
296302

0 commit comments

Comments
 (0)