source: abuse/trunk/src/imlib/sprite.cpp

Last change on this file was 682, checked in by Sam Hocevar, 11 years ago

core: rename vec2i to ivec2 and update matrix.h from Lol Engine.

File size: 1.3 KB
RevLine 
[56]1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
[494]4 *  Copyright (c) 2005-2011 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
[555]11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
[56]14
15#include <math.h>
16
[512]17#include "common.h"
18
[481]19#include "video.h"
20#include "image.h"
21#include "palette.h"
22#include "linked.h"
23#include "sprite.h"
[2]24
[682]25Sprite::Sprite(image *screen, image *visual, ivec2 pos)
[669]26{
27    CHECK(visual && screen);
28    m_pos = pos;
29    m_visual = visual;
30    m_screen = screen;
31    m_save = new image(visual->Size());
[2]32
[682]33    if (m_pos + visual->Size() >= 0 && m_pos < ivec2(xres, yres))
34        m_save->PutPart(m_screen, ivec2(0,0), m_pos, m_pos + m_save->Size());
[513]35}
[2]36
[669]37Sprite::~Sprite()
[2]38{
[669]39    delete m_save;
[2]40}
41
[669]42void Sprite::SetVisual(image *visual, int delete_old)
[2]43{
[669]44    if (delete_old)
45        delete m_visual;
46    m_visual = visual;
47    if (m_save->Size() != visual->Size())
48    {
49        delete m_save;
50        m_save = new image(visual->Size());
51    }
[2]52
[682]53    if (m_pos + visual->Size() >= 0 && m_pos < ivec2(xres, yres))
54        m_save->PutPart(m_screen, ivec2(0,0), m_pos, m_pos + m_save->Size());
[2]55}
[534]56
Note: See TracBrowser for help on using the repository browser.