Deep RTS
Blend2DGUI.h
Go to the documentation of this file.
1//
2// Created by per on 9/4/21.
3//
4
5#ifndef DEEPRTS_GUI_H
6#define DEEPRTS_GUI_H
7
8#include <blend2d.h>
9#include "gui/BaseGUI.h"
10#include <cmrc/cmrc.hpp>
11#include <utility>
12#include <opencv2/core/mat.hpp>
13#include <opencv2/core.hpp>
14#include <opencv2/imgcodecs.hpp>
15#include <opencv2/highgui.hpp>
16#include "Constants.h"
17CMRC_DECLARE(DeepRTSAssets);
18
19using UnitStateData = std::unordered_map<Constants::State, std::vector<std::tuple<int, int, bool>>>;
20using UnitData = std::unordered_map<Constants::Direction, UnitStateData>;
21using Color = std::tuple<int, int, int>;
22
23
25public:
26 static BLImage subImage(const BLImage& src, int x, int y, int w, int h, BLFormat format=BL_FORMAT_PRGB32){
27 BLImage img(w, h, format);
28 BLContext ctx(img);
29 ctx.setCompOp(BLCompOp::BL_COMP_OP_SRC_COPY);
30 ctx.blitImage(BLPointI(0, 0), src, BLRectI(x, y, w, h));
31 return img;
32 }
33 static void blit(int x, int y, BLContext& ctx, const BLImage& src){
34 ctx.blitImage(BLPointI(x, y), src);
35 }
36};
37
38
39
41 std::vector<BLImage> Spawning;
42 std::vector<BLImage> Walking;
43 std::vector<BLImage> Despawned;
44 std::vector<BLImage> Harvesting;
45 std::vector<BLImage> Building;
46 std::vector<BLImage> Combat;
47 std::vector<BLImage> Dead;
48 std::vector<BLImage> Base;
49 std::vector<BLImage> Idle;
50
51 std::vector<BLImage>* getContainer(Constants::State state){
52 std::vector<BLImage> *container;
53 switch (state) {
55 container = &Spawning;
56 break;
58 container = &Walking;
59 break;
61 container = &Despawned;
62 break;
64 container = &Harvesting;
65 break;
67 container = &Building;
68 break;
70 container = &Combat;
71 break;
72 case Constants::Dead:
73 container = &Dead;
74 break;
75 case Constants::Idle:
76 container = &Idle;
77 break;
78 case Constants::Base:
79 container = &Base;
80 break;
81 }
82 return container;
83 }
84
85public:
86
87 void load(const BLImage& src, int tileSize, int width, int height, const UnitStateData& stateData){
88 for(const auto & pair: stateData){
89 std::vector<BLImage> *container = getContainer(pair.first);
90 for(const auto& frame: pair.second){
91 auto [x, y, flip] = frame;
92 container->push_back(Blend2DWrapper::subImage(src, x, y, tileSize * width, tileSize * height));
93 }
94 }
95 }
96
97
98 const BLImage& get(int animationCounter, Constants::State state) {
99 std::vector<BLImage> *container = getContainer(state);
100 auto idx = animationCounter % container->size();
101 return container->at(idx);
102 }
103};
104
106protected:
115
116public:
117 const BLImage& get(int animationCounter, Constants::Direction direction, Constants::State state) {
118 switch(direction){
120 return Down.get(animationCounter, state);
121 case Constants::Up:
122 return Up.get(animationCounter, state);
123 case Constants::Left:
124 return Left.get(animationCounter, state);;
125 case Constants::Right:
126 return Right.get(animationCounter, state);
128 return DownLeft.get(animationCounter, state);
130 return DownRight.get(animationCounter, state);
132 return UpLeft.get(animationCounter, state);
134 return UpRight.get(animationCounter, state);
135 }
136
137 throw std::runtime_error("Should not come here.");
138 }
139};
140
142 const std::string asset_path;
143 const int tileSize;
144 const int width;
145 const int height;
146 const UnitData data;
147 const Color color;
148 BLImage image;
149
150
151protected:
152 explicit Blend2DUnit(const Color& color, int tileSize, int width, int height, std::string path, UnitData data)
153 : asset_path(std::move(path))
154 , tileSize(tileSize)
155 , width(width)
156 , height(height)
157 , data(std::move(data))
158 {
159 auto [r, g, b] = color;
160 auto fs = cmrc::DeepRTSAssets::get_filesystem();
161 auto tileData = fs.open(asset_path);
162 cv::Mat rawData( 1, tileData.size(), CV_8UC1, (void*)tileData.begin() );
163 cv::Mat decodedImage = cv::imdecode(rawData, cv::ImreadModes::IMREAD_UNCHANGED);
164 cv::Mat mask;
165 cv::inRange(decodedImage, cv::Scalar(150, 150, 150, 150), cv::Scalar(255, 255, 255, 255), mask);
166 decodedImage.setTo(cv::Scalar(r, g, b, 255), mask);
167
168 std::vector<uchar> buf;
169 cv::imencode(".png", decodedImage, buf, std::vector<int>() );
170// imageBuf = (unsigned char *) realloc(imageBuf, buf.size());
171// memcpy(imageBuf, &buf[0], buf.size());
172//
173// cv::imshow("lo", decodedImage);
174// cv::waitKey(1000);
175 if ( decodedImage.data == NULL )
176 {
177 // Error reading raw image data
178 }
179
180 auto err = image.readFromData(buf.data(), buf.size());
181
182 if (err) {
183 throw std::runtime_error("Could not load the tileset texture");
184 }
185
186 load();
187
188 }
189
190 void load(){
191 for(auto& pair: data){
192 switch(pair.first){
194 Down.load(image, tileSize, width, height, pair.second);
195 break;
196 case Constants::Up:
197 Up.load(image, tileSize, width, height, pair.second);
198 break;
199 case Constants::Left:
200 Left.load(image, tileSize, width, height, pair.second);
201 break;
202 case Constants::Right:
203 Right.load(image, tileSize, width, height, pair.second);
204 break;
206 DownLeft.load(image, tileSize, width, height, pair.second);
207 break;
209 DownRight.load(image, tileSize, width, height, pair.second);
210 break;
212 UpLeft.load(image, tileSize, width, height, pair.second);
213 break;
215 UpRight.load(image, tileSize, width, height, pair.second);
216 break;
217 }
218 }
219
220
221
222 }
223
224};
225
226
227
228
230public:
231 Blend2DFarm(const Color& color, int tileSize, int width, int height)
232 : Blend2DUnit(color,
233 tileSize, width, height,
234 "assets/textures/farm.png",
235 {
236
237 {
245 {Constants::State::Dead, {}}, // TODO
247 }
248 },
249 {
251 {Constants::State::Spawning, {{32, 0, false}}},
257 {Constants::State::Dead, {{32, 0, false}}},
258 {Constants::State::Idle, {{0, 0, false}}}
259 }
260 },
261 {
271 }
272 },
273 {
283 }
284 },
285 {
295 }
296 },
297 {
307 }
308 },
309 {
318 }
319 },
320 {
330 }
331 }
332 })
333 {}
334
335};
336
338
339};
341
342public:
343 Blend2DPeasant(const Color& color, int tileSize, int width, int height)
344 : Blend2DUnit(color,
345 tileSize, width, height,
346 "assets/textures/peasant.png",
347 {
348 {
351 {Constants::State::Walking, {{0, 0, false}, {32, 0, false}, {64, 0, false}, {96, 0, false},
352 {128, 0, false}}},
354 {Constants::State::Harvesting, {{0, 288, false}, {32, 288, false}, {64, 288, false}, {96, 288, false},
355 {128, 288, false}}},
356 {Constants::State::Building, {{0, 288, false}, {32, 288, false}, {64, 288, false}, {96, 288, false},
357 {128, 288, false}}},
358 {Constants::State::Combat, {{0, 288, false}, {32, 288, false}, {64, 288, false}, {96, 288, false},
359 {128, 288, false}}},
360 {Constants::State::Dead, {{164, 4, false}}}, // TODO
361 {Constants::State::Idle, {{0, 0, false}}}
362 }
363 },
364 {
367 {Constants::State::Walking, {{0, 32, false}, {32, 32, false}, {64, 32, false}, {96, 32, false},
368 {128, 32, false}}},
370 {Constants::State::Harvesting, {{0, 352, false}, {32, 352, false}, {64, 352, false}, {96, 352, false},
371 {128, 352, false}}},
372 {Constants::State::Building, {{0, 352, false}, {32, 352, false}, {64, 352, false}, {96, 352, false},
373 {128, 352, false}}},
374 {Constants::State::Combat, {{0, 352, false}, {32, 352, false}, {64, 352, false}, {96, 352, false},
375 {128, 352, false}}},
376 {Constants::State::Dead, {{164, 4, false}}},
377 {Constants::State::Idle, {{0, 32, false}}}
378 }
379 },
380 {
383 {Constants::State::Walking, {{0, 64, false}, {32, 64, false}, {64, 64, false}, {96, 64, false},
384 {128, 64, false}}},
386 {Constants::State::Harvesting, {{0, 320, false}, {32, 320, false}, {64, 320, false}, {96, 320, false}}},
387 {Constants::State::Building, {{0, 320, false}, {32, 320, false}, {64, 320, false}, {96, 320, false},
388 {128, 320, false}}},
389 {Constants::State::Combat, {{0, 320, false}, {32, 320, false}, {64, 320, false}, {96, 320, false}}},
390 {Constants::State::Dead, {{164, 4, false}}},
391 {Constants::State::Idle, {{0, 64, false}}}
392 }
393 },
394 {
397 {Constants::State::Walking, {{0, 96, false}, {32, 96, false}, {64, 96, false}, {96, 96, false},
398 {128, 96, false}}},
400 {Constants::State::Harvesting, {{0, 320, true}, {32, 320, true}, {64, 320, true}, {96, 320, true}}},
401 {Constants::State::Building, {{0, 320, true}, {32, 320, true}, {64, 320, true}, {96, 320, true},
402 {128, 320, true}}},
403 {Constants::State::Combat, {{0, 320, true}, {32, 320, true}, {64, 320, true}, {96, 320, true}}},
404 {Constants::State::Dead, {{164, 4, false}}},
405 {Constants::State::Idle, {{0, 96, false}}}
406 }
407 },
408 {
411 {Constants::State::Walking, {{0, 128, false}, {32, 128, false}, {64, 128, false}, {96, 128, false},
412 {128, 128, false}}},
414 {Constants::State::Harvesting, {{0, 256, false}, {32, 256, false}, {64, 256, false}}},
415 {Constants::State::Building, {{0, 256, false}, {32, 256, false}, {64, 256, false}}},
416 {Constants::State::Combat, {{0, 256, false}, {32, 256, false}, {64, 256, false}}},
417 {Constants::State::Dead, {{164, 4, false}}},
418 {Constants::State::Idle, {{0, 128, false}}}
419 }
420 },
421 {
424 {Constants::State::Walking, {{0, 160, false}, {32, 160, false}, {64, 160, false}, {96, 160, false},
425 {128, 160, false}}},
427 {Constants::State::Harvesting, {{0, 256, true}, {32, 256, true}, {64, 256, true}}},
428 {Constants::State::Building, {{0, 256, true}, {32, 256, true}, {64, 256, true}}},
429 {Constants::State::Combat, {{0, 256, true}, {32, 256, true}, {64, 256, true}}},
430 {Constants::State::Dead, {{164, 4, false}}},
431 {Constants::State::Idle, {{0, 160, false}}}
432 }
433 },
434 {
437 {Constants::State::Walking, {{0, 224, false}, {32, 224, false}, {64, 224, false}, {96, 224, false},
438 {128, 224, false}}},
440 {Constants::State::Harvesting, {{32, 320, true}, {64, 352, true}, {96, 352, true}, {128, 352, true}}},
441 {Constants::State::Building, {{0, 320, true}, {32, 320, true}}},
442 {Constants::State::Combat, {{32, 320, true}, {64, 352, true}, {96, 352, true}, {128, 352, true}}},
443 {Constants::State::Dead, {{164, 4, false}}},
444 {Constants::State::Idle, {{0, 224, false}}}
445 }
446 },
447 {
450 {Constants::State::Walking, {{0, 192, false}, {32, 192, false}, {64, 192, false}, {96, 192, false},
451 {128, 192, false}}},
453 {Constants::State::Harvesting, {{32, 320, false}, {64, 352, false}, {96, 352, false},
454 {128, 352, false}}},
455 {Constants::State::Building, {{0, 320, false}, {32, 320, false}}},
456 {Constants::State::Combat, {{32, 320, false}, {64, 352, false}, {96, 352, false}, {128, 352, false}}},
457 {Constants::State::Dead, {{164, 4, false}}},
458 {Constants::State::Idle, {{0, 192, false}}}
459 }
460 }
461 })
462 {}
463
464
465
466};
468public:
469 Blend2DFootman(const Color& color, int tileSize, int width, int height)
470 : Blend2DUnit(color,
471 tileSize, width, height,
472 "assets/textures/footman.png",
473 {
474
475 {
478 {Constants::State::Walking, {{0, 0, false}, {32, 0, false}, {64, 0, false}, {96, 0, false},
479 {128, 0, false}}},
483 {Constants::State::Combat, {{0, 160, false}, {32, 160, false}, {64, 160, false}, {96, 160, false}}},
484 {Constants::State::Dead, {{164, 4, false}}}, // TODO
485 {Constants::State::Idle, {{0, 0, false}}}
486 }
487 },
488 {
491 {Constants::State::Walking, {{0, 128, false}, {32, 128, false}, {64, 128, false}, {96, 128, false},
492 {128, 128, false}}},
496 {Constants::State::Combat, {{0, 288, false}, {32, 288, false}, {64, 288, false}, {96, 288, false}}},
497 {Constants::State::Dead, {{164, 4, false}}},
498 {Constants::State::Idle, {{0, 128, false}}}
499 }
500 },
501 {
504 {Constants::State::Walking, {{0, 64, false}, {32, 64, false}, {64, 64, false}, {96, 64, false},
505 {128, 64, false}}},
509 {Constants::State::Combat, {{0, 224, false}, {32, 224, false}, {64, 224, false}, {96, 224, false}}},
510 {Constants::State::Dead, {{164, 4, false}}},
511 {Constants::State::Idle, {{0, 64, false}}}
512 }
513 },
514 {
517 {Constants::State::Walking, {{0, 64, true}, {32, 64, true}, {64, 64, true}, {96, 64, true},
518 {128, 64, true}}},
522 {Constants::State::Combat, {{0, 224, true}, {32, 224, true}, {64, 224, true}, {96, 224, true}}},
523 {Constants::State::Dead, {{164, 4, false}}},
524 {Constants::State::Idle, {{0, 64, true}}}
525 }
526 },
527 {
530 {Constants::State::Walking, {{0, 32, false}, {32, 32, false}, {64, 32, false}, {96, 32, false},
531 {128, 32, false}}},
535 {Constants::State::Combat, {{0, 192, false}, {32, 192, false}, {64, 192, false}}},
536 {Constants::State::Dead, {{164, 4, false}}},
537 {Constants::State::Idle, {{0, 32, false}}}
538 }
539 },
540 {
543 {Constants::State::Walking, {{0, 32, true}, {32, 32, true}, {64, 32, true}, {96, 32, true},
544 {128, 32, true}}},
548 {Constants::State::Combat, {{0, 192, true}, {32, 192, true}, {64, 192, true}}},
549 {Constants::State::Dead, {{164, 4, false}}},
550 {Constants::State::Idle, {{0, 32, true}}}
551 }
552 },
553 {
556 {Constants::State::Walking, {{0, 96, false}, {32, 96, false}, {64, 96, false}, {96, 96, false},
557 {128, 96, false}}},
560 {Constants::State::Combat, {{0, 256, false}, {32, 256, false}, {64, 256, false}, {96, 256, false}}},
561 {Constants::State::Dead, {{164, 4, false}}},
562 {Constants::State::Idle, {{0, 96, false}}}
563 }
564 },
565 {
568 {Constants::State::Walking, {{0, 96, true}, {32, 96, true}, {64, 96, true}, {96, 96, true},
569 {128, 96, true}}},
573 {Constants::State::Combat, {{0, 256, true}, {32, 256, true}, {64, 256, true}, {96, 256, true}}},
574 {Constants::State::Dead, {{164, 4, false}}},
575 {Constants::State::Idle, {{0, 96, true}}}
576 }
577 }
578 })
579 {}
580
581};
582
584public:
585 Blend2DBarracks(const Color& color, int tileSize, int width, int height)
586 : Blend2DUnit(color,
587 tileSize, width, height,
588 "assets/textures/barracks.png",
589 {
590
591 {
599 {Constants::State::Dead, {}}, // TODO
601 }
602 },
603 {
605 {Constants::State::Spawning, {{96, 0, false}}},
609 {Constants::State::Building, {{0, 0, false}}},
611 {Constants::State::Dead, {{96, 0, false}}},
612 {Constants::State::Idle, {{0, 0, false}}}
613 }
614 },
615 {
625 }
626 },
627 {
637 }
638 },
639 {
649 }
650 },
651 {
661 }
662 },
663 {
672 }
673 },
674 {
684 }
685 }
686 })
687 {}
688
689};
690
692public:
693 Blend2DArcher(const Color& color, int tileSize, int width, int height)
694 : Blend2DUnit(color,
695 tileSize, width, height,
696 "assets/textures/archer.png",
697 {
698
699 {
701 {Constants::State::Spawning, {{0, 32, false}, {32, 32, false}, {64, 32, false}, {96, 32, false}}},
706 {Constants::State::Combat, {{0, 192, false}, {32, 192, false}}},
707 {Constants::State::Dead, {{164, 4, false}}}, // TODO
708 {Constants::State::Idle, {{0, 32, false}}}
709 }
710 },
711 {
714 {Constants::State::Walking, {{0, 160, false}, {32, 160, false}, {64, 160, false}, {96, 160, false},
715 {128, 160, false}}},
719 {Constants::State::Combat, {{0, 320, false}, {32, 320, false}}},
720 {Constants::State::Dead, {{164, 4, false}}},
721 {Constants::State::Idle, {{0, 160, false}}}
722 }
723 },
724 {
727 {Constants::State::Walking, {{0, 96, false}, {32, 96, false}, {64, 96, false}, {96, 96, false}}},
731 {Constants::State::Combat, {{0, 256, false}, {32, 256, false}}},
732 {Constants::State::Dead, {{164, 4, false}}},
733 {Constants::State::Idle, {{0, 96, false}}}
734 }
735 },
736 {
739 {Constants::State::Walking, {{0, 96, true}, {32, 96, true}, {64, 96, true}, {96, 96, true}}},
743 {Constants::State::Combat, {{0, 256, true}, {32, 256, true}}},
744 {Constants::State::Dead, {{164, 4, false}}},
745 {Constants::State::Idle, {{0, 96, true}}}
746 }
747 },
748 {
751 {Constants::State::Walking, {{0, 32, false}, {32, 32, false}, {64, 32, false}, {96, 32, false},
752 {128, 32, false}}},
756 {Constants::State::Combat, {{0, 224, false}, {32, 224, false}}},
757 {Constants::State::Dead, {{164, 4, false}}},
758 {Constants::State::Idle, {{0, 32, false}}}
759 }
760 },
761 {
764 {Constants::State::Walking, {{0, 32, true}, {32, 32, true}, {64, 32, true}, {96, 32, true},
765 {128, 32, true}}},
769 {Constants::State::Combat, {{0, 224, true}, {32, 224, true}}},
770 {Constants::State::Dead, {{164, 4, false}}},
771 {Constants::State::Idle, {{0, 32, true}}}
772 }
773 },
774 {
777 {Constants::State::Walking, {{0, 128, true}, {32, 128, true}, {64, 128, true}, {96, 128, true},
778 {128, 128, true}}},
781 {Constants::State::Combat, {{0, 288, true}, {32, 288, true}}},
782 {Constants::State::Dead, {{164, 4, false}}},
783 {Constants::State::Idle, {{0, 128, true}}}
784 }
785 },
786 {
789 {Constants::State::Walking, {{0, 128, false}, {32, 128, false}, {64, 128, false}, {96, 128, false},
790 {128, 128, false}}},
794 {Constants::State::Combat, {{0, 288, false}, {32, 288, false}}},
795 {Constants::State::Dead, {{164, 4, false}}},
796 {Constants::State::Idle, {{0, 128, false}}}
797 }
798 }
799 })
800 {}
801
802};
803
805public:
806 Blend2DTownHall(const Color& color, int tileSize, int width, int height)
807 : Blend2DUnit(color,
808 tileSize, width, height,
809 "assets/textures/town_hall.png",
810 {
811
812 {
820 {Constants::State::Dead, {}}, // TODO
822 }
823 },
824 {
826 {Constants::State::Spawning, {{96, 0, false}}},
830 {Constants::State::Building, {{0, 0, false}}},
832 {Constants::State::Dead, {{96, 0, false}}},
833 {Constants::State::Idle, {{0, 0, false}}}
834 }
835 },
836 {
846 }
847 },
848 {
858 }
859 },
860 {
870 }
871 },
872 {
882 }
883 },
884 {
893 }
894 },
895 {
905 }
906 }
907 })
908 {}
909
910};
911
912
913
914
915
916
917
919
920public:
921
922
923 explicit Blend2DTile(BLImage tile)
924 : tile(std::move(tile))
925 {
926 }
927
928 BLImage tile;
929};
930
931
933
934 std::vector<Blend2DTile> tiles;
935 const int tileWidth;
936 const int tileHeight;
937
938public:
939 explicit Blend2DTileset(int tileWidth, int tileHeight, const std::string& srcPath)
940 : tileWidth(tileWidth)
941 , tileHeight(tileHeight)
942 {
943 BLImage tileset;
944 auto fs = cmrc::DeepRTSAssets::get_filesystem();
945 auto tileData = fs.open(srcPath);
946 auto err = tileset.readFromData(tileData.begin(), tileData.size());
947 if (err) {
948 throw std::runtime_error("Could not load the tileset texture");
949 }
950
951 BLImageCodec codec;
952 codec.findByName("BMP");
953
954 tileset.writeToFile("lol.bmp", codec);
955
956 load(tileset);
957 }
958
959 void load(BLImage& tileset){
960 auto n_cols = tileset.width() / tileWidth;
961 auto n_rows = tileset.height() / tileHeight;
962 auto total_items = n_cols * n_rows;
963 for(int i = 0; i < total_items; i++){
964 auto x = i % n_cols; // % is the "modulo operator", the remainder of i / width;
965 auto y = i / n_cols; // where "/" is an integer division
966 auto x_start = (x * tileWidth) + x;
967 auto y_start = (y * tileHeight) + y;
968
969 tiles.emplace_back(Blend2DWrapper::subImage(tileset, x_start, y_start, tileWidth, tileHeight));
970// std::cout << "x=" << x_start << ",y=" << y_start << std::endl;
971 // tile.writeToFile((std::to_string(x) + "_" + std::to_string(y) + ".bmp").c_str());
972 }
973
974// for(int i =0; i < tiles.size(); i++){
975// auto& tile = tiles[i].tile;
976// tile.writeToFile((std::to_string(i) + ".bmp").c_str());
977//
978// }
979 }
980
981 [[nodiscard]] const BLImage &at(int index) const{
982 return tiles[index].tile;
983 }
984};
985
986
987
988class Blend2DGUI: public BaseGUI{
989 int tileSize = 32;
990 BLImage canvas;
991 BLContext ctx;
992 BLImageData imageData;
993 Blend2DTileset tileset;
994 std::vector<std::unordered_map<Constants::Unit, Blend2DUnit>> units;
995
996 const cv::Mat& render()const override;
997 void onTileChange(const Tile& tile) override;
998
999public:
1000 explicit Blend2DGUI(Game& game);
1001
1002 void renderMap();
1003
1004};
1005
1006
1007#endif //DEEPRTS_GUI_H
std::tuple< int, int, int > Color
Definition: Blend2DGUI.h:21
std::unordered_map< Constants::Direction, UnitStateData > UnitData
Definition: Blend2DGUI.h:20
CMRC_DECLARE(DeepRTSAssets)
std::unordered_map< Constants::State, std::vector< std::tuple< int, int, bool > > > UnitStateData
Definition: Blend2DGUI.h:19
Definition: Blend2DGUI.h:105
const BLImage & get(int animationCounter, Constants::Direction direction, Constants::State state)
Definition: Blend2DGUI.h:117
Blend2DUnitState Up
Definition: Blend2DGUI.h:107
Blend2DUnitState Left
Definition: Blend2DGUI.h:108
Blend2DUnitState DownRight
Definition: Blend2DGUI.h:114
Blend2DUnitState Right
Definition: Blend2DGUI.h:110
Blend2DUnitState UpLeft
Definition: Blend2DGUI.h:111
Blend2DUnitState UpRight
Definition: Blend2DGUI.h:112
Blend2DUnitState DownLeft
Definition: Blend2DGUI.h:113
Blend2DUnitState Down
Definition: Blend2DGUI.h:109
Definition: BaseGUI.h:14
const Game & game
Definition: BaseGUI.h:17
Definition: Blend2DGUI.h:691
Blend2DArcher(const Color &color, int tileSize, int width, int height)
Definition: Blend2DGUI.h:693
Definition: Blend2DGUI.h:583
Blend2DBarracks(const Color &color, int tileSize, int width, int height)
Definition: Blend2DGUI.h:585
Definition: Blend2DGUI.h:229
Blend2DFarm(const Color &color, int tileSize, int width, int height)
Definition: Blend2DGUI.h:231
Definition: Blend2DGUI.h:467
Blend2DFootman(const Color &color, int tileSize, int width, int height)
Definition: Blend2DGUI.h:469
Definition: Blend2DGUI.h:988
Blend2DGUI(Game &game)
Definition: Blend2DGUI.cpp:62
void renderMap()
Definition: Blend2DGUI.cpp:49
Definition: Blend2DGUI.h:340
Blend2DPeasant(const Color &color, int tileSize, int width, int height)
Definition: Blend2DGUI.h:343
Definition: Blend2DGUI.h:337
Definition: Blend2DGUI.h:918
Blend2DTile(BLImage tile)
Definition: Blend2DGUI.h:923
BLImage tile
Definition: Blend2DGUI.h:928
Definition: Blend2DGUI.h:932
void load(BLImage &tileset)
Definition: Blend2DGUI.h:959
const BLImage & at(int index) const
Definition: Blend2DGUI.h:981
Blend2DTileset(int tileWidth, int tileHeight, const std::string &srcPath)
Definition: Blend2DGUI.h:939
Definition: Blend2DGUI.h:804
Blend2DTownHall(const Color &color, int tileSize, int width, int height)
Definition: Blend2DGUI.h:806
Definition: Blend2DGUI.h:40
void load(const BLImage &src, int tileSize, int width, int height, const UnitStateData &stateData)
Definition: Blend2DGUI.h:87
const BLImage & get(int animationCounter, Constants::State state)
Definition: Blend2DGUI.h:98
Definition: Blend2DGUI.h:141
Blend2DUnit(const Color &color, int tileSize, int width, int height, std::string path, UnitData data)
Definition: Blend2DGUI.h:152
void load()
Definition: Blend2DGUI.h:190
Definition: Blend2DGUI.h:24
static void blit(int x, int y, BLContext &ctx, const BLImage &src)
Definition: Blend2DGUI.h:33
static BLImage subImage(const BLImage &src, int x, int y, int w, int h, BLFormat format=BL_FORMAT_PRGB32)
Definition: Blend2DGUI.h:26
Definition: Building.h:11
Definition: Combat.h:11
Definition: Dead.h:11
Definition: Despawned.h:13
Definition: Game.h:23
Definition: Harvesting.h:13
Definition: Idle.h:11
Definition: Spawning.h:12
Definition: Tile.h:21
Definition: Walking.h:12
State
Definition: Constants.h:64
@ Harvesting
Definition: Constants.h:68
@ Despawned
Definition: Constants.h:67
@ Spawning
Definition: Constants.h:65
@ Idle
Definition: Constants.h:72
@ Combat
Definition: Constants.h:70
@ Walking
Definition: Constants.h:66
@ Building
Definition: Constants.h:69
@ Base
Definition: Constants.h:73
@ Dead
Definition: Constants.h:71
Direction
Definition: Constants.h:83
@ UpRight
Definition: Constants.h:91
@ Down
Definition: Constants.h:84
@ Up
Definition: Constants.h:85
@ DownLeft
Definition: Constants.h:88
@ DownRight
Definition: Constants.h:89
@ Right
Definition: Constants.h:87
@ UpLeft
Definition: Constants.h:90
@ Left
Definition: Constants.h:86