void mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y);\r
void mapDrawRow(map_view_t *mv, int tx, int ty, word y);\r
void mapDrawCol(map_view_t *mv, int tx, int ty, word x);
-void animatePlayer(map_view_t *mv, short d1, short d2, int x, int y, int ls, bitmap_t *bmp);\r
+void animatePlayer(map_view_t *mv, map_view_t *src, short d1, short d2, int x, int y, int ls, bitmap_t *bmp);\r
\r
#define TILEWH 16\r
#define QUADWH (TILEWH/4)
screen = modexDefaultPage();\r
screen.width += (TILEWH*2);\r
mv.page = &screen;\r
- screen2=modexNextPage(mv.page);\r
+ screen2 = modexNextPage(mv.page);
+ screen2.width += (TILEWH*2);\r
mv2.page = &screen2;\r
- modexShowPage(mv.page);\r
+ //modexShowPage(mv.page);\r
\r
/* set up paging */\r
draw = &mv;\r
spri = &mv2;\r
-// draw = &mv;
//TODO: LOAD map data and position the map in the middle of the screen if smaller then screen
mapGoTo(draw, 0, 0);
player.ty = draw->ty + 8;
player.x = player.tx*TILEWH;
player.y = player.ty*TILEWH;
- modexDrawSpriteRegion(draw->page, player.x-4, player.y-TILEWH, 24, 64, 24, 32, &ptmp);
-
- modexShowPage(draw->page);\r
+ modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 64, 24, 32, &ptmp);
+ modexCopyPageRegion(spri->page, draw->page, player.x-4, player.y-TILEWH, player.x-4, player.y-TILEWH, 24, 34);
+ modexShowPage(spri->page);\r
while(!keyp(1))
{\r
//top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square\r
//TODO: render the player properly with animation and sprite sheet
if(keyp(77))
{
- modexDrawSpriteRegion(draw->page, player.x-4, player.y-TILEWH, 24, 32, 24, 32, &ptmp);
+ modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 32, 24, 32, &ptmp);
if(draw->tx >= 0 && draw->tx+20 < MAPX && player.tx == draw->tx + 10)
{
for(q=0; q<(TILEWH/SPEED); q++)
- {\r
-// modexDrawBmp(draw->page, &bmp);
- animatePlayer(draw, 1, 1, player.x, player.y, q, &ptmp);
+ {
+ animatePlayer(spri, draw, 1, 1, player.x, player.y, q, &ptmp);
mapScrollRight(draw, SPEED);
- modexShowPage(draw->page);\r
-// mapScrollRight(show, SPEED);\r
-// SWAP(draw, show);\r
+ modexShowPage(spri->page);
}
player.tx++;
}
for(q=0; q<(TILEWH/SPEED); q++)
{
player.x+=SPEED;
-// modexDrawBmp(draw->page, player.x, player.y, &bmp);
- animatePlayer(draw, 1, 0, player.x, player.y, q, &ptmp);
- modexShowPage(draw->page);
-// SWAP(draw, show);
+ animatePlayer(spri, draw, 1, 0, player.x, player.y, q, &ptmp);
+ modexShowPage(spri->page);
}
player.tx++;
}\r
\r
if(keyp(75))
{
- modexDrawSpriteRegion(draw->page, player.x-4, player.y-TILEWH, 24, 96, 24, 32, &ptmp);
+ modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 96, 24, 32, &ptmp);
if(draw->tx > 0 && draw->tx+20 <= MAPX && player.tx == draw->tx + 10)
{
for(q=0; q<(TILEWH/SPEED); q++)
{
-// modexDrawBmp(draw->page, player.x-((q+1)*SPEED), player.y, &bmp);
- animatePlayer(draw, 3, 1, player.x, player.y, q, &ptmp);
+
+ animatePlayer(spri, draw, 3, 1, player.x, player.y, q, &ptmp);
mapScrollLeft(draw, SPEED);
- modexShowPage(draw->page);\r
-// mapScrollLeft(show, SPEED);\r
-// SWAP(draw, show);\r
+ modexShowPage(spri->page);
}
player.tx--;\r
}
for(q=0; q<(TILEWH/SPEED); q++)
{
player.x-=SPEED;
-// modexDrawBmp(draw->page, player.x, player.y, &bmp);
- animatePlayer(draw, 3, 0, player.x, player.y, q, &ptmp);
- modexShowPage(draw->page);
-// SWAP(draw, show);
+ animatePlayer(spri, draw, 3, 0, player.x, player.y, q, &ptmp);
+ modexShowPage(spri->page);
}
player.tx--;
}
\r
if(keyp(80))
{
- modexDrawSpriteRegion(draw->page, player.x-4, player.y-TILEWH, 24, 64, 24, 32, &ptmp);
+ modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 64, 24, 32, &ptmp);
if(draw->ty >= 0 && draw->ty+15 < MAPY && player.ty == draw->ty + 8)
{\r
for(q=0; q<(TILEWH/SPEED); q++)
{
-// modexDrawBmp(draw->page, player.x, player.y+((q+1)*SPEED), &bmp);
- animatePlayer(draw, 2, 1, player.x, player.y, q, &ptmp);
+ animatePlayer(spri, draw, 2, 1, player.x, player.y, q, &ptmp);
mapScrollDown(draw, SPEED);
- modexShowPage(draw->page);\r
-// mapScrollDown(show, SPEED);\r
-// SWAP(draw, show);\r
+ modexShowPage(spri->page);
}
player.ty++;
}
for(q=0; q<(TILEWH/SPEED); q++)
{
player.y+=SPEED;
-// modexDrawBmp(draw->page, player.x, player.y, &bmp);
- animatePlayer(draw, 2, 0, player.x, player.y, q, &ptmp);
- modexShowPage(draw->page);
-// SWAP(draw, show);
+ animatePlayer(spri, draw, 2, 0, player.x, player.y, q, &ptmp);
+ modexShowPage(spri->page);
}
player.ty++;
}\r
\r
if(keyp(72))
{
- modexDrawSpriteRegion(draw->page, player.x-4, player.y-TILEWH, 24, 0, 24, 32, &ptmp);
+ modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 0, 24, 32, &ptmp);
if(draw->ty > 0 && draw->ty+15 <= MAPY && player.ty == draw->ty + 8)
{\r
for(q=0; q<(TILEWH/SPEED); q++)
- {\r
-// modexDrawBmp(draw->page, player.x, player.y-((q+1)*SPEED), &bmp);
- animatePlayer(draw, 0, 1, player.x, player.y, q, &ptmp);
+ {
+ animatePlayer(spri, draw, 0, 1, player.x, player.y, q, &ptmp);
mapScrollUp(draw, SPEED);
- modexShowPage(draw->page);
-// mapScrollUp(show, SPEED);\r
-// SWAP(draw, show);\r
+ mapScrollUp(spri, SPEED);
+ modexShowPage(spri->page);
}
player.ty--;
}
for(q=0; q<(TILEWH/SPEED); q++)
{
player.y-=SPEED;
-// modexDrawBmp(draw->page, player.x, player.y, &bmp);
- animatePlayer(draw, 0, 0, player.x, player.y, q, &ptmp);
- modexShowPage(draw->page);
-// SWAP(draw, show);
+ animatePlayer(spri, draw, 0, 0, player.x, player.y, q, &ptmp);
+ modexShowPage(spri->page);
}
player.ty--;
}\r
- }\r
+ }
+
}\r
modexLeave();\r
}\r
}\r
-void animatePlayer(map_view_t *mv, short d1, short d2, int x, int y, int ls, bitmap_t *bmp)
+void animatePlayer(map_view_t *mv, map_view_t *src, short d1, short d2, int x, int y, int ls, bitmap_t *bmp)
{
int qq;
{
case 0:
//up
- //if(ls==0) modexClearPlayer(mv->page, x-4, y-qq-TILEWH, 24, 32);
- if(ls<1) { modexClearPlayer(mv->page, x-4, y-qq-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-4, y-qq-TILEWH, 24, 0, 24, 32, bmp); }
- if(4>ls && ls>=1) { modexClearPlayer(mv->page, x-4, y-qq-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-4, y-qq-TILEWH, 48, 0, 24, 32, bmp); }
- if(7>ls && ls>=4) { modexClearPlayer(mv->page, x-4, y-qq-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-4, y-qq-TILEWH, 0, 0, 24, 32, bmp); }
- if(ls>=7) { modexClearPlayer(mv->page, x-4, y-qq-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-4, y-qq-TILEWH, 24, 0, 24, 32, bmp); }
+ if(ls<1) { modexCopyPageRegion(mv->page, src->page, x-4, y-qq-TILEWH, x-4, y-qq-TILEWH, 24, 34);
+ modexDrawSpriteRegion(mv->page, x-4, y-qq-TILEWH, 24, 0, 24, 32, bmp); }
+ if(4>ls && ls>=1) { modexCopyPageRegion(mv->page, src->page, x-4, y-qq-TILEWH, x-4, y-qq-TILEWH, 24, 34);
+ modexDrawSpriteRegion(mv->page, x-4, y-qq-TILEWH, 48, 0, 24, 32, bmp); }
+ if(7>ls && ls>=4) { modexCopyPageRegion(mv->page, src->page, x-4, y-qq-TILEWH, x-4, y-qq-TILEWH, 24, 34);
+ modexDrawSpriteRegion(mv->page, x-4, y-qq-TILEWH, 0, 0, 24, 32, bmp); }
+ if(ls>=7) { modexCopyPageRegion(mv->page, src->page, x-4, y-qq-TILEWH, x-4, y-qq-TILEWH, 24, 34);
+ modexDrawSpriteRegion(mv->page, x-4, y-qq-TILEWH, 24, 0, 24, 32, bmp); }
break;
case 1:
// right
- //if(ls==0) modexClearPlayer(mv->page, x+qq-4, y-TILEWH, 24, 32);
- if(ls<1) { modexClearPlayer(mv->page, x+qq-4, y-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x+qq-4, y-TILEWH, 24, 32, 24, 32, bmp); }
- if(4>ls && ls>=1) { modexClearPlayer(mv->page, x+qq-4, y-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x+qq-4, y-TILEWH, 48, 32, 24, 32, bmp); }
- if(7>ls && ls>=4) { modexClearPlayer(mv->page, x+qq-4, y-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x+qq-4, y-TILEWH, 0, 32, 24, 32, bmp); }
- if(ls>=7) { modexClearPlayer(mv->page, x+qq-4, y-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x+qq-4, y-TILEWH, 24, 32, 24, 32, bmp); }
+ if(ls<1) { modexCopyPageRegion(mv->page, src->page, x+qq-4, y-TILEWH, x+qq-4, y-TILEWH, 24, 34);
+ modexDrawSpriteRegion(mv->page, x+qq-4, y-TILEWH, 24, 32, 24, 32, bmp); }
+ if(4>ls && ls>=1) { modexCopyPageRegion(mv->page, src->page, x+qq-4, y-TILEWH, x+qq-4, y-TILEWH, 24, 34);
+ modexDrawSpriteRegion(mv->page, x+qq-4, y-TILEWH, 48, 32, 24, 32, bmp); }
+ if(7>ls && ls>=4) { modexCopyPageRegion(mv->page, src->page, x+qq-4, y-TILEWH, x+qq-4, y-TILEWH, 24, 34);
+ modexDrawSpriteRegion(mv->page, x+qq-4, y-TILEWH, 0, 32, 24, 32, bmp); }
+ if(ls>=7) { modexCopyPageRegion(mv->page, src->page, x+qq-4, y-TILEWH, x+qq-4, y-TILEWH, 24, 34);
+ modexDrawSpriteRegion(mv->page, x+qq-4, y-TILEWH, 24, 32, 24, 32, bmp); }
break;
case 2:
//down
- //if(ls==0) modexClearPlayer(mv->page, x-4, y+qq-TILEWH, 24, 32);
- if(ls<1) { modexClearPlayer(mv->page, x-4, y+qq-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-4, y+qq-TILEWH, 24, 64, 24, 32, bmp); }
- if(4>ls && ls>=1) { modexClearPlayer(mv->page, x-4, y+qq-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-4, y+qq-TILEWH, 48, 64, 24, 32, bmp); }
- if(7>ls && ls>=4) { modexClearPlayer(mv->page, x-4, y+qq-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-4, y+qq-TILEWH, 0, 64, 24, 32, bmp); }
- if(ls>=7) { modexClearPlayer(mv->page, x-4, y+qq-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-4, y+qq-TILEWH, 24, 64, 24, 32, bmp); }
+ if(ls<1) { modexCopyPageRegion(mv->page, src->page, x-4, y+qq-TILEWH, x-4, y+qq-TILEWH, 24, 34);
+ modexDrawSpriteRegion(mv->page, x-4, y+qq-TILEWH, 24, 64, 24, 32, bmp); }
+ if(4>ls && ls>=1) { modexCopyPageRegion(mv->page, src->page, x-4, y+qq-TILEWH, x-4, y+qq-TILEWH, 24, 34);
+ modexDrawSpriteRegion(mv->page, x-4, y+qq-TILEWH, 48, 64, 24, 32, bmp); }
+ if(7>ls && ls>=4) { modexCopyPageRegion(mv->page, src->page, x-4, y+qq-TILEWH, x-4, y+qq-TILEWH, 24, 34);
+ modexDrawSpriteRegion(mv->page, x-4, y+qq-TILEWH, 0, 64, 24, 32, bmp); }
+ if(ls>=7) { modexCopyPageRegion(mv->page, src->page, x-4, y+qq-TILEWH, x-4, y+qq-TILEWH, 24, 34);
+ modexDrawSpriteRegion(mv->page, x-4, y+qq-TILEWH, 24, 64, 24, 32, bmp); }
break;
case 3:
//left
- //if(ls==0) modexClearPlayer(mv->page, x-qq-4, y-TILEWH, 24, 32);
- if(ls<1) { modexClearPlayer(mv->page, x-qq-4, y-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-qq-4, y-TILEWH, 24, 96, 24, 32, bmp); }
- if(4>ls && ls>=1) { modexClearPlayer(mv->page, x-qq-4, y-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-qq-4, y-TILEWH, 48, 96, 24, 32, bmp); }
- if(7>ls && ls>=4) { modexClearPlayer(mv->page, x-qq-4, y-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-qq-4, y-TILEWH, 0, 96, 24, 32, bmp); }
- if(ls>=7) { modexClearPlayer(mv->page, x-qq-4, y-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-qq-4, y-TILEWH, 24, 96, 24, 32, bmp); }
+ if(ls<1) { modexCopyPageRegion(mv->page, src->page, x-qq-4, y-TILEWH, x-qq-4, y-TILEWH, 24, 34);
+ modexDrawSpriteRegion(mv->page, x-qq-4, y-TILEWH, 24, 96, 24, 32, bmp); }
+ if(4>ls && ls>=1) { modexCopyPageRegion(mv->page, src->page, x-qq-4, y-TILEWH, x-qq-4, y-TILEWH, 24, 34);
+ modexDrawSpriteRegion(mv->page, x-qq-4, y-TILEWH, 48, 96, 24, 32, bmp); }
+ if(7>ls && ls>=4) { modexCopyPageRegion(mv->page, src->page, x-qq-4, y-TILEWH, x-qq-4, y-TILEWH, 24, 34);
+ modexDrawSpriteRegion(mv->page, x-qq-4, y-TILEWH, 0, 96, 24, 32, bmp); }
+ if(ls>=7) { modexCopyPageRegion(mv->page, src->page, x-qq-4, y-TILEWH, x-qq-4, y-TILEWH, 24, 34);
+ modexDrawSpriteRegion(mv->page, x-qq-4, y-TILEWH, 24, 96, 24, 32, bmp); }
break;
}
}