about summary refs log tree commit diff stats
path: root/data/maps/the_talented
diff options
context:
space:
mode:
Diffstat (limited to 'data/maps/the_talented')
0 files changed, 0 insertions, 0 deletions
f='/therapy/commit/src/systems/mapping.cpp?h=es-rewrite&id=8016a7146fec3f6f43ca05723441750e5aae3d4d'>8016a71 ^
77be863 ^
8016a71 ^
77be863 ^
8016a71 ^

77be863 ^
8016a71 ^




77be863 ^
8016a71 ^
77be863 ^
8016a71 ^


77be863 ^


8016a71 ^


77be863 ^


ed08b67 ^
8016a71 ^
ed08b67 ^


77be863 ^

8016a71 ^






















77be863 ^

8016a71 ^
77be863 ^
77be863 ^
8016a71 ^
77be863 ^
e16fb5b ^
8016a71 ^
e16fb5b ^





8016a71 ^
e16fb5b ^





8016a71 ^
e16fb5b ^





8016a71 ^
e16fb5b ^




77be863 ^



8016a71 ^
77be863 ^



8016a71 ^
77be863 ^






8016a71 ^
77be863 ^





8016a71 ^
77be863 ^





8016a71 ^
77be863 ^





8016a71 ^
77be863 ^






8016a71 ^
e4e2f2d ^





8016a71 ^
e4e2f2d ^





8016a71 ^
c00668c ^
77be863 ^


e4e2f2d ^

8016a71 ^
e4e2f2d ^



77be863 ^


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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191

                                

                                  


                   














                                              


                                                                            
 
                                     
 

                                            
 




                                                  
 
                 
     


                        


                     


                                            


                     
                               
                         


                        

     






















                                                                             

 
                                                         
 
                                            
                                               
 
              
                            





                                                  
                             





                                                  
                          





                                                  
                            




                                                  



                                                     
                                 



                                   
                                






                                                     
                                 





                                                 
                                





                                                 
                                





                                                 
                              






                                                 
                                 





                                                   
                                





                                                   
                                
                            


                                                   

                  
                              



                                                   


     
#include "mapping.h"
#include "components/mappable.h"
#include "components/realizable.h"
#include "systems/realizing.h"
#include "game.h"
#include "consts.h"

template <typename Storage>
inline void addBoundary(
  Storage& boundaries,
  int axis,
  int lower,
  int upper,
  MappableComponent::Boundary::Type type)
{
  boundaries.emplace(std::piecewise_construct,
    std::tie(axis),
    std::tie(axis, lower, upper, type));
}

void MappingSystem::render(Texture& texture)
{
  auto& realizable = game_.getEntityManager().
    getComponent<RealizableComponent>(
      game_.getSystemManager().getSystem<RealizingSystem>().getSingleton());

  id_type map = realizable.activeMap;

  auto& mappable = game_.getEntityManager().
    getComponent<MappableComponent>(map);

  for (int i = 0; i < MAP_WIDTH * MAP_HEIGHT; i++)
  {
    int x = i % MAP_WIDTH;
    int y = i / MAP_WIDTH;
    int tile = mappable.tiles[i];

    if (tile > 0)
    {
      Rectangle dst {
        x * TILE_WIDTH,
        y * TILE_HEIGHT,
        TILE_WIDTH,
        TILE_HEIGHT};

      Rectangle src {
        (tile % TILESET_COLS) * TILE_WIDTH,
        (tile / TILESET_COLS) * TILE_HEIGHT,
        TILE_WIDTH,
        TILE_HEIGHT};

      game_.getRenderer().blit(
        mappable.tileset,
        texture,
        std::move(src),
        std::move(dst));
    }
  }

  int startX = ((GAME_WIDTH / TILE_WIDTH) / 2) - (mappable.title.size() / 2);

  for (size_t i = 0; i < mappable.title.size(); i++)
  {
    Rectangle src {
      (mappable.title[i] % FONT_COLS) * TILE_WIDTH,
      (mappable.title[i] / FONT_COLS) * TILE_HEIGHT,
      TILE_WIDTH,
      TILE_HEIGHT};

    Rectangle dst {
      (startX + static_cast<int>(i)) * TILE_WIDTH,
      24 * TILE_HEIGHT,
      TILE_WIDTH,
      TILE_HEIGHT};

    game_.getRenderer().blit(
      mappable.font,
      texture,
      std::move(src),
      std::move(dst));
  }
}

