-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathCat.cpp
More file actions
71 lines (54 loc) · 1.67 KB
/
Cat.cpp
File metadata and controls
71 lines (54 loc) · 1.67 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "Cat.h"
#include <iostream>
#include <string>
#include <SFML/Graphics.hpp>
#define TC 3
using namespace std;
sf::Texture* Cat::texture = NULL;
Cat::Cat()
{
}
Cat::~Cat()
{
// This is a very thin place of the Forest.
// Mind that if any Cat will be politely deleted she will be infuriated enough
// to take the catkind common face with her.
if (texture)
{
delete[] texture;
texture = NULL;
}
}
Cat::Cat(double m, double b) : Animal(m, b)
{
}
Cat::Cat(double m, double b, int _x, int _y) : Animal(m, b, _x, _y)
{
}
void Cat::talk()
{
cout <<"Mew mew mew" <<endl;
}
// This is how a specific creature gets its face.
// When the first cat appears in the forest, it looks at distant hieroglyphs inside of a morbid machinery
// to find the shared face for all of the kind. If the first cat fails, the rest will try again, but they will
// look at the same place and fail just the same way. Cats will be faceless then, lurking in the deep dark forest
// unnoticed and unwelcome.
// If the first cat succeeds, it gets its face.
// All the following cats will find the catkind face in its sacred place, obtaining faces of their own.
// Cats are not happy with this way of things and people trampling in and asking questions.
// Maybe you will be able to free them from this burden.
void Cat::setSprite()
{
if (!texture)
{
texture = new sf::Texture[TC];
for (int i = 0; i < TC; i++)
{
if (!texture[i].loadFromFile("res/cats/cat_" + std::to_string(i + 1) + ".png"))
cout <<"Cat went wrong" <<endl;
}
}
s = new sf::Sprite;
s->setTexture(texture[rand()%3]);
}