- Treballant, canvi de comp, ara peta

This commit is contained in:
2023-09-26 19:32:12 +02:00
parent 742bf54d61
commit e6cd1233e2
4 changed files with 137 additions and 27 deletions

View File

@@ -24,14 +24,14 @@ namespace actor
return selected;
}
actor_t *create(const char *name, vec3_t p, vec3_t s, const char *bmp, SDL_Rect r, SDL_Point o)
actor_t *create(std::string name, vec3_t p, vec3_t s, std::string bmp, SDL_Rect r, SDL_Point o)
{
actor_t *act = (actor_t*)malloc(sizeof(actor_t));
strcpy(act->name, name);
strcpy(act->bmp, bmp);
act->name = std::string(name);
act->bmp = std::string(bmp);
act->pos = p;
act->size = s;
act->surface = draw::loadSurface(bmp);
act->surface = draw::loadSurface(bmp.c_str());
act->bmp_rect = r;
act->bmp_offset = o;
act->anim_cycle = act->orient = 0;
@@ -609,12 +609,12 @@ namespace actor
if (draw_all && act->next) draw(act->next);
}
actor_t *find(const char *name)
actor_t *find(std::string name)
{
actor_t *act = first;
while (act)
{
if (SDL_strcmp(name, act->name)==0)
if (name == act->name)
{
return act;
}
@@ -624,7 +624,7 @@ namespace actor
act = dirty;
while (act)
{
if (SDL_strcmp(name, act->name)==0)
if (name == act->name)
{
return act;
}
@@ -687,6 +687,16 @@ namespace actor
(obj1->pos.z + obj1->size.z > obj2->pos.z );
}
void remove(actor_t *act)
{
if (!act) return;
if (act->prev) act->prev->next = act->next;
if (act==first) first = act->next;
if (act==dirty) dirty = act->next;
if (act->next) act->next->prev = act->prev;
free(act);
}
void clear()
{
actor_t *hero = nullptr;
@@ -721,4 +731,5 @@ namespace actor
}
}
}