void mapGoTo(map_view_t *mv, int tx, int ty);\r
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);\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
\r
#define TILEWH 16\r
#define QUADWH (TILEWH/4)
#define MAPY 30\r
//#define SWAP(a, b) tmp=a; a=b; b=tmp;\r
void main() {\r
- bitmap_t bmp;\r
+ bitmap_t ptmp; // player sprite\r
int q=0;\r
- page_t screen;//,screen2;\r
+ page_t screen, screen2;\r
map_t map;\r
- map_view_t mv;//, mv2;\r
- map_view_t *draw;//, *show, *tmp;\r
+ map_view_t mv, mv2;\r
+ map_view_t *draw, *show, *tmp;\r
byte *ptr;\r
\r
setkb(1);\r
\r
/* draw the tiles */\r
ptr = map.data;
- bmp = bitmapLoadPcx("ptmp.pcx"); // load sprite
- modexPalUpdate(bmp.palette);\r
- modexEnter();\r
+ ptmp = bitmapLoadPcx("ptmp.pcx"); // load sprite\r
+ modexEnter();
+ modexPalUpdate(ptmp.palette);\r
screen = modexDefaultPage();\r
screen.width += (TILEWH*2);\r
mv.page = &screen;\r
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
while(!keyp(1))
{\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);
if(draw->tx >= 0 && draw->tx+20 < MAPX && player.tx == draw->tx + 10)
{
for(q=0; q<(TILEWH/SPEED); q++)
{\r
- modexDrawBmp(draw->page, player.x+((q+1)*SPEED), player.y, &bmp);
+// modexDrawBmp(draw->page, &bmp);
+ animatePlayer(draw, 1, 1, player.x, player.y, q, &ptmp);
mapScrollRight(draw, SPEED);
modexShowPage(draw->page);\r
// mapScrollRight(draw, 1);\r
for(q=0; q<(TILEWH/SPEED); q++)
{
player.x+=SPEED;
- modexDrawBmp(draw->page, player.x, player.y, &bmp);
+// modexDrawBmp(draw->page, player.x, player.y, &bmp);
+ animatePlayer(draw, 1, 0, player.x, player.y, q, &ptmp);
modexShowPage(draw->page);
}
player.tx++;
}\r
}\r
\r
- if(keyp(75)){
+ if(keyp(75))
+ {
+// modexDrawSpriteRegion(draw->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)
- {\r
+ {
for(q=0; q<(TILEWH/SPEED); q++)
{
- modexDrawBmp(draw->page, player.x-((q+1)*SPEED), player.y, &bmp);
+// modexDrawBmp(draw->page, player.x-((q+1)*SPEED), player.y, &bmp);
+ animatePlayer(draw, 3, 1, player.x, player.y, q, &ptmp);
mapScrollLeft(draw, SPEED);
modexShowPage(draw->page);\r
// mapScrollLeft(show, 1);\r
for(q=0; q<(TILEWH/SPEED); q++)
{
player.x-=SPEED;
- modexDrawBmp(draw->page, player.x, player.y, &bmp);
+// modexDrawBmp(draw->page, player.x, player.y, &bmp);
+ animatePlayer(draw, 3, 0, player.x, player.y, q, &ptmp);
modexShowPage(draw->page);
}
player.tx--;
\r
if(keyp(80))
{
+ modexDrawSpriteRegion(draw->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);
+// modexDrawBmp(draw->page, player.x, player.y+((q+1)*SPEED), &bmp);
+ animatePlayer(draw, 2, 1, player.x, player.y, q, &ptmp);
mapScrollDown(draw, SPEED);
modexShowPage(draw->page);\r
// mapScrollDown(show, 1);\r
for(q=0; q<(TILEWH/SPEED); q++)
{
player.y+=SPEED;
- modexDrawBmp(draw->page, player.x, player.y, &bmp);
+// modexDrawBmp(draw->page, player.x, player.y, &bmp);
+ animatePlayer(draw, 2, 0, player.x, player.y, q, &ptmp);
modexShowPage(draw->page);
}
player.ty++;
{\r
for(q=0; q<(TILEWH/SPEED); q++)
{\r
- modexDrawBmp(draw->page, player.x, player.y-((q+1)*SPEED), &bmp);
+// modexDrawBmp(draw->page, player.x, player.y-((q+1)*SPEED), &bmp);
+ animatePlayer(draw, 0, 1, player.x, player.y, q, &ptmp);
mapScrollUp(draw, SPEED);
modexShowPage(draw->page);
// mapScrollUp(show, 1);\r
for(q=0; q<(TILEWH/SPEED); q++)
{
player.y-=SPEED;
- modexDrawBmp(draw->page, player.x, player.y, &bmp);
+// modexDrawBmp(draw->page, player.x, player.y, &bmp);
+ animatePlayer(draw, 0, 0, player.x, player.y, q, &ptmp);
modexShowPage(draw->page);
}
player.ty--;
}\r
}\r
- modexDrawBmp(draw->page, player.x, player.y, &bmp);\r
+// modexDrawBmp(draw->page, player.x, player.y, &bmp);\r
//modexShowPage(draw->page);\r
\r
}\r
i += mv->map->width;\r
}\r
}\r
+
+void animatePlayer(map_view_t *mv, short d1, short d2, int x, int y, int ls, bitmap_t *bmp)
+{
+ int qq;
+
+ if(d2==0) qq = 0;
+ else qq = ((ls+1)*SPEED);
+ switch (d1)
+ {
+ case 0:
+ //up
+ if(ls<2) modexDrawSpriteRegion(mv->page, x-4, y-qq-TILEWH, 24, 0, 24, 32, bmp);
+ if(4>ls && ls>=2) modexDrawSpriteRegion(mv->page, x-4, y-qq-TILEWH, 0, 0, 24, 32, bmp);
+ if(6>ls && ls>=4) modexDrawSpriteRegion(mv->page, x-4, y-qq-TILEWH, 48, 0, 24, 32, bmp);
+ if(ls>6) modexDrawSpriteRegion(mv->page, x-4, y-qq-TILEWH, 24, 0, 24, 32, bmp);
+ break;
+ case 1:
+ // right
+ //right
+ if(ls<2) modexDrawSpriteRegion(mv->page, x+qq-4, y-TILEWH, 24, 32, 24, 32, bmp);
+ if(4>ls && ls>=2) modexDrawSpriteRegion(mv->page, x+qq-4, y-TILEWH, 0, 32, 24, 32, bmp);
+ if(6>ls && ls>=4) modexDrawSpriteRegion(mv->page, x+qq-4, y-TILEWH, 48, 32, 24, 32, bmp);
+ if(ls>6) modexDrawSpriteRegion(mv->page, x+qq-4, y-TILEWH, 24, 32, 24, 32, bmp);
+ break;
+ case 2:
+ //down
+ if(ls<2) modexDrawSpriteRegion(mv->page, x-4, y+qq-TILEWH, 24, 64, 24, 32, bmp);
+ if(4>ls && ls>=2) modexDrawSpriteRegion(mv->page, x-4, y+qq-TILEWH, 0, 64, 24, 32, bmp);
+ if(6>ls && ls>=4) modexDrawSpriteRegion(mv->page, x-4, y+qq-TILEWH, 48, 64, 24, 32, bmp);
+ if(ls>6) modexDrawSpriteRegion(mv->page, x-4, y+qq-TILEWH, 24, 64, 24, 32, bmp);
+ break;
+ case 3:
+ //left
+ if(ls<2) modexDrawSpriteRegion(mv->page, x-qq-4, y-TILEWH, 24, 96, 24, 32, bmp);
+ if(4>ls && ls>=2) modexDrawSpriteRegion(mv->page, x-qq-4, y-TILEWH, 0, 96, 24, 32, bmp);
+ if(6>ls && ls>=4) modexDrawSpriteRegion(mv->page, x-qq-4, y-TILEWH, 48, 96, 24, 32, bmp);
+ if(ls>6) modexDrawSpriteRegion(mv->page, x-qq-4, y-TILEWH, 24, 96, 24, 32, bmp);
+ break;
+ }
+}