Ordered_array<data_t>::Ordered_array( const size_t &max_size ){ abs_size( max_size*sizeof(data_t) ); base=new data_t(max_size); memset( base, 0, max_size*sizeof(base)); size(0); this->max_size(max_size); }
void SpriteScene::Render(SDL_Renderer* ren, Vector2d cam) { Sprite* sprite; ARRAY_ID id; SDL_Rect rect; for(int i = 0; i < sprites.GetElementCount(); ++i) { sprites.get_by_index(i, &id, &sprite); Vector2d abs_size(abs(sprite->size.x), abs(sprite->size.y)); rect.x = sprite->pos.x - abs_size.x / 2 - cam.x; rect.y = sprite->pos.y - abs_size.y / 2 - cam.y; rect.w = abs_size.x; rect.h = abs_size.y; int flip_mask = SDL_FLIP_NONE; if(sprite->size.x < 0) flip_mask |= SDL_FLIP_HORIZONTAL; if(sprite->size.y < 0) flip_mask |= SDL_FLIP_VERTICAL; if(sprite->source.x | sprite->source.y | sprite->source.w | sprite->source.h) { SDL_RenderCopyEx(ren, sprite->texture.ptr, &sprite->source, &rect, 0, 0, (SDL_RendererFlip)flip_mask); }else { SDL_RenderCopyEx(ren, sprite->texture.ptr, 0, &rect, 0, 0, (SDL_RendererFlip)flip_mask); } } }