summaryrefslogtreecommitdiff
path: root/Sprite.cpp
blob: e9203613d2899f78d4ad57ff0896ab9e3fc32961 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include "Sprite.h"

Sprite::Sprite() {
    isVisible = true;
}

int Sprite::getX() {
    return x;
}

int Sprite::getY() {
    return y;
}

void Sprite::setX(int x) {
    this->x = x;
}

void Sprite::setY(int y) {
    this->y = y;
}

bool Sprite::visible() {
    return isVisible;
}

bool Sprite::setImage(std::string path) {
    image = loadImage(path);
    // Set initial clip to the whole image
    clipNo = 0;
    clip[0].x = 0;
    clip[0].y = 0;
    clip[0].w = image->w;
    clip[0].h = image->h;
}

SDL_Rect* Sprite::getClip() {
    return &clip[clipNo];
}

void Sprite::setClip(int clipNo, int x, int y, int w, int h) {
    clip[clipNo].x = x;
    clip[clipNo].y = y;
    clip[clipNo].w = w;
    clip[clipNo].h = h;
}