]> 4ch.mooo.com Git - 16.git/commitdiff
==== INITIAL LAYER MAP STUFF DONE, added mapdraw layer ontop of bg, going to implemen...
authorsparky4 <sparky4@cock.li>
Thu, 16 Feb 2017 02:11:11 +0000 (20:11 -0600)
committersparky4 <sparky4@cock.li>
Thu, 16 Feb 2017 02:11:11 +0000 (20:11 -0600)
src/lib/scroll16.c
src/lib/scroll16.h

index a78c99820637862235de9801504f1e15b919fedb..12d8991c2ba19698da06b2b0f3b41bd24b51613e 100755 (executable)
@@ -36,7 +36,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn)
                break;\r
                //right movement\r
                case 3:\r
-                       if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->ti.tw < pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->ti.tilemidposscreenx &&\r
+                       if(ZC_mapEdgeChk(pip, player[pn].enti.d, 0) && player[pn].enti.tx == pip[0].tx+pip[0].page->ti.tilemidposscreenx &&\r
                        !(pip[0].map->layerdata[0].data[(player[pn].enti.tx)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY))     //collision detection!\r
                        {\r
                                player[pn].walktype=2;\r
@@ -69,7 +69,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn)
                break;\r
                //left movement\r
                case 1:\r
-                       if(pip[0].tx > 0 && pip[0].tx+pip[0].page->ti.tw <= pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->ti.tilemidposscreenx &&\r
+                       if(ZC_mapEdgeChk(pip, player[pn].enti.d, 0) && player[pn].enti.tx == pip[0].tx+pip[0].page->ti.tilemidposscreenx &&\r
                        !(pip[0].map->layerdata[0].data[(player[pn].enti.tx-2)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY))   //collision detection!\r
                        {\r
                                player[pn].walktype=2;\r
@@ -102,7 +102,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn)
                break;\r
                //down movement\r
                case 4:\r
-                       if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->ti.th < pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->ti.tilemidposscreeny &&\r
+                       if(ZC_mapEdgeChk(pip, player[pn].enti.d, 0) && player[pn].enti.ty == pip[0].ty+pip[0].page->ti.tilemidposscreeny &&\r
                        !(pip[0].map->layerdata[0].data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY))     //collision detection!\r
                        {\r
                                player[pn].walktype=2;\r
@@ -135,7 +135,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn)
                break;\r
                //up movement\r
                case 0:\r
-                       if(pip[0].ty > 0 && pip[0].ty+pip[0].page->ti.th <= pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->ti.tilemidposscreeny &&\r
+                       if(ZC_mapEdgeChk(pip, player[pn].enti.d, 0) && player[pn].enti.ty == pip[0].ty+pip[0].page->ti.tilemidposscreeny &&\r
                        !(pip[0].map->layerdata[0].data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty-2))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY))   //collision detection!\r
                        {\r
                                player[pn].walktype=2;\r
@@ -178,7 +178,7 @@ void ZC_panPageManual(map_view_t *pip, player_t *player, word pn)
        {\r
                //right movement\r
                case 3:\r
-                       if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->ti.tw < pip[0].page->ti.tilesw)\r
+                       if(ZC_mapEdgeChk(pip, player[pn].enti.d, 1))\r
                        {\r
                                if(player[pn].enti.q<=player[pn].enti.spt)\r
                                {\r
@@ -191,7 +191,7 @@ void ZC_panPageManual(map_view_t *pip, player_t *player, word pn)
 \r
                //left movement\r
                case 1:\r
-                       if(pip[0].tx > 0 && pip[0].tx+pip[0].page->ti.tw <= pip[0].page->ti.tilesw)\r
+                       if(ZC_mapEdgeChk(pip, player[pn].enti.d, 1))\r
                        {\r
                                if(player[pn].enti.q<=player[pn].enti.spt)\r
                                {\r
@@ -204,7 +204,7 @@ void ZC_panPageManual(map_view_t *pip, player_t *player, word pn)
 \r
                //down movement\r
                case 4:\r
-                       if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->ti.th < pip[0].page->ti.tilesh)\r
+                       if(ZC_mapEdgeChk(pip, player[pn].enti.d, 1))\r
                        {\r
                                if(player[pn].enti.q<=player[pn].enti.spt)\r
                                {\r
@@ -217,7 +217,7 @@ void ZC_panPageManual(map_view_t *pip, player_t *player, word pn)
 \r
                //up movement\r
                case 0:\r
-                       if(pip[0].ty > 0 && pip[0].ty+pip[0].page->ti.th <= pip[0].page->ti.tilesh)\r
+                       if(ZC_mapEdgeChk(pip, player[pn].enti.d, 1))\r
                        {\r
                                if(player[pn].enti.q<=player[pn].enti.spt)\r
                                {\r
@@ -338,7 +338,7 @@ void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid)
 \r
        /* draw the next column */\r
        x= mv[0].page->sw + mv[0].map->tiles->tileWidth;\r
-       if(mv[0].tx >= 0 && mv[0].tx+mv[0].page->ti.tw < mv[0].map->width)\r
+       if(ZC_mapEdgeChk(mv, player[plid].enti.d, 0))\r
 #ifndef FULLRCREND\r
        if(player[plid].enti.q%4)\r
 #else\r
@@ -361,7 +361,7 @@ void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
 \r
        /* draw the next column */\r
        x= 0;\r
-       if(mv[0].tx > 0 && mv[0].tx+mv[0].page->ti.tw <= mv[0].map->width)\r
+       if(ZC_mapEdgeChk(mv, player[plid].enti.d, 0))\r
 #ifndef FULLRCREND\r
        if(player[plid].enti.q%4)\r
 #else\r
@@ -384,7 +384,7 @@ void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid)
 \r
        /* draw the next row */\r
        y= 0;\r
-       if(mv[0].ty > 0 && mv[0].ty+mv[0].page->ti.th <= mv[0].map->height)\r
+       if(ZC_mapEdgeChk(mv, player[plid].enti.d, 0))\r
 #ifndef FULLRCREND\r
        if(player[plid].enti.q%3)\r
 #else\r
@@ -407,7 +407,7 @@ void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid)
 \r
        /* draw the next row */\r
        y= mv[0].page->sh + mv[0].map->tiles->tileHeight;\r
-       if(mv[0].ty >= 0 && mv[0].ty+mv[0].page->ti.th < mv[0].map->height)\r
+       if(ZC_mapEdgeChk(mv, player[plid].enti.d, 0))\r
 #ifndef FULLRCREND\r
        if(player[plid].enti.q%3)\r
 #else\r
@@ -877,6 +877,10 @@ void player_walk(player_t *player, map_view_t *map_v){
        }\r
 }\r
 \r
+/*\r
+ *     end\r
+ */\r
+\r
 void mapScroll(map_view_t *mv, player_t *player)\r
 {\r
        //word x, y;  /* coordinate for drawing */\r
index cefda677b307f10672bf6a5dd84aedfd5c68d33d..45105a2741bb95d4a657a154dfbffaefd63a3e63 100755 (executable)
@@ -199,6 +199,51 @@ boolean ZC_walk2(entity_t *ent, map_view_t *map_v);
 // Move player around and call map scrolling if required/possible\r
 void walk_player(player_t *player, map_view_t *map_v);\r
 \r
+//check map edge\r
+inline boolean ZC_mapEdgeChk(map_view_t *map_v, nibble dir, boolean pansw)\r
+{\r
+       int     w,h;\r
+\r
+       switch (pansw)\r
+       {\r
+               case 0:\r
+                       w = map_v[0].map->width;\r
+                       h = map_v[0].map->height;\r
+               break;\r
+               case 1:\r
+                       w = map_v[0].page->ti.tilesw;\r
+                       h = map_v[0].page->ti.tilesh;\r
+               break;\r
+       }\r
+\r
+       switch(dir)\r
+       {\r
+               //no direction\r
+               default:\r
+               case 2:\r
+                       //0000pip[0].video->startclk = (*clockw);\r
+                       return false;\r
+               break;\r
+               //right movement\r
+               case 3:\r
+                       if(map_v[0].tx >= 0 && map_v[0].tx+map_v[0].page->ti.tw < w) return true;\r
+               break;\r
+               //left movement\r
+               case 1:\r
+                       if(map_v[0].tx > 0 && map_v[0].tx+map_v[0].page->ti.tw <= w) return true;\r
+               break;\r
+               //down movement\r
+               case 4:\r
+                       if(map_v[0].ty >= 0 && map_v[0].ty+map_v[0].page->ti.th < h) return true;\r
+               break;\r
+               //up movement\r
+               case 0:\r
+                       if(map_v[0].ty > 0 && map_v[0].ty+map_v[0].page->ti.th <= h) return true;\r
+               break;\r
+       }\r
+       return false;\r
+}\r
+\r
 // Scroll map in one direction (assumed from player's movement)\r
 void mapScroll(map_view_t *mv, player_t *player);\r
 \r