- Carrega de l'habitació des de arxiu

- Traslladem a jutil funcionetes varies
- Comencem a implementar carrega de actors des de arxiu
- Comencem a implementar els templates de actors
This commit is contained in:
2024-06-05 14:23:16 +02:00
parent e2bae91000
commit 9dc27d7e8b
9 changed files with 285 additions and 41 deletions

View File

@@ -1,6 +1,8 @@
#include "actor.h"
#include "jdraw.h"
#include "jinput.h"
#include "jfile.h"
#include "jutil.h"
#include "room.h"
#include <vector>
@@ -45,6 +47,28 @@ namespace actor
return act;
}
void createFromFile(char **buffer)
{
actor_t *act = (actor_t*)malloc(sizeof(actor_t));
if (*buffer)
{
while (**buffer != 0)
{
const char* key = file::readString(buffer);
if (util::strcomp(key, "pos:")) {
act->pos.x = file::readInt(buffer);
act->pos.y = file::readInt(buffer);
act->pos.z = file::readInt(buffer);
} else if (util::strcomp(key, "height:")) {
const int val = file::readInt(buffer);
inner_h = SDL_clamp(val, 0, 3);
}
}
}
setDirty(act, true);
}
const bool check_2d_collision(actor_t *obj1, actor_t *obj2)
{
return (obj1->pos.x < obj2->pos.x + obj2->size.x) &&