-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreature.cpp
More file actions
58 lines (50 loc) · 1.48 KB
/
Copy pathCreature.cpp
File metadata and controls
58 lines (50 loc) · 1.48 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
#include "Creature.h"
#include "utility.h"
#include "gameview.h"
#include <iostream>
Creature::Creature(const char *img, int x, int y, int z, int height_, int width_)
{
texture = new sf::Texture;
sprite = new sf::Sprite;
texture ->loadFromFile(img);
sprite ->setTexture(*texture);
height = height_;
width = width_;
depth = 0;
xValue = x;
yValue = gameView.view.getSize().y;
zValue = z;
yStand = y;
yLie = gameView.view.getSize().y;
sprite ->setPosition(xValue,yValue);
AnimationState = lie;
in_out_start = gameClock.getElapsedTime();
}
void Creature::set_intro()
{
if (gameClock.getElapsedTime() - in_out_start >= introTime)
{
yValue = yStand;
AnimationState = stand;
sprite ->setPosition(xValue, yValue);
}
else
{
yValue = gameView.view.getSize().y - ((gameClock.getElapsedTime() - in_out_start).asMilliseconds() * (gameView.view.getSize().y - yStand) / introTime.asMilliseconds());
sprite ->setPosition(xValue, yValue);
}
}
void Creature::set_outro()
{
if (gameClock.getElapsedTime() - in_out_start >= introTime)
{
yValue = gameView.view.getSize().y;
AnimationState = lie;
sprite ->setPosition(xValue, yValue);
}
else
{
yValue = yStand + ((gameClock.getElapsedTime() - in_out_start).asMilliseconds() * (gameView.view.getSize().y - yStand) / introTime.asMilliseconds());
sprite -> setPosition(xValue, yValue);
}
}