diff --git a/assets-cg/levels/tilesetEGA64_CG.png b/assets-cg/levels/tilesetEGA64_CG.png
old mode 100644
new mode 100755
index 5fd8503..f27561c
Binary files a/assets-cg/levels/tilesetEGA64_CG.png and b/assets-cg/levels/tilesetEGA64_CG.png differ
diff --git a/assets-cg/levels/tilesetEGA64_CG_bak.png b/assets-cg/levels/tilesetEGA64_CG_bak.png
new file mode 100644
index 0000000..5fd8503
Binary files /dev/null and b/assets-cg/levels/tilesetEGA64_CG_bak.png differ
diff --git a/assets/level0.tmx b/assets/level0.tmx
index 0671ef7..1d0e971 100644
--- a/assets/level0.tmx
+++ b/assets/level0.tmx
@@ -7,68 +7,68 @@
-257,297,298,299,300,257,386,297,298,299,300,2,2,2,2,2,257,337,338,225,226,227,228,201,202,203,204,273,274,275,276,249,250,251,252,297,298,299,93,94,2,345,346,347,348,2,337,338,
-253,205,229,205,229,280,179,180,179,156,156,156,158,157,179,180,253,361,362,249,250,251,252,225,226,227,228,297,298,299,300,273,274,275,276,25,26,27,117,118,28,369,370,371,372,2,361,362,
-301,125,126,127,128,2,385,303,350,351,303,2,2,2,350,351,301,2,386,273,274,275,276,249,250,251,252,201,202,203,204,297,298,299,300,49,9,10,134,135,52,393,394,395,396,337,338,2,
-325,149,150,151,152,2,2,327,374,375,327,2,184,185,374,375,325,387,279,297,298,299,300,273,274,275,276,225,226,227,228,2,2,2,2,73,33,34,74,219,76,2,2,2,2,361,362,2,
-257,2,2,385,2,2,385,2,265,266,2,2,208,209,352,353,257,2,302,2,130,129,166,297,298,299,300,249,250,251,252,25,26,27,27,97,98,99,98,99,100,26,26,27,28,131,201,202,
-281,176,2,2,278,2,2,385,289,290,2,2,232,233,376,377,281,2,326,2,154,153,190,201,202,203,204,273,274,275,276,49,356,357,2,121,59,60,60,61,124,2,354,355,52,132,225,226,
-201,202,203,204,302,385,2,2,265,266,2,385,2,2,2,2,2,2,2,2,2,2,166,225,226,227,228,297,298,299,300,73,380,381,2,145,83,84,84,85,148,2,378,379,76,132,249,250,
-225,226,227,228,326,2,385,2,265,266,2,2,2,2,214,215,2,2,2,2,2,2,190,249,250,251,252,2,2,385,2,49,404,405,2,169,107,108,108,109,172,2,402,403,76,132,273,274,
-249,250,251,252,201,202,203,204,289,290,2,258,259,260,238,239,260,260,261,262,262,263,264,273,274,275,276,2,93,94,385,49,134,135,2,2,166,2,2,166,2,2,134,135,52,132,297,298,
-273,274,275,276,225,226,227,228,265,266,2,282,283,284,285,285,285,285,285,285,286,287,288,297,298,299,300,2,117,118,2,73,373,2,217,2,190,373,373,190,2,219,2,373,76,132,201,203,
-297,298,299,300,249,250,251,252,290,2,2,306,307,308,309,308,309,308,309,310,310,311,312,131,2,339,340,2,134,135,2,97,98,99,99,98,99,2,2,98,98,99,98,99,100,132,225,227,
-202,203,204,386,273,274,275,276,2,2,2,330,331,332,333,332,333,332,333,334,334,335,336,132,2,363,364,2,2,2,2,121,122,122,122,123,124,81,82,121,122,123,122,123,124,132,249,251,
-226,227,228,386,297,298,299,300,2,290,2,162,163,164,165,162,163,164,165,162,163,164,165,132,2,201,202,203,204,2,2,145,146,146,146,147,148,57,58,145,146,147,146,147,148,132,273,275,
-250,251,252,2,2,2,2,2,2,2,2,86,87,88,89,186,187,188,189,86,87,88,89,132,385,225,226,227,228,2,2,169,170,170,170,171,172,81,82,169,170,171,14,15,27,26,27,27,
-274,275,276,2,270,271,271,271,272,2,2,110,111,112,113,210,211,212,213,110,111,112,113,133,2,249,250,251,252,2,2,303,2,2,2,136,137,290,265,265,266,266,38,39,2,2,2,51,
-298,299,300,2,294,1,1,1,296,2,2,136,137,2,2,234,290,265,237,2,2,2,339,340,385,273,274,275,276,2,2,327,2,2,2,160,161,386,266,289,290,265,62,63,73,74,75,75,
-202,203,204,2,294,1,1,1,296,2,2,160,161,265,266,266,265,266,290,2,2,2,363,364,2,297,298,299,300,2,2,2,2,2,2,2,2,266,290,2,2,2,398,399,97,98,99,99,
-226,227,228,2,318,319,319,319,320,2,386,266,266,289,290,265,266,241,265,266,266,265,266,241,385,2,2,2,241,265,266,266,265,386,265,266,266,265,266,2,2,2,206,207,121,122,123,123,
-250,251,252,2,2,2,2,2,2,385,289,290,386,265,265,2,2,241,289,290,265,266,290,266,265,266,266,386,266,289,290,265,266,290,289,385,265,266,290,2,2,2,230,231,145,146,147,147,
-274,275,276,201,202,203,204,257,2,2,2,257,2,265,386,2,257,2,2,2,257,2,241,241,289,290,265,266,290,241,2,2,2,2,2,2,21,22,23,24,2,2,254,255,169,170,171,171,
-298,299,300,225,226,227,228,253,205,229,205,253,2,290,265,2,253,205,229,205,253,201,202,203,204,2,2,2,2,2,2,2,2,2,2,2,45,46,47,48,2,2,2,2,2,201,202,203,
-2,2,386,249,250,251,252,345,346,347,348,277,2,265,266,2,301,386,2,2,2,225,226,227,228,2,2,2,2,2,2,2,2,2,339,340,69,70,71,72,387,201,202,203,204,225,226,227,
-202,203,204,273,274,275,276,369,370,371,372,301,2,289,290,2,325,387,201,202,204,249,250,251,252,201,203,204,2,2,2,2,387,2,363,364,2,2,2,2,2,225,226,227,228,249,250,251,
-226,227,228,297,298,299,300,393,394,395,396,325,2,265,266,2,301,386,225,226,228,273,274,275,276,225,227,228,201,202,203,204,201,202,203,204,387,201,202,203,204,249,250,251,252,273,274,275
+2,297,298,299,300,2,386,297,298,299,300,2,2,2,2,2,2,337,338,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,297,298,299,2,2,2,345,346,347,348,2,337,338,
+253,205,229,205,229,280,179,180,179,156,156,156,158,157,179,180,253,361,362,2,2,2,2,2,2,2,2,297,298,299,300,2,2,2,2,25,26,27,117,118,28,369,370,371,372,2,361,362,
+301,2,2,2,2,2,385,2,2,2,2,2,2,2,2,2,301,2,386,2,2,2,2,2,2,2,2,2,2,2,2,297,298,299,300,49,9,10,134,135,52,393,394,395,396,337,338,2,
+325,149,150,151,152,2,2,327,374,375,327,2,2,185,374,375,325,387,2,297,298,299,300,2,2,2,2,2,2,2,2,2,2,2,2,73,33,34,74,219,76,2,2,2,2,361,362,2,
+257,2,2,385,2,2,385,2,265,266,2,2,208,209,352,353,257,2,2,2,2,2,2,297,298,299,300,2,2,2,2,25,26,27,27,97,98,99,98,99,100,26,26,27,28,131,2,2,
+281,176,2,2,2,2,2,385,289,290,2,2,232,233,376,377,281,2,326,2,154,153,190,2,2,2,2,2,2,2,2,49,2,2,2,121,59,60,60,61,124,2,2,2,52,132,2,2,
+2,2,2,2,2,385,2,2,265,266,2,385,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,297,298,299,300,73,2,2,2,145,83,84,84,85,148,2,2,2,76,132,2,2,
+2,2,2,2,326,2,385,2,265,266,2,2,2,2,214,215,2,2,2,2,2,2,190,2,2,2,2,2,2,385,2,49,404,405,2,169,107,108,108,109,172,2,402,403,76,132,2,2,
+2,2,2,2,2,2,2,2,289,290,2,258,259,260,238,239,260,260,261,262,262,263,264,2,2,2,2,2,2,2,385,49,134,135,2,2,2,2,2,2,2,2,134,135,52,132,297,298,
+2,2,2,2,2,2,2,2,265,266,2,282,283,284,285,285,285,285,285,285,286,287,288,297,298,299,300,2,117,118,2,73,373,2,217,2,190,373,373,190,2,219,2,373,76,132,2,2,
+297,298,299,300,2,2,2,2,290,2,2,306,307,308,309,308,309,308,309,310,310,311,312,131,2,339,340,2,134,135,2,97,98,99,99,98,99,2,2,98,98,99,98,99,100,132,2,2,
+2,2,2,386,2,2,2,2,2,2,2,330,331,332,333,332,333,332,333,334,334,335,336,132,2,363,364,2,2,2,2,121,122,122,122,123,124,81,82,121,122,123,122,123,124,132,2,2,
+2,2,2,386,297,298,299,300,2,290,2,162,163,164,165,162,163,164,165,162,163,164,165,132,2,2,2,2,2,2,2,145,146,146,146,147,148,57,58,145,146,147,146,147,148,132,2,2,
+2,2,2,2,2,2,2,2,2,2,2,86,87,88,89,186,187,188,189,86,87,88,89,132,385,2,2,2,2,2,2,169,170,170,170,171,172,81,82,169,170,171,14,15,27,26,27,27,
+2,2,2,2,270,271,271,271,272,2,2,110,111,112,113,210,211,212,213,110,111,112,113,133,2,2,2,2,2,2,2,2,2,2,2,2,2,290,265,265,266,266,38,39,2,2,2,51,
+298,299,300,2,294,1,1,1,296,2,2,2,2,2,2,234,290,265,237,2,2,2,339,340,385,2,2,2,2,2,2,327,2,2,2,160,161,386,266,289,290,265,62,63,73,74,75,75,
+2,2,2,2,294,1,1,1,296,2,2,160,161,265,266,266,265,266,290,2,2,2,363,364,2,297,298,299,300,2,2,2,2,2,2,2,2,266,290,2,2,2,2,2,97,98,99,99,
+2,2,2,2,318,319,319,319,320,2,386,266,266,289,290,265,266,241,265,266,266,265,266,241,385,2,2,2,241,265,266,266,265,386,265,266,266,265,266,2,2,2,2,2,121,122,123,123,
+2,2,2,2,2,2,2,2,2,385,289,290,386,265,265,2,2,241,289,290,265,266,290,266,265,266,266,386,266,289,290,265,266,290,289,385,265,266,290,2,2,2,2,2,145,146,147,147,
+2,2,2,2,2,2,2,2,2,2,2,2,2,265,386,2,2,2,2,2,2,2,241,241,289,290,265,266,290,241,2,2,2,2,2,2,21,22,23,24,2,2,254,255,169,170,171,171,
+298,299,300,2,2,2,2,253,205,229,205,253,2,290,265,2,253,205,229,205,253,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,45,46,47,48,2,2,2,2,2,2,2,2,
+2,2,386,2,2,2,2,345,346,347,348,277,2,265,266,2,301,386,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,339,340,69,70,71,72,387,2,2,2,2,2,2,2,
+2,2,2,2,2,2,2,369,370,371,372,301,2,289,290,2,325,387,2,2,2,2,2,2,2,2,2,2,2,2,2,2,387,2,363,364,2,2,2,2,2,2,2,2,2,2,2,2,
+2,2,2,297,298,299,300,393,394,395,396,325,2,265,266,2,301,386,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,387,2,2,2,2,2,2,2,2,2,2,2
-
+
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+257,0,0,0,0,257,0,0,0,0,0,0,0,0,0,0,257,0,0,225,226,227,228,201,202,203,204,273,274,275,276,249,250,251,252,0,0,0,93,94,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,249,250,251,252,225,226,227,228,0,0,0,0,273,274,275,276,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,125,126,127,128,0,0,303,350,351,303,0,0,0,350,351,0,0,0,273,274,275,276,249,250,251,252,201,202,203,204,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,273,274,275,276,225,226,227,228,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,302,0,130,129,166,0,0,0,0,249,250,251,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,201,202,
+0,0,0,0,278,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,201,202,203,204,273,274,275,276,0,356,357,0,0,0,0,0,0,0,0,354,355,0,0,225,226,
+201,202,203,204,302,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,166,225,226,227,228,0,0,0,0,0,380,381,0,0,0,0,0,0,0,0,378,379,0,0,249,250,
+225,226,227,228,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,249,250,251,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,273,274,
+249,250,251,252,201,202,203,204,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,273,274,275,276,0,93,94,0,0,0,0,0,0,166,0,0,166,0,0,0,0,0,0,0,0,
+273,274,275,276,225,226,227,228,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,201,203,
+0,0,0,0,249,250,251,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,225,227,
+202,203,204,0,273,274,275,276,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,249,251,
+226,227,228,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,201,202,203,204,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,273,275,
+250,251,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,225,226,227,228,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+274,275,276,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,249,250,251,252,0,0,303,0,0,0,136,137,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,136,137,0,0,0,0,0,0,0,0,0,0,0,0,273,274,275,276,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+202,203,204,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,398,399,0,0,0,0,
+226,227,228,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,206,207,0,0,0,0,
+250,251,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,230,231,0,0,0,0,
+274,275,276,201,202,203,204,257,0,0,0,257,0,0,0,0,257,0,0,0,257,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,225,226,227,228,0,0,0,0,0,0,0,0,0,0,0,0,0,0,201,202,203,204,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,201,202,203,
+0,0,0,249,250,251,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,225,226,227,228,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,201,202,203,204,225,226,227,
+202,203,204,273,274,275,276,0,0,0,0,0,0,0,0,0,0,0,201,202,204,249,250,251,252,201,203,204,0,0,0,0,0,0,0,0,0,0,0,0,0,225,226,227,228,249,250,251,
+226,227,228,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,225,226,228,273,274,275,276,225,227,228,201,202,203,204,201,202,203,204,0,201,202,203,204,249,250,251,252,273,274,275
-
+
-410,0,410,410,0,410,0,0,410,410,0,0,0,0,0,0,410,410,410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,410,0,0,0,410,410,410,410,0,410,410,
+0,0,410,410,0,0,0,0,410,410,0,0,0,0,0,0,0,410,410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,410,0,0,0,410,410,410,410,0,410,410,
410,410,410,410,410,410,410,410,410,410,410,410,0,0,410,410,410,410,410,0,0,0,0,0,0,0,0,0,410,410,0,0,0,0,0,410,410,410,410,410,410,410,410,410,410,0,410,410,
-410,0,0,0,0,0,0,0,0,0,0,0,0,0,410,410,410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,410,0,410,0,0,0,0,410,410,410,410,410,410,410,0,
+410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,410,0,410,0,0,0,0,410,410,410,410,410,410,410,0,
410,410,410,410,410,0,0,410,410,410,410,0,0,0,410,410,410,410,0,0,410,410,0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0,0,0,410,0,0,0,0,410,410,0,
-410,0,0,0,0,0,0,0,0,0,0,0,410,0,411,411,0,0,0,0,0,0,0,0,410,410,0,0,0,0,0,410,410,410,410,410,410,410,410,410,410,410,410,410,410,0,0,0,
-410,0,0,0,0,0,0,0,0,0,0,0,0,0,411,411,0,0,410,0,410,410,410,0,0,0,0,0,0,0,0,410,0,0,0,410,410,410,410,410,410,0,0,0,410,0,0,0,
+410,0,0,0,0,0,0,0,0,0,0,0,410,411,411,411,410,0,0,0,0,0,0,0,410,410,0,0,0,0,0,410,410,410,410,410,410,410,410,410,410,410,410,410,410,0,0,0,
+410,0,0,0,0,0,0,0,0,0,0,0,411,411,411,411,410,0,410,0,410,410,410,0,0,0,0,0,0,0,0,410,0,0,0,410,410,410,410,410,410,0,0,0,410,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,410,0,410,0,0,0,410,410,410,410,410,410,0,0,0,410,0,0,0,
0,0,0,0,410,0,0,0,0,0,0,0,0,0,410,410,0,0,0,0,0,0,410,0,0,0,0,0,0,0,0,410,410,410,0,410,410,0,0,410,410,0,410,410,410,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,410,410,410,410,410,410,410,410,410,410,410,410,0,0,0,0,0,0,0,0,410,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0,410,
@@ -82,7 +82,7 @@
0,0,0,0,412,412,412,412,412,0,0,410,410,0,0,0,0,0,0,0,0,0,410,410,0,0,410,410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,410,410,410,
0,0,0,0,412,412,412,412,412,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,410,410,410,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,410,410,410,
-0,0,0,0,0,0,0,410,0,0,0,410,0,0,0,0,410,0,0,0,410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,410,410,410,0,0,410,410,410,410,410,410,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,410,410,410,0,0,410,410,410,410,410,410,
410,410,0,0,0,0,0,410,410,410,410,410,0,0,0,0,410,410,410,410,410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,410,410,410,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,410,410,410,410,410,0,0,0,0,410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,410,410,410,410,410,410,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,410,410,410,410,410,0,0,0,0,410,410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,410,410,0,0,0,0,0,0,0,0,0,0,0,0,
diff --git a/assets/level0_bak2.tmx b/assets/level0_bak2.tmx
new file mode 100644
index 0000000..0671ef7
--- /dev/null
+++ b/assets/level0_bak2.tmx
@@ -0,0 +1,92 @@
+
+
diff --git a/src/game.c b/src/game.c
index 4bf871b..eb9df60 100644
--- a/src/game.c
+++ b/src/game.c
@@ -12,8 +12,9 @@ void game_logic(Game *game) {
void draw(Game *game) {
/* Draw everything. */
- render_map(&game->player, game->map_level);
+ render_map_by_layer(&game->player, game->map_level, BACKGROUND);
player_draw(&game->player);
+ render_map_by_layer(&game->player, game->map_level, FOREGROUND);
}
/* Key management */
diff --git a/src/map.c b/src/map.c
index 6b96976..e80fe10 100644
--- a/src/map.c
+++ b/src/map.c
@@ -93,6 +93,99 @@ void render_map(Player *player, Map *map_level) {
}
}
+void render_map_by_layer(Player *player, Map *map_level, int layer) {
+ /* for all Layer (2 in the current configuration: Background is layer 0 and
+ * foreground is layer 1 ) */
+ /* x and y will contain the position in the loop. */
+ unsigned char x, y;
+ /* The positions where we start drawing the tiles will be in tx and
+ * ty. */
+ unsigned short int tx, ty;
+ /* mx and my will contain how many pixels will be hidden on x and on
+ * y. */
+ unsigned char mx, my;
+ /* dw and dh contain the amount of tiles that will be drawn on x and on
+ * y. */
+ unsigned char dw = DWIDTH/T_WIDTH+2, dh = DHEIGHT/T_HEIGHT+1;
+ /* mw and mh will contain the height and the width of the map. */
+ unsigned short int mw = map_level->w*T_WIDTH, mh = map_level->h*T_HEIGHT;
+ /* tile contains the tile to draw. */
+ short int tile;
+ /* The position where I start drawing */
+ unsigned short int sx, sy;
+ /* The position of the tile in the tileset. */
+ unsigned short int xtile, ytile;
+ /* The layer we're drawing */
+ unsigned char l;
+ /* Fix sx. */
+ if(player->xpx = player->x;
+ sx = 0;
+ }else if(player->x+DWIDTH/2>mw){
+ /* If I can't center the player because I'm near the right border of
+ * the map. */
+ sx = mw-DWIDTH;
+ player->px = player->x-sx;
+ }else{
+ /* I can center the player. */
+ player->px = DWIDTH/2;
+ sx = player->x-player->px;
+ }
+ /* Fix sy. */
+ if(player->ypy = player->y;
+ sy = 0;
+ }else if(player->y+DHEIGHT/2>mh){
+ /* If I can't center the player because I'm near the bottom border
+ * of the map. */
+ sy = mh-DHEIGHT;
+ player->py = player->y-sy;
+ }else{
+ /* I can center the player. */
+ player->py = DHEIGHT/2;
+ sy = player->y-player->py;
+ }
+ tx = sx/T_WIDTH;
+ ty = sy/T_HEIGHT;
+ mx = sx-tx*T_WIDTH;
+ my = sy-ty*T_HEIGHT;
+
+
+ /* Draw a layer of the map on screen. */
+ for(y=0;y=0 && tx+x < map_level->w &&
+ ty+y>=0 && ty+y < map_level->h){
+ /* index of the current tile */
+ int currentIndex = (y+ty) * map_level->w + tx+x;
+ /* we get the ID of the tile in the current drawable layers
+ */
+ tile = map_level->layers[layer][currentIndex];
+
+ /* tile == -1 means nothing to be drawn */
+ if(tile >= 0){
+ /* get x and y position in the tileset image */
+ xtile = (tile % map_level->tileset_size) * T_WIDTH;
+ ytile = (tile / map_level->tileset_size) * T_HEIGHT;
+ /* render */
+ dsubimage(x*T_WIDTH-mx, y*T_HEIGHT-my,
+ map_level->tileset, xtile, ytile, T_WIDTH,
+ T_HEIGHT, DIMAGE_NONE);
+ }
+ }
+ }
+ }
+}
+
+
+
+
short int get_tile(Map *map_level, int x, int y, int l) {
/* Get the tile at (x, y) on layer l. Returns the tile ID or MAP_OUTSIDE if
* she's not found. */
diff --git a/src/map.h b/src/map.h
index cdea3e4..be18c01 100644
--- a/src/map.h
+++ b/src/map.h
@@ -16,6 +16,9 @@
#define PXSIZE 1
#endif
+#define BACKGROUND 0
+#define FOREGROUND 1
+
#define MAP_OUTSIDE -2 /* Returned by get_tile_at_pos if the point is outside of
* the map. */
@@ -25,6 +28,9 @@
/* Draws the map map on the entire screen to be viewed by the player player. */
void render_map(Player *player, Map *map_level);
+/* Draws the map layer on the entire screen to be viewed by the player player. */
+void render_map_by_layer(Player *player, Map *map_level, int layer);
+
/* Get the tile at (x, y) of the map map. If the tile is located outside of the
* screen, MAP_OUTSIDE is returned. */
short int get_tile(Map *map_level, int x, int y, int l);