-
Notifications
You must be signed in to change notification settings - Fork 2
/
GameObject.cpp
57 lines (38 loc) · 952 Bytes
/
GameObject.cpp
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
48
49
50
51
//
// Created by fredr on 01.04.2020.
//
#include "GameObject.h"
#include "Map.h"
GameObject::GameObject(const char *path, SDL_Point pos) : objTexture(Screen::loadImage(path, 255)),
arrayOfRails(Map::getInstance()->getRails()),
renderer(Screen::renderer), pos(pos)
{}
GameObject::~GameObject()
= default;
void GameObject::update()
{
if (&pos == teleportLeft) {
pos.x = 515;
} else if (&pos == teleportRight) {
pos.x = 100;
}
srcRect.h = 23;
srcRect.w = 23;
srcRect.x = 0;
srcRect.y = 0;
destRect.x = pos.x;
destRect.y = pos.y;
destRect.w = srcRect.w;
destRect.h = srcRect.h;
}
bool GameObject::isStillAlive()
{
return stillAlive;
}
void GameObject::move()
{
}
void GameObject::render()
{
SDL_RenderCopy(renderer, objTexture, &srcRect, &destRect);
}