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

Last change on this file since 711 was 711, checked in by Sam Hocevar, 9 years ago

core: get rid of linked_list and linked_node, at last.

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-2011 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 defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include <math.h>
16
17#include "common.h"
18
19#include "video.h"
20#include "image.h"
21#include "palette.h"
22#include "sprite.h"
23
24ASprite::ASprite(AImage *screen, AImage *visual, ivec2 pos)
25{
26    ASSERT(visual);
27    ASSERT(screen);
28
29    m_pos = pos;
30    m_visual = visual;
31    m_screen = screen;
32    m_save = new AImage(visual->Size());
33
34    if (m_pos + visual->Size() >= ivec2(0) && m_pos < ivec2(xres, yres))
35        m_save->PutPart(m_screen, ivec2(0), m_pos, m_pos + m_save->Size());
36}
37
38ASprite::~ASprite()
39{
40    delete m_save;
41}
42
43void ASprite::SetVisual(AImage *visual, int delete_old)
44{
45    if (delete_old)
46        delete m_visual;
47    m_visual = visual;
48    if (m_save->Size() != visual->Size())
49    {
50        delete m_save;
51        m_save = new AImage(visual->Size());
52    }
53
54    if (m_pos + visual->Size() >= ivec2(0) && m_pos < ivec2(xres, yres))
55        m_save->PutPart(m_screen, ivec2(0), m_pos, m_pos + m_save->Size());
56}
57
Note: See TracBrowser for help on using the repository browser.