Mercurial > hg > demos > krapula
comparison krapula.c @ 46:62d3cf935706
Fix to match API changes.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 27 Feb 2015 16:23:48 +0200 |
parents | c32b6fc0951b |
children | 25a12fb58c19 |
comparison
equal
deleted
inserted
replaced
45:ac7f374dfe00 | 46:62d3cf935706 |
---|---|
1 #include "dmengine.h" | 1 #include "dmengine.h" |
2 #include "dmvecmat.h" | 2 #include "dmvecmat.h" |
3 #include "dmperlin.h" | |
3 #include <math.h> | 4 #include <math.h> |
4 | 5 |
5 static int demoInit(); | 6 static int demoInit(); |
6 static void demoShutdown(); | 7 static void demoShutdown(); |
7 static void demoQuit(); | 8 static void demoQuit(); |
8 static int demoRender(); | 9 static int demoRender(); |
9 | 10 |
10 | 11 static DMPerlinContext perlinCtx; |
11 | 12 |
12 #define DM_COLORS (256) | 13 #define DM_COLORS (256) |
13 | 14 |
14 void dmMakePalette(SDL_Surface *scr) | 15 void dmMakePalette(SDL_Surface *scr) |
15 { | 16 { |
55 int x, y; | 56 int x, y; |
56 for (y = 0; y < QHEIGHT; y++) | 57 for (y = 0; y < QHEIGHT; y++) |
57 { | 58 { |
58 for (x = 0; x < QWIDTH; x++) | 59 for (x = 0; x < QWIDTH; x++) |
59 { | 60 { |
60 DMFloat f = 0.40f + dmPerlinNoise2D(x, y, 1.1f, q, 2); | 61 DMFloat f = 0.40f + dmPerlinNoise2D(&perlinCtx, x, y, 1.1f, q, 2); |
61 map[y][x] = (int) (dmClamp10(f) * m); | 62 map[y][x] = (int) (dmClamp10(f) * m); |
62 } | 63 } |
63 } | 64 } |
64 } | 65 } |
65 | 66 |
362 static int demoInit(DMEngineData *engine) | 363 static int demoInit(DMEngineData *engine) |
363 { | 364 { |
364 int i; | 365 int i; |
365 | 366 |
366 // Initialize effect stuff | 367 // Initialize effect stuff |
367 dmPerlinInit(); | 368 dmPerlinInit(&perlinCtx, 1234); |
368 | 369 |
369 for (i = 0; i < NOSFE_MAX; i++) | 370 for (i = 0; i < NOSFE_MAX; i++) |
370 { | 371 { |
371 char fname[32]; | 372 char fname[32]; |
372 snprintf(fname, sizeof(fname), "%08d.jpg", NOSFE_MIN + i); | 373 snprintf(fname, sizeof(fname), "%08d.jpg", NOSFE_MIN + i); |
383 JSSModule *mod = NULL; | 384 JSSModule *mod = NULL; |
384 engineGetResModule(engine, mod, "krapula.xm"); | 385 engineGetResModule(engine, mod, "krapula.xm"); |
385 | 386 |
386 if ((i = jssConvertModuleForPlaying(mod)) != DMERR_OK) | 387 if ((i = jssConvertModuleForPlaying(mod)) != DMERR_OK) |
387 { | 388 { |
388 dmError("Could not convert module for playing, %d: %s\n", | 389 dmErrorMsg("Could not convert module for playing, %d: %s\n", |
389 i, dmErrorStr(i)); | 390 i, dmErrorStr(i)); |
390 return DMERR_INIT_FAIL; | 391 return DMERR_INIT_FAIL; |
391 } | 392 } |
392 | 393 |
393 jvmSetCallback(engine->jssDev, jmpExec, engine->jssPlr); | 394 jvmSetCallback(engine->jssDev, jmpExec, engine->jssPlr); |