comparison examples/example-battle/main.c @ 230:86b71e1f9dd5

rpg: add movements in battle
author David Demelier <markand@malikania.fr>
date Mon, 23 Nov 2020 17:05:07 +0100
parents befa2e855d3b
children fb304a94a05c
comparison
equal deleted inserted replaced
229:e71039d820a7 230:86b71e1f9dd5
79 { 79 {
80 ch->hpmax = ch->hp = 126; 80 ch->hpmax = ch->hp = 126;
81 ch->mpmax = ch->mp = 38; 81 ch->mpmax = ch->mp = 38;
82 ch->atk = 22; 82 ch->atk = 22;
83 ch->def = 19; 83 ch->def = 19;
84 ch->agt = 21; 84 ch->agt = 11;
85 ch->luck = 14; 85 ch->luck = 14;
86 } 86 }
87 87
88 static struct character team[] = { 88 static struct character team[] = {
89 { 89 {
91 .type = "Adventurer", 91 .type = "Adventurer",
92 .level = 1, 92 .level = 1,
93 .hp = 120, 93 .hp = 120,
94 .mp = 50, 94 .mp = 50,
95 .reset = adventurer_reset, 95 .reset = adventurer_reset,
96 .sprite = &registry_sprites[REGISTRY_TEXTURE_JOHN], 96 .sprites = {
97 [CHARACTER_SPRITE_WALK] = &registry_sprites[REGISTRY_TEXTURE_JOHN_WALK],
98 [CHARACTER_SPRITE_SWORD] = &registry_sprites[REGISTRY_TEXTURE_JOHN_SWORD],
99 },
97 .spells = { 100 .spells = {
98 &spell_fire 101 &spell_fire
99 } 102 }
100 }, 103 },
101 {
102 .name = "Fake Molko",
103 .type = "Adventurer",
104 .level = 1,
105 .hp = 120,
106 .mp = 50,
107 .reset = adventurer_reset,
108 .sprite = &registry_sprites[REGISTRY_TEXTURE_JOHN],
109 .spells = {
110 &spell_fire
111 }
112 }
113 }; 104 };
114 105
115 static void 106 static void
116 haunted_wood_strat(struct character *ch, struct battle *bt) 107 haunted_wood_strat(struct character *ch, struct battle *bt)
117 { 108 {
133 static struct character haunted_wood = { 124 static struct character haunted_wood = {
134 .name = "Haunted Wood", 125 .name = "Haunted Wood",
135 .type = "Wood", 126 .type = "Wood",
136 .level = 30, 127 .level = 30,
137 .reset = haunted_wood_reset, 128 .reset = haunted_wood_reset,
138 .sprite = &registry_sprites[REGISTRY_TEXTURE_HAUNTED_WOOD], 129 .sprites = {
130 [CHARACTER_SPRITE_WALK] = &registry_sprites[REGISTRY_TEXTURE_HAUNTED_WOOD],
131 },
139 .exec = haunted_wood_strat 132 .exec = haunted_wood_strat
140 }; 133 };
141 134
142 static struct character black_cat = { 135 static struct character black_cat = {
143 .name = "Black Cat", 136 .name = "Black Cat",
144 .type = "Cat", 137 .type = "Cat",
145 .level = 6, 138 .level = 6,
146 .reset = black_cat_reset, 139 .reset = black_cat_reset,
147 .sprite = &registry_sprites[REGISTRY_TEXTURE_BLACK_CAT], 140 .sprites = {
141 [CHARACTER_SPRITE_WALK] = &registry_sprites[REGISTRY_TEXTURE_BLACK_CAT],
142 },
148 .exec = black_cat_strat 143 .exec = black_cat_strat
149 }; 144 };
150 145
151 static void 146 static void
152 init(void) 147 init(void)
169 { 164 {
170 struct battle *bt = alloc_new0(sizeof (*bt)); 165 struct battle *bt = alloc_new0(sizeof (*bt));
171 166
172 // bt->enemies[0].ch = &haunted_wood; 167 // bt->enemies[0].ch = &haunted_wood;
173 bt->team[0].ch = &team[0]; 168 bt->team[0].ch = &team[0];
174 bt->team[1].ch = &team[1]; 169 //bt->team[1].ch = &team[1];
175 170
176 /* Positionate the single ennemy to the left. */ 171 /* Positionate the single ennemy to the left. */
177 align(ALIGN_LEFT, 172 align(ALIGN_LEFT,
178 &bt->enemies[0].x, &bt->enemies[0].y, haunted_wood.sprite->cellw, haunted_wood.sprite->cellh, 173 &bt->enemies[0].x, &bt->enemies[0].y,
174 haunted_wood.sprites[0]->cellw,
175 haunted_wood.sprites[0]->cellh,
179 0, 0, window.w, window.h); 176 0, 0, window.w, window.h);
180 177
181 /* Black cat is near the previous monster. */ 178 /* Black cat is near the previous monster. */
182 bt->enemies[1].ch = &black_cat; 179 bt->enemies[1].ch = &black_cat;
183 bt->enemies[1].x = 500; 180 bt->enemies[1].x = 500;
184 bt->enemies[1].y = 100; 181 bt->enemies[1].y = 100;
182
183 bt->background = &registry_images[REGISTRY_IMAGE_BATTLE_BACKGROUND];
185 184
186 battle_start(bt); 185 battle_start(bt);
187 186
188 fight_state.data = bt; 187 fight_state.data = bt;
189 game_switch(&fight_state, false); 188 game_switch(&fight_state, false);