Mercurial > hg > demos > bussi
changeset 3:37b33851cfbb
Joo.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 22 May 2015 01:39:04 +0300 |
parents | 496b9ab9238c |
children | 1b96b102f401 |
files | Makefile assets/graffat.svg demo.c |
diffstat | 3 files changed, 232 insertions(+), 96 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Thu May 21 23:30:51 2015 +0300 +++ b/Makefile Fri May 22 01:39:04 2015 +0300 @@ -12,12 +12,14 @@ mingw-win32: $(MAKE) -f $(DMLIB)Makefile.cross-mingw \ OBJPATH=./obj/win32/ \ + BINPATH=./bin/ \ MINGW_PREFIX=i686-w64-mingw32- \ MINGW_PATH=/usr/i686-w64-mingw32 mingw-win64: $(MAKE) -f $(DMLIB)Makefile.cross-mingw \ OBJPATH=./obj/win64/ \ + BINPATH=./bin/ \ MINGW_PREFIX=x86_64-w64-mingw32- \ MINGW_PATH=/usr/x86_64-w64-mingw32
--- a/assets/graffat.svg Thu May 21 23:30:51 2015 +0300 +++ b/assets/graffat.svg Fri May 22 01:39:04 2015 +0300 @@ -241,8 +241,8 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="0.7" - inkscape:cx="252.01978" - inkscape:cy="220.30674" + inkscape:cx="232.16163" + inkscape:cy="278.77908" inkscape:document-units="px" inkscape:current-layer="layer5" showgrid="false" @@ -261,7 +261,7 @@ <dc:format>image/svg+xml</dc:format> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - <dc:title></dc:title> + <dc:title /> </cc:Work> </rdf:RDF> </metadata> @@ -427,6 +427,59 @@ </g> </g> </g> + <text + xml:space="preserve" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:28.3125px;line-height:89.99999762%;font-family:Arial;-inkscape-font-specification:Arial;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;" + x="408.21429" + y="-122.85714" + id="text4275" + sodipodi:linespacing="89.999998%"><tspan + sodipodi:role="line" + id="tspan4277" + x="408.21429" + y="-122.85714" /></text> + <g + id="g4283" + inkscape:export-filename="/usr/src/prj/demos/bussi/data/viitta.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <g + id="g4270"> + <rect + style="opacity:1;fill:#4696ca;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:6.80000019;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:20;stroke-opacity:1" + id="rect4250" + width="224.28572" + height="61.42857" + x="387.14285" + y="-167.14285" + rx="0" + ry="0" /> + <path + style="display:inline;opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:3.12277818;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:20;stroke-opacity:1" + d="m 393.57214,-164.73146 189.20432,0 24.73218,29.37432 -24.37503,27.23147 -189.56147,0 c -2.2259,0 -4.01788,-1.79198 -4.01788,-4.01788 l 0,-48.57003 c 0,-2.2259 1.79198,-4.01788 4.01788,-4.01788 z" + id="rect4250-2" + inkscape:connector-curvature="0" + sodipodi:nodetypes="scccssss" /> + <path + style="opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:3.29999995;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:20;stroke-opacity:1" + d="m 576.90455,-108.21429 0,-56.42857 5.77959,0.33252 24.39744,28.23891 -23.66406,27.33575 z" + id="path4268" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccccc" /> + </g> + <text + transform="scale(0.93976837,1.064092)" + sodipodi:linespacing="89.999998%" + id="text4279" + y="-116.90852" + x="512.54913" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:32.9078064px;line-height:89.99999762%;font-family:Arial;-inkscape-font-specification:Arial;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + xml:space="preserve"><tspan + y="-116.90852" + x="512.54913" + id="tspan4281" + sodipodi:role="line">JOROINEN</tspan></text> + </g> </g> <g inkscape:label="bussi"
--- a/demo.c Thu May 21 23:30:51 2015 +0300 +++ b/demo.c Fri May 22 01:39:04 2015 +0300 @@ -98,51 +98,6 @@ } -typedef struct -{ - char *filename; - float xc, yc; - SDL_Surface *img; -} DMTextItem; - - -static DMTextItem textItems[] = -{ - { "text01.png", 0.05, 0.10, NULL }, - { "text02.png", 0.10, 0.30, NULL }, - { "text03.png", 0.60, 0.30, NULL }, - { "text04.png", 0.20, 0.60, NULL }, - { "text05.png", 0.30, 0.70, NULL }, -}; - -static const int ntextItems = sizeof(textItems) / sizeof(textItems[0]); - - -static DMTextItem textItems2[] = -{ - { "text11.png", 0.05, 0.10, NULL }, - { "text02.png", 0.30, 0.25, NULL }, - { "text12.png", 0.10, 0.40, NULL }, - { "text13.png", 0.20, 0.60, NULL }, - { "text14.png", 0.30, 0.70, NULL }, -}; - -static const int ntextItems2 = sizeof(textItems2) / sizeof(textItems2[0]); - - -static DMTextItem textItems3[] = -{ - { "teki.png" , 0.25, 0.20, NULL }, - { "mitvit.png" , 0.05, 0.40, NULL }, - { "ja.png" , 0.05, 0.65, NULL }, - { "kemisti.png", 0.15, 0.65, NULL }, -}; - -static const int ntextItems3 = sizeof(textItems3) / sizeof(textItems3[0]); - - - - #define DM_RADIAL_BLUR(YC, XC) \ DMVector p1 = { xc, yc, 0, 0 }, p2 = { cx, cy, 0, 0 }, v; \ dm_vector_sub_r(&v, &p2, &p1); \ @@ -210,48 +165,15 @@ } -static int hitlerText(DMEngineData *engine, const int dt, float fftPow, DMTextItem *items, const int nitems, BOOL *nollattu) -{ - int i, vis; - if (!(*nollattu)) - { - for (i = 0; i < nitems; i++) - engineGetResImage(engine, items[i].img, items[i].filename); - - *nollattu = TRUE; - } - - float q = fftPow * 0.05f; - vis = dt / 1000; - for (i = 0; i < nitems; i++) - { - DMTextItem *item = &items[i]; - if (i < vis) - { - dmScaledBlitSurface32to32TransparentGA( - item->img, - dmCX(engine, item->xc - q), - dmCY(engine, item->yc - q), - - dmQX(engine, item->img, 1.0f + q * 2.0f), - dmQY(engine, item->img, 1.0f + q * 2.0f), - - engine->screen, - - 100 + 80 * fftPow); - } - } - - return DMERR_OK; -} - static int demoRender(DMEngineData *engine) { float t = engineGetTimeDT(engine); - static DMScaledBlitFunc cblit = NULL; + + // // Do FFT + // DMFFTType fftPow = 0; BOOL fftOK = FALSE; static DMFFTType fftAmp[FFT_SIZE / 2]; @@ -277,29 +199,188 @@ dmConvertFFTtoPowerAndSum(&fft, fftData, fftAmp, 1.0, &fftPow, 0.00004f); } - // Demokoodi - if (t < 5) + + // + // Taustaskrolli + // { - // Alkufeidi sisään - int dt = engineGetTime(engine, 0); + static SDL_Surface *tausta = NULL, + *aurinko = NULL, + *puu1 = NULL, + *puu2 = NULL, + *bussi = NULL, + *rengas = NULL; + + static DMScaledBlitFunc cblit = NULL, ablit = NULL; + static BOOL nollattu = FALSE; + static DMLerpContext fadeLerp, fadeLerp2, fadeLerp3; + + if (!nollattu) + { + dmLerpInit(&fadeLerp, 0, 255, 3000); + dmLerpInit(&fadeLerp2, 0, 255, 4000); + dmLerpInit(&fadeLerp3, 0, 1.2, 3000); + engineGetResImage(engine, tausta, "tausta_pv.png"); + engineGetResImage(engine, aurinko, "aurinko.png"); + engineGetResImage(engine, puu1, "puu_pv_1.png"); + engineGetResImage(engine, puu2, "puu_pv_2.png"); + engineGetResImage(engine, bussi, "auto.png"); + engineGetResImage(engine, rengas, "rengas.png"); + cblit = dmGetScaledBlitFunc(tausta->format, engine->screen->format, DMD_NONE); + ablit = dmGetScaledBlitFunc(bussi->format, engine->screen->format, DMD_TRANSPARENT); + } + + int x1 = - ((int)dmQX(engine, tausta, t * 0.2) % tausta->w), + x2 = x1 + tausta->w; + + int fadeVal; + if (t < 3 || t > 64) + { + if (t < 3) + fadeVal = dmLerpSCurveClamp(&fadeLerp, engineGetTime(engine, 0)); + else + fadeVal = dmLerpSCurveClamp(&fadeLerp2, engineGetTime(engine, 64)); + + dmClearSurface(engine->screen, dmMapRGB(engine->screen, 0,0,0)); + dmScaledBlitSurface32to32TransparentGA(tausta, x1, 0, tausta->w, tausta->h, engine->screen, fadeVal); + dmScaledBlitSurface32to32TransparentGA(tausta, x2, 0, tausta->w, tausta->h, engine->screen, fadeVal); + } + else + { + fadeVal = 255; + cblit(tausta, x1, 0, tausta->w, tausta->h, engine->screen); + cblit(tausta, x2, 0, tausta->w, tausta->h, engine->screen); + } + + float qm = sin(t * 0.1 + fftPow * 5) * 15, qm2 = qm*2; + dmScaledBlitSurface32to32TransparentGA(aurinko, + dmCX(engine, 0.8 - dmLerpSCurveClamp(&fadeLerp3, engineGetTime(engine, 0) * 0.01) * 0.3 ) - qm, + dmCY(engine, 0.05) - qm, + aurinko->w + qm2, aurinko->h + qm2, + engine->screen, fadeVal); + + + // Bussi ajaa sisään + if (t > 4) + { + float + dt = engineGetTime(engine, 4), + ajelu = dmLerpSCurveClamp(&fadeLerp3, dt), + xc = dmCX(engine, -1 + ajelu), + yc = dmCY(engine, 0.35 + sin(t * 10) * 0.005), + yc2 = yc + dmQY(engine, bussi, 0.7) + dmCY(engine, sin(t * 20) * 0.001); + + ablit(rengas, xc + dmQX(engine, bussi, 0.07), yc2, dmQX(engine, rengas, 1), dmQY(engine, rengas, 1), engine->screen); + ablit(rengas, xc + dmQX(engine, bussi, 0.80), yc2, dmQX(engine, rengas, 1), dmQY(engine, rengas, 1), engine->screen); + ablit(bussi, xc, yc, dmQX(engine, bussi, 1), dmQY(engine, bussi, 1), engine->screen); + } + } + + // + // AP logo + // + if (t > 4 && t < 8) + { + int dt = engineGetTime(engine, 4); static DMLerpContext fadeLerp; - static SDL_Surface *tausta = NULL; + static SDL_Surface *logo = NULL; static BOOL nollattu = FALSE; if (!nollattu) { - engineGetResImage(engine, tausta, "tausta_pv.png"); - cblit = dmGetScaledBlitFunc(tausta->format, engine->screen->format, DMD_NONE); + dmLerpInit(&fadeLerp, 0, 255, 1000); + engineGetResImage(engine, logo, "ap.png"); + nollattu = TRUE; + } + + int fadeVal; + if (dt < 1000) + fadeVal = dmLerpSCurveClamp(&fadeLerp, dt); + else + if (dt > 3000) + fadeVal = 255 - dmLerpSCurveClamp(&fadeLerp, dt - 3000); + else + fadeVal = 255; - dmLerpInit(&fadeLerp, 0, 255, 5000); + dmScaledBlitSurface32to32TransparentGA(logo, + dmQX(engine, logo, 0.2), + dmQY(engine, logo, 0.3), + dmQX(engine, logo, 1), + dmQY(engine, logo, 1), + engine->screen, fadeVal); + } + + // + // BUSSI logo + // + if (t > 10 && t < 14) + { + int dt = engineGetTime(engine, 10); + static DMLerpContext fadeLerp; + static SDL_Surface *logo = NULL, *logo2 = NULL; + static BOOL nollattu = FALSE; + if (!nollattu) + { + dmLerpInit(&fadeLerp, 0, 255, 1000); + engineGetResImage(engine, logo, "bussi_logo.png"); + engineGetResImage(engine, logo2, "dosa.png"); nollattu = TRUE; } - dmClearSurface(engine->screen, dmMapRGB(engine->screen, 0,0,0)); + int fadeVal, fadeVal2; + if (dt < 1000) + fadeVal = dmLerpSCurveClamp(&fadeLerp, dt); + else + if (dt > 3000) + fadeVal = 255 - dmLerpSCurveClamp(&fadeLerp, dt - 3000); + else + fadeVal = 255; + + if (dt > 1000) + { + if (dt < 2000) + fadeVal2 = dmLerpSCurveClamp(&fadeLerp, dt - 1000); + else + if (dt > 3000) + fadeVal2 = 255 - dmLerpSCurveClamp(&fadeLerp, dt - 3000); + else + fadeVal2 = 255; + } + else + fadeVal2 = 0; - dmScaledBlitSurface32to32TransparentGA(tausta, - 0, - 0, + dmScaledBlitSurface32to32TransparentGA(logo, + dmCX(engine, 0.10), + dmCY(engine, 0.2), + dmQX(engine, logo, 1), + dmQY(engine, logo, 1), + engine->screen, fadeVal); + + dmScaledBlitSurface32to32TransparentGA(logo2, + dmCX(engine, 0.6), + dmCY(engine, 0.6), + dmQX(engine, logo2, 1), + dmQY(engine, logo2, 1), + engine->screen, fadeVal2); + } + + { + static DMScaledBlitFunc cblit = NULL; + static SDL_Surface *maski = NULL; + static BOOL nollattu = FALSE; + + if (!nollattu) + { + engineGetResImage(engine, maski, "maze.png"); + cblit = dmGetScaledBlitFunc(maski->format, engine->screen->format, DMD_TRANSPARENT); + } + + cblit(maski, + 0, 0, + dmQX(engine, maski, 1), + dmQY(engine, maski, 1), + engine->screen); + } return DMERR_OK; }