void MappingSystem::generateBoundaries(id_type mapEntity)
{
  auto& mappable = game_.getEntityManager().
    getComponent<MappableComponent>(mapEntity);

  addBoundary(
    mappable.leftBoundaries,
    -WALL_GAP,
    0,
    MAP_HEIGHT * TILE_HEIGHT,
    MappableComponent::Boundary::Type::adjacency);

  addBoundary(
    mappable.rightBoundaries,
    GAME_WIDTH + WALL_GAP,
    0,
    MAP_HEIGHT * TILE_HEIGHT,
    MappableComponent::Boundary::Type::adjacency);

  addBoundary(
    mappable.upBoundaries,
    -WALL_GAP,
    0,
    GAME_WIDTH,
    MappableComponent::Boundary::Type::adjacency);

  addBoundary(
    mappable.downBoundaries,
    MAP_HEIGHT * TILE_HEIGHT + WALL_GAP,
    0,
    GAME_WIDTH,
    MappableComponent::Boundary::Type::adjacency);

  for (size_t i = 0; i < MAP_WIDTH * MAP_HEIGHT; i++)
  {
    size_t x = i % MAP_WIDTH;
    size_t y = i / MAP_WIDTH;
    int tile = mappable.tiles[i];

    if ((tile >= 5) && (tile <= 7))
    {
      addBoundary(
        mappable.downBoundaries,
        y * TILE_HEIGHT,
        x * TILE_WIDTH,
        (x + 1) * TILE_WIDTH,
        MappableComponent::Boundary::Type::platform);
    } else if ((tile > 0) && (tile < 28))
    {
      addBoundary(
        mappable.rightBoundaries,
        x * TILE_WIDTH,
        y * TILE_HEIGHT,
        (y+1) * TILE_HEIGHT,
        MappableComponent::Boundary::Type::wall);

      addBoundary(
        mappable.leftBoundaries,
        (x+1) * TILE_WIDTH,
        y * TILE_HEIGHT,
        (y+1) * TILE_HEIGHT,
        MappableComponent::Boundary::Type::wall);

      addBoundary(
        mappable.downBoundaries,
        y * TILE_HEIGHT,
        x * TILE_WIDTH,
        (x+1) * TILE_WIDTH,
        MappableComponent::Boundary::Type::wall);

      addBoundary(
        mappable.upBoundaries,
        (y+1) * TILE_HEIGHT,
        x * TILE_WIDTH,
        (x+1) * TILE_WIDTH,
        MappableComponent::Boundary::Type::wall);
    } else if (tile == 42)
    {
      addBoundary(
        mappable.rightBoundaries,
        x * TILE_WIDTH,
        y * TILE_HEIGHT,
        (y+1) * TILE_HEIGHT,
        MappableComponent::Boundary::Type::danger);

      addBoundary(
        mappable.leftBoundaries,
        (x+1) * TILE_WIDTH,
        y * TILE_HEIGHT,
        (y+1) * TILE_HEIGHT,
        MappableComponent::Boundary::Type::danger);

      addBoundary(
        mappable.downBoundaries,
        y * TILE_HEIGHT + 1,
        x * TILE_WIDTH,
        (x+1) * TILE_WIDTH,
        MappableComponent::Boundary::Type::danger);

      addBoundary(
        mappable.upBoundaries,
        (y+1) * TILE_HEIGHT,
        x * TILE_WIDTH,
        (x+1) * TILE_WIDTH,
        MappableComponent::Boundary::Type::danger);
    }
  }
}