- actor::find() per nom
- [new] actor seleccionat - actor seleccionat es pinta de diferent color
This commit is contained in:
@@ -12,12 +12,18 @@ namespace actor
|
||||
|
||||
actor_t *first = nullptr;
|
||||
actor_t *dirty = nullptr;
|
||||
actor_t *selected = nullptr;
|
||||
|
||||
actor_t *getFirst()
|
||||
{
|
||||
return first;
|
||||
}
|
||||
|
||||
actor_t *getSelected()
|
||||
{
|
||||
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 *act = (actor_t*)malloc(sizeof(actor_t));
|
||||
@@ -102,6 +108,10 @@ namespace actor
|
||||
|
||||
}
|
||||
|
||||
void select(actor_t *act) {
|
||||
selected = act;
|
||||
}
|
||||
|
||||
const bool isInFront(actor_t *act1, actor_t *act2) {
|
||||
|
||||
if (act1->pos.x >= act2->pos.x+act2->size.x) { return true; }
|
||||
@@ -585,7 +595,9 @@ namespace actor
|
||||
|
||||
draw::pushSource();
|
||||
draw::setSource(act->surface);
|
||||
if (act==selected) draw::swapcol(1, room::getColor()==9?11:9); // Si està seleccionat, que canvie de color
|
||||
draw::draw(x, y, act->bmp_rect.w, act->bmp_rect.h, act->bmp_rect.x+ao, act->bmp_rect.y+oo, flip);
|
||||
draw::swapcol(1, room::getColor()); // Tornem al color per defecte
|
||||
draw::popSource();
|
||||
//print(x+5,y,act->pos.x);
|
||||
//print(x+5,y+6,act->pos.y);
|
||||
@@ -596,6 +608,30 @@ namespace actor
|
||||
if (draw_all && act->next) draw(act->next);
|
||||
}
|
||||
|
||||
actor_t *find(const char *name)
|
||||
{
|
||||
actor_t *act = first;
|
||||
while (act)
|
||||
{
|
||||
if (SDL_strcmp(name, act->name)==0)
|
||||
{
|
||||
return act;
|
||||
}
|
||||
act = act->next;
|
||||
}
|
||||
|
||||
act = dirty;
|
||||
while (act)
|
||||
{
|
||||
if (SDL_strcmp(name, act->name)==0)
|
||||
{
|
||||
return act;
|
||||
}
|
||||
act = act->next;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
actor_t *find_at(const int x, const int y, const int z)
|
||||
{
|
||||
actor_t *act = first;
|
||||
|
||||
@@ -66,16 +66,22 @@ namespace actor
|
||||
|
||||
actor_t *getFirst();
|
||||
|
||||
actor_t *getSelected();
|
||||
|
||||
actor_t *create(const char *name, vec3_t p, vec3_t s, const char *bmp, SDL_Rect r, SDL_Point o);
|
||||
|
||||
void setDirty(actor_t *act, const bool force=false);
|
||||
|
||||
void select(actor_t *act);
|
||||
|
||||
void reorder();
|
||||
|
||||
void update(actor_t *act, const bool update_all=true);
|
||||
|
||||
void draw(actor_t *act, const bool draw_all=true);
|
||||
|
||||
actor_t *find(const char *name);
|
||||
|
||||
actor_t *find_at(const int x, const int y, const int z);
|
||||
|
||||
actor_t *get_collision(actor_t *act);
|
||||
|
||||
Reference in New Issue
Block a user