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
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
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
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
{\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
\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
\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
\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
\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
\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
\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
\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
}\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
// 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