comparison demo.c @ 9:77b2bb97fa59

Some stuff.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 22 May 2015 03:12:08 +0300
parents dde02bd75871
children 952e27204992
comparison
equal deleted inserted replaced
8:0da5de9dcc75 9:77b2bb97fa59
213 } 213 }
214 } 214 }
215 } 215 }
216 216
217 217
218 static int my_toupper(int ch)
219 {
220 switch (ch)
221 {
222 case 0xe4: return 142;
223 case 0xf6: return 153;
224 default:
225 if (ch >= 'a' && ch <= 'z')
226 return ch - 'a' + 'A';
227 else
228 return ch;
229 }
230 }
231
232
233
218 static int demoRender(DMEngineData *engine) 234 static int demoRender(DMEngineData *engine)
219 { 235 {
220 float t = engineGetTimeDT(engine); 236 float t = engineGetTimeDT(engine);
221 237
222 // 238 //
430 dmQX(engine, maski, 1), 446 dmQX(engine, maski, 1),
431 dmQY(engine, maski, 1), 447 dmQY(engine, maski, 1),
432 engine->screen); 448 engine->screen);
433 } 449 }
434 450
451 // Skrolleri
452 if (t > 2)
453 {
454 int tt = engineGetTime(engine, 2);
455 static DMScaledBlitFunc cblit, qblit;
456 static BOOL nollattu = FALSE;
457 if (!nollattu)
458 {
459 cblit = dmGetScaledBlitFunc(font->glyphs[65]->format, engine->screen->format, DMD_TRANSPARENT);
460 qblit = dmGetScaledBlitFunc(font->glyphs[65]->format, engine->screen->format, DMD_SATURATE);
461 }
462
463 size_t txtLen = teksti->rawSize - 1;
464 Uint8 *txtData = teksti->rawData;
465 int fwidth = font->width * 2 + 2;
466 int xc, offs, scrollTime = tt / 10,
467 scrWidth = engine->screen->w / (dmQX(engine, font->glyphs[65], 1) + dmCX(engine, 0.001));
468
469 for (xc = offs = 0; offs < scrWidth; offs++)
470 {
471 int ch = txtData[((scrollTime / fwidth) + offs) % txtLen];
472 SDL_Surface *glyph = dmGetBMGlyph(font, my_toupper(ch));
473 if (glyph != NULL)
474 {
475 float mt = (offs * 20 + tt) / 100.0f;
476 int dx = xc - (scrollTime % fwidth),
477 dy = dmCY(engine, 0.8 + sin(mt) * 0.05),
478 dw = glyph->w * 2 * (1.0f + sin(mt) * 0.1f),
479 dh = glyph->h * 2 * (1.0f + cos(mt) * 0.2f);
480
481 cblit(glyph, dx+1, dy+1, dw+1, dh+1, engine->screen);
482 qblit(glyph, dx, dy, dw, dh, engine->screen);
483 }
484 xc += fwidth;
485 }
486 }
487
488 // Loppufeidi
435 if (t > 70) 489 if (t > 70)
490 {
491 static DMLerpContext fadeLerp;
492 static SDL_Surface *feidi = NULL;
493 static BOOL nollattu = FALSE;
494 if (!nollattu)
495 {
496 engineGetResImage(engine, feidi, "feidi.png");
497 dmLerpInit(&fadeLerp, 0, 255, 5000);
498 }
499
500 int fadeTime = engineGetTime(engine, 70);
501 dmScaledBlitSurface32to32TransparentGA(feidi,
502 0, 0, engine->screen->w, engine->screen->h, engine->screen,
503 dmLerpSCurveClamp(&fadeLerp, fadeTime));
504 }
505
506 if (t > 75)
436 return 1; 507 return 1;
437 else 508 else
438 return DMERR_OK; 509 return DMERR_OK;
439 } 510 }