From c6a12066bffdaf09e0fb68551e9eaea995fdab49 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Sokolov" Date: Sat, 9 Feb 2019 12:47:15 +0100 Subject: [PATCH] map drawing --- doc/002.png | Bin 0 -> 3053 bytes tinyraycaster.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 doc/002.png diff --git a/doc/002.png b/doc/002.png new file mode 100644 index 0000000000000000000000000000000000000000..1812ba8c0e103ffb3817c1d9aecb288dd863f8a9 GIT binary patch literal 3053 zcmeH}ZA@EL7{{Ns&=ME{mC3RZifWUv=bn}ie$Yf$&=2N* zIJZ5y&-45LpXWR|Z@*Bah>czu4FIwE+vM8;`1q9%QQY#z%4a^qON2&NC<8d(7~|g` ziGQb*Zrff6@cL>1`Yiw-{)@f~@Tvr0LIsfB3XrI6yHt{cH-rZY6mme^)Bat@F@Tte ze7S7rp&L`y@6RXgTAuean^2{VXyWAw)wHy|-n5z@C2KHc3a*&c^kc9!rLO$Z#D@kW zGlpCfQ(p=^l9uOS1@4 zt}e#*8F4WZQeKD6J~eYFr`EU6SK}8=J7xt2yeO4PM6kFZ9xX@ zyRM_gAWFkbK-)ryOle(Wa}X@^vZrTnkgs?CaApC~aC60IoF*uRL?w#C67)R^hNn(Z zxe9$iS|WMg$w;SZtTwO)VX&TPp^x?lW_M3pwn)6vf= ziPlgC;y}0)tkOgKq{lUq+*r|lwDz>`w!ptUeoJ#V|56)c7-NIBi=-uUE#0hn^?#5 z-*Z_UC}Q560NkKE)7S+nDISwy8EfIHz@S12dd6#GMteFeF1NSG|M0m+Jn(#XV}N!& zOQ!cy+>&f|Z%#l8S{mnG%1h(IjdVhp@u1|Z$P4P9@D2Hi>byPG>iyMa*`<|bc!6|D zTGj?h`UXkX&b0LGjTza}r`Ji+vLzDpuStLW;FSvXi{&+c{y{hW(LtO6^7D%1pKn#w F{SMy6Qy>5U literal 0 HcmV?d00001 diff --git a/tinyraycaster.cpp b/tinyraycaster.cpp index 4d4e6d8..6d51bcd 100644 --- a/tinyraycaster.cpp +++ b/tinyraycaster.cpp @@ -29,11 +29,43 @@ void drop_ppm_image(const std::string filename, const std::vector &ima ofs.close(); } +void draw_rectangle(std::vector &img, const size_t img_w, const size_t img_h, const size_t x, const size_t y, const size_t w, const size_t h, const uint32_t color) { + assert(img.size()==img_w*img_h); + for (size_t i=0; i framebuffer(win_w*win_h, 255); // the image itself, initialized to white + const size_t map_w = 16; // map width + const size_t map_h = 16; // map height + const char map[] = "0000222222220000"\ + "1 0"\ + "1 11111 0"\ + "1 0 0"\ + "0 0 1110000"\ + "0 3 0"\ + "0 10000 0"\ + "0 0 11100 0"\ + "0 0 0 0"\ + "0 0 1 00000"\ + "0 1 0"\ + "2 1 0"\ + "0 0 0"\ + "0 0000000 0"\ + "0 0"\ + "0002222222200000"; // our game map + assert(sizeof(map) == map_w*map_h+1); // +1 for the null terminated string + for (size_t j = 0; j