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