Mirai's Miscellaneous Misadventures
M51 / chapters / test / setup.c
1
2
3
4#include <stdlib.h>
5
6#include <mimimi-chapters.h>
7
8#include "ground.c"
9
10void mimimi_test_tick(void *data, unsigned char left, unsigned char right)
11{
12 struct mimimi_test *chapter;
13
14 chapter = data;
15 chapter->engine->size.width = 512;
16 chapter->engine->size.height = 256;
17
18 mimimi_history_tick(&chapter->history, left, right);
19 mimimi_controls_tick(&chapter->stage.sprites[0].walk, &chapter->history, &mimimi_jump, chapter->stage.sprites);
20 mimimi_stage_tick(&chapter->stage, chapter->engine);
21}
22
23static void mimimi_test_background(struct mimimi_test *chapter)
24{
25 static unsigned char colors[] = {0x0D, 0x05, 0x05};
26
27 struct mimimi_area *area;
28
29 area = chapter->stage.areas;
30 area->background_count = 1;
31 area->backgrounds = malloc(sizeof *area->backgrounds);
32 if (area->backgrounds == NULL) exit(1);
33 area->backgrounds[0].x = 0;
34 area->backgrounds[0].y = 0;
35 area->backgrounds[0].z = 0;
36 area->backgrounds[0].texture = mimimi_background(chapter->engine, area->ground, colors);
37}
38
39void *mimimi_test(struct mimimi_engine *engine)
40{
41 static struct mimimi_ground *grounds[] = {&mimimi_test_ground};
42 static struct mimimi_display mango_display, pepper_display;
43 struct mimimi_test *chapter;
44
45 engine->size.width = 256;
46 engine->size.height = 128;
47
48 mimimi_display(&mango_display, mimimi_mango, engine);
49 mimimi_display(&pepper_display, mimimi_pepper, engine);
50 chapter = malloc(sizeof *chapter);
51 if (chapter == NULL) exit(1);
52 chapter->engine = engine;
53 mimimi_stage(&chapter->stage, grounds, 1);
54 mimimi_test_background(chapter);
55 mimimi_spawn(&chapter->stage, &mango_display, 0, 0, 80, 250);
56 mimimi_spawn(&chapter->stage, &pepper_display, -256, 0, 80, 250);
57 chapter->history.left = 0;
58 chapter->history.right = 0;
59 return chapter;
60}