Mercurial > hg > demos > bussi
diff 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 |
line wrap: on
line diff
--- a/demo.c Fri May 22 02:27:17 2015 +0300 +++ b/demo.c Fri May 22 03:12:08 2015 +0300 @@ -215,6 +215,22 @@ } +static int my_toupper(int ch) +{ + switch (ch) + { + case 0xe4: return 142; + case 0xf6: return 153; + default: + if (ch >= 'a' && ch <= 'z') + return ch - 'a' + 'A'; + else + return ch; + } +} + + + static int demoRender(DMEngineData *engine) { float t = engineGetTimeDT(engine); @@ -432,7 +448,62 @@ engine->screen); } + // Skrolleri + if (t > 2) + { + int tt = engineGetTime(engine, 2); + static DMScaledBlitFunc cblit, qblit; + static BOOL nollattu = FALSE; + if (!nollattu) + { + cblit = dmGetScaledBlitFunc(font->glyphs[65]->format, engine->screen->format, DMD_TRANSPARENT); + qblit = dmGetScaledBlitFunc(font->glyphs[65]->format, engine->screen->format, DMD_SATURATE); + } + + size_t txtLen = teksti->rawSize - 1; + Uint8 *txtData = teksti->rawData; + int fwidth = font->width * 2 + 2; + int xc, offs, scrollTime = tt / 10, + scrWidth = engine->screen->w / (dmQX(engine, font->glyphs[65], 1) + dmCX(engine, 0.001)); + + for (xc = offs = 0; offs < scrWidth; offs++) + { + int ch = txtData[((scrollTime / fwidth) + offs) % txtLen]; + SDL_Surface *glyph = dmGetBMGlyph(font, my_toupper(ch)); + if (glyph != NULL) + { + float mt = (offs * 20 + tt) / 100.0f; + int dx = xc - (scrollTime % fwidth), + dy = dmCY(engine, 0.8 + sin(mt) * 0.05), + dw = glyph->w * 2 * (1.0f + sin(mt) * 0.1f), + dh = glyph->h * 2 * (1.0f + cos(mt) * 0.2f); + + cblit(glyph, dx+1, dy+1, dw+1, dh+1, engine->screen); + qblit(glyph, dx, dy, dw, dh, engine->screen); + } + xc += fwidth; + } + } + + // Loppufeidi if (t > 70) + { + static DMLerpContext fadeLerp; + static SDL_Surface *feidi = NULL; + static BOOL nollattu = FALSE; + if (!nollattu) + { + engineGetResImage(engine, feidi, "feidi.png"); + dmLerpInit(&fadeLerp, 0, 255, 5000); + } + + int fadeTime = engineGetTime(engine, 70); + dmScaledBlitSurface32to32TransparentGA(feidi, + 0, 0, engine->screen->w, engine->screen->h, engine->screen, + dmLerpSCurveClamp(&fadeLerp, fadeTime)); + } + + if (t > 75) return 1; else return DMERR_OK;