comparison libmlk-rpg/mlk/rpg/tileset-file.c @ 516:6af0524913b3

misc: fix
author David Demelier <markand@malikania.fr>
date Sat, 04 Mar 2023 11:23:10 +0100
parents daf085bf8a8c
children c2124ecb2423
comparison
equal deleted inserted replaced
515:2e05c1804b25 516:6af0524913b3
193 anim = mlk_alloc_pool_new(&ctx->tf->anims[0]); 193 anim = mlk_alloc_pool_new(&ctx->tf->anims[0]);
194 194
195 if (mlk_image_open(&anim->texture, mlk_util_pathf("%s/%s", ctx->basedir, filename)) < 0) 195 if (mlk_image_open(&anim->texture, mlk_util_pathf("%s/%s", ctx->basedir, filename)) < 0)
196 return -1; 196 return -1;
197 197
198 mlk_sprite_init(&anim->sprite, &anim->texture, ctx->tilewidth, ctx->tileheight); 198 anim->sprite.texture = &anim->texture;
199 anim->sprite.cellw = ctx->tilewidth;
200 anim->sprite.cellh = ctx->tileheight;
199 201
200 anim->animation.sprite = &anim->sprite; 202 anim->animation.sprite = &anim->sprite;
201 anim->animation.delay = delay; 203 anim->animation.delay = delay;
204
205 mlk_sprite_init(&anim->sprite);
202 } 206 }
203 207
204 /* 208 /*
205 * 2. Create the second array that only consist of pointers to 209 * 2. Create the second array that only consist of pointers to
206 * animations referencing the first array. 210 * animations referencing the first array.
238 if (!(p = strchr(line, '|'))) 242 if (!(p = strchr(line, '|')))
239 return MLK_ERR_FORMAT; 243 return MLK_ERR_FORMAT;
240 if ((err = mlk_image_open(&ctx->tf->image, mlk_util_pathf("%s/%s", ctx->basedir, p + 1))) < 0) 244 if ((err = mlk_image_open(&ctx->tf->image, mlk_util_pathf("%s/%s", ctx->basedir, p + 1))) < 0)
241 return err; 245 return err;
242 246
243 mlk_sprite_init(&ctx->tf->sprite, &ctx->tf->image, ctx->tilewidth, ctx->tileheight); 247 ctx->tf->sprite.texture = &ctx->tf->image;
248 ctx->tf->sprite.cellw = ctx->tilewidth;
249 ctx->tf->sprite.cellh = ctx->tileheight;
250 mlk_sprite_init(&ctx->tf->sprite);
251
244 ctx->tileset->sprite = &ctx->tf->sprite; 252 ctx->tileset->sprite = &ctx->tf->sprite;
245 253
246 return 0; 254 return 0;
247 } 255 }
248 256