Mirai's Miscellaneous Misadventures
M50 / 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 chapter = data;
14 mimimi_history_tick(&chapter->history, left, right);
15 mimimi_controls_tick(&chapter->stage.sprites[0].walk, &chapter->history, &mimimi_jump, chapter->stage.sprites);
16 mimimi_stage_tick(&chapter->stage, chapter->engine);
17}
18
19static void mimimi_test_background(struct mimimi_test *chapter)
20{
21 static unsigned char colors[] = {0x0D, 0x05, 0x05};
22
23 struct mimimi_area *area;
24
25 area = chapter->stage.areas;
26 area->background_count = 1;
27 area->backgrounds = malloc(sizeof *area->backgrounds);
28 if (area->backgrounds == NULL) exit(1);
29 area->backgrounds[0].x = 0;
30 area->backgrounds[0].y = 0;
31 area->backgrounds[0].z = 0;
32 area->backgrounds[0].texture = mimimi_background(chapter->engine, area->ground, colors);
33}
34
35void *mimimi_test(struct mimimi_engine *engine)
36{
37 static struct mimimi_ground *grounds[] = {&mimimi_test_ground};
38 static struct mimimi_display mango_display, pepper_display;
39 struct mimimi_test *chapter;
40 mimimi_display(&mango_display, mimimi_mango, engine);
41 mimimi_display(&pepper_display, mimimi_pepper, engine);
42 chapter = malloc(sizeof *chapter);
43 if (chapter == NULL) exit(1);
44 chapter->engine = engine;
45 mimimi_stage(&chapter->stage, grounds, 1);
46 mimimi_test_background(chapter);
47 mimimi_spawn(&chapter->stage, &mango_display, 0, 0, 80, 250);
48 mimimi_spawn(&chapter->stage, &pepper_display, -256, 0, 80, 250);
49 chapter->history.left = 0;
50 chapter->history.right = 0;
51 return chapter;
52}