source: abuse/branches/lol/src/imlib/sprite.cpp

Last change on this file was 732, checked in by Sam Hocevar, 8 years ago

build: SDL2 compilation fixes.

File size: 1.3 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *  Copyright (c) 2005-2013 Sam Hocevar <sam@hocevar.net>
5 *
6 *  This software was released into the Public Domain. As with most public
7 *  domain software, no warranty is made or implied by Crack dot Com, by
8 *  Jonathan Clark, or by Sam Hocevar.
9 */
10
11#if HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include <math.h>
16
17#include "common.h"
18
19#include "imlib/video.h"
20#include "imlib/image.h"
21#include "imlib/palette.h"
22
23#include "sprite.h"
24
25ASprite::ASprite(AImage *screen, AImage *visual, ivec2 pos)
26{
27    ASSERT(visual);
28    ASSERT(screen);
29
30    m_pos = pos;
31    m_visual = visual;
32    m_screen = screen;
33    m_save = new AImage(visual->Size());
34
35    if (m_pos + visual->Size() >= ivec2::zero && m_pos < ivec2(xres, yres))
36        m_save->PutPart(m_screen, ivec2::zero, m_pos, m_pos + m_save->Size());
37}
38
39ASprite::~ASprite()
40{
41    delete m_save;
42}
43
44void ASprite::SetVisual(AImage *visual, int delete_old)
45{
46    if (delete_old)
47        delete m_visual;
48    m_visual = visual;
49    if (m_save->Size() != visual->Size())
50    {
51        delete m_save;
52        m_save = new AImage(visual->Size());
53    }
54
55    if (m_pos + visual->Size() >= ivec2::zero && m_pos < ivec2(xres, yres))
56        m_save->PutPart(m_screen, ivec2::zero, m_pos, m_pos + m_save->Size());
57}
58
Note: See TracBrowser for help on using the repository browser.