- El actors tenen la seua propia surface
This commit is contained in:
@@ -19,12 +19,13 @@ namespace actor
|
||||
return first;
|
||||
}
|
||||
|
||||
actor_t *create(const char *name, vec3_t p, vec3_t s, SDL_Rect r, SDL_Point o)
|
||||
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));
|
||||
strcpy(act->name, name);
|
||||
act->pos = p;
|
||||
act->size = s;
|
||||
act->surface = draw::loadSurface(bmp);
|
||||
act->bmp_rect = r;
|
||||
act->bmp_offset = o;
|
||||
act->anim_cycle = act->orient = 0;
|
||||
@@ -566,6 +567,7 @@ namespace actor
|
||||
if (!act) return;
|
||||
//if (act==first)order=0;
|
||||
//order++;
|
||||
|
||||
const int x = 148-act->bmp_offset.x + act->pos.x*2 - act->pos.y*2;
|
||||
const int y = 91-act->bmp_offset.y + act->pos.x + act->pos.y - act->pos.z*2;
|
||||
|
||||
@@ -574,7 +576,10 @@ namespace actor
|
||||
|
||||
const int ao = (act->flags & FLAG_ANIMATED) ? anims[act->anim_cycle][anim_frame]*act->bmp_rect.w : 0;
|
||||
|
||||
draw::pushSource();
|
||||
draw::setSource(act->surface);
|
||||
draw::draw(x, y, act->bmp_rect.w, act->bmp_rect.h, act->bmp_rect.x+ao, act->bmp_rect.y+oo, flip);
|
||||
draw::popSource();
|
||||
//print(x+5,y,act->pos.x);
|
||||
//print(x+5,y+6,act->pos.y);
|
||||
//print(x+5,y+12,act->pos.z);
|
||||
@@ -648,6 +653,7 @@ namespace actor
|
||||
if (act->flags & FLAG_HERO) {
|
||||
hero = act;
|
||||
} else {
|
||||
draw::freeSurface(act->surface);
|
||||
free(act);
|
||||
}
|
||||
act = tmp;
|
||||
@@ -659,6 +665,7 @@ namespace actor
|
||||
if (act->flags & FLAG_HERO) {
|
||||
hero = act;
|
||||
} else {
|
||||
draw::freeSurface(act->surface);
|
||||
free(act);
|
||||
}
|
||||
act = tmp;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include <SDL2/SDL.h>
|
||||
#include "misc.h"
|
||||
#include "jdraw.h"
|
||||
|
||||
#define FLAG_NONE 0
|
||||
#define FLAG_HERO 1
|
||||
@@ -33,9 +34,10 @@ namespace actor
|
||||
{
|
||||
struct actor_t
|
||||
{
|
||||
char name[8];
|
||||
SDL_Rect bmp_rect;
|
||||
SDL_Point bmp_offset;
|
||||
char name[8];
|
||||
draw::surface *surface;
|
||||
SDL_Rect bmp_rect;
|
||||
SDL_Point bmp_offset;
|
||||
|
||||
vec3_t pos;
|
||||
vec3_t size;
|
||||
@@ -61,7 +63,7 @@ namespace actor
|
||||
|
||||
actor_t *getFirst();
|
||||
|
||||
actor_t *create(const char *name, vec3_t p, vec3_t s, SDL_Rect r, SDL_Point o);
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user