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

Last change on this file since 687 was 687, checked in by Sam Hocevar, 10 years ago

core: get rid of custom Min(), Max(), ERROR(), etc. and use the Lol Engine
features instead.

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 "linked.h"
23#include "sprite.h"
24
25ASprite::ASprite(image *screen, image *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 image(visual->Size());
34
35    if (m_pos + visual->Size() >= ivec2(0) && m_pos < ivec2(xres, yres))
36        m_save->PutPart(m_screen, ivec2(0), m_pos, m_pos + m_save->Size());
37}
38
39ASprite::~ASprite()
40{
41    delete m_save;
42}
43
44void ASprite::SetVisual(image *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 image(visual->Size());
53    }
54
55    if (m_pos + visual->Size() >= ivec2(0) && m_pos < ivec2(xres, yres))
56        m_save->PutPart(m_screen, ivec2(0), m_pos, m_pos + m_save->Size());
57}
58
Note: See TracBrowser for help on using the repository browser.