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
|
#include "game.hpp"
namespace game {
static const struct {
render::animated_texture_t *texture;
v2f_t mins, maxs;
world::cflags_t cflags;
v2f_t render_mins, render_maxs;
double fps;
} decos[ ] = {
{
&assets::deco.stone,
{-0.4f, +0.1f}, {+0.4f, +0.4f}, CF_SOLID,
{-0.4f, -0.4f}, {+0.4f, +0.4f}, 0.0
},
{
&assets::deco.stone,
{-0.2f, +0.1f}, {+0.2f, +0.2f}, CF_SOLID,
{-0.2f, -0.2f}, {+0.2f, +0.2f}, 0.0
},
{
&assets::deco.eyething,
{-0.4f, +0.1f}, {+0.4f, +0.4f}, CF_SOLID,
{-0.4f, -1.2f}, {+0.4f, +0.4f}, 0.3
}
};
deco_t::deco_t(game::state_t *game_, deco_type_t type_) : entity_t(ET_DECO)
{
game = game_;
type = type_;
}
void deco_t::spawn(world::world_t *world, v2f_t x)
{
v2f_t center, offset;
offset[0] = world->perlin.get(x, 0.17331f);
offset[1] = world->perlin.get(x, 0.19571f);
center = x + v2f_t(0.5f, 0.5f) + offset.norm() * 0.1;
cmodel.bounds[0] = center + decos[type].mins;
cmodel.bounds[1] = center + decos[type].maxs;
cmodel.cflags = decos[type].cflags;
render_bounds[0] = center + decos[type].render_mins;
render_bounds[1] = center + decos[type].render_maxs;
link(world);
}
void deco_t::render_to(render::state_t *render)
{
render->render(game->now * decos[type].fps + phase_shift,
decos[type].texture, render_bounds, sf::Color::White);
}
} // namespace game
